Package com.mewna.catnip.cache.view
Class NoopCacheView<T>
java.lang.Object
com.mewna.catnip.cache.view.NoopCacheView<T>
- Type Parameters:
T
- Type of the element contained by this cache.
- All Implemented Interfaces:
CacheView<T>
,MutableCacheView<T>
,MutableNamedCacheView<T>
,NamedCacheView<T>
,Iterable<T>
Helper class for noop caches. All mutation methods are noop. Always empty.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether all elements of this cache match the provided predicate.boolean
Returns whether any elements of this cache match the provided predicate.<R> R
collect
(Supplier<R> supplier, BiConsumer<R, ? super T> accumulator, BiConsumer<R, R> combiner) Performs a mutable reduction operation on the elements of this cache.<A,
R> R Performs a mutable reduction operation on the elements of this cache using aCollector
.long
Returns the amount of elements that match the provided predicate.Returns all elements in this cache that matches the given filter.<C extends Collection<T>>
CReturns all elements in this cache that matches the given filter.Returns any element in this cache that matches the given filter.findByName
(String name, boolean ignoreCase) Finds all entities with a name equal to the provided value.<C extends Collection<T>>
CfindByName
(String name, boolean ignoreCase, Supplier<C> supplier) Finds all entities with a name equal to the provided value.findByNameContains
(String name, boolean ignoreCase) Finds all entities whose name contains the provided value.<C extends Collection<T>>
CfindByNameContains
(String name, boolean ignoreCase, Supplier<C> supplier) Finds all entities whose name contains the provided value.findByNameEndsWith
(String name, boolean ignoreCase) Finds all entities whose name ends with the provided value.<C extends Collection<T>>
CfindByNameEndsWith
(String name, boolean ignoreCase, Supplier<C> supplier) Finds all entities whose name ends with the provided value.findByNameStartsWith
(String name, boolean ignoreCase) Finds all entities whose name starts with the provided value.<C extends Collection<T>>
CfindByNameStartsWith
(String name, boolean ignoreCase, Supplier<C> supplier) Finds all entities whose name starts with the provided value.void
Iterates this view, providing all elements to the given consumer.getById
(long id) boolean
isEmpty()
iterator()
keys()
max
(Comparator<? super T> comparator) Returns the maximum element of this cache according to the providedComparator
.min
(Comparator<? super T> comparator) Returns the minimum element of this cache according to the providedComparator
.boolean
Returns whether no elements of this cache match the provided predicate.reduce
(BinaryOperator<T> accumulator) Performs a reduction on the elements of this cache, using an associative accumulation function, and returns anOptional
describing the reduced value, if any.reduce
(T identity, BinaryOperator<T> accumulator) Performs a reduction on the elements of this cache, using the provided identity value and an associative accumulation function, and returns the reduced value.<U> U
reduce
(U identity, BiFunction<U, ? super T, U> accumulator, BinaryOperator<U> combiner) Performs a reduction on the elements of this cache, using the provided identity, accumulation and combining functions.remove
(long key) void
removeIf
(LongPredicate predicate) long
size()
snapshot()
<C extends Collection<T>>
Cvalues()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.mewna.catnip.cache.view.CacheView
getById, spliterator, stream
Methods inherited from interface com.mewna.catnip.cache.view.NamedCacheView
findByName, findByName, findByNameContains, findByNameContains, findByNameEndsWith, findByNameEndsWith, findByNameStartsWith, findByNameStartsWith
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
NoopCacheView
public NoopCacheView()
-
-
Method Details
-
removeIf
- Specified by:
removeIf
in interfaceMutableCacheView<T>
-
put
- Specified by:
put
in interfaceMutableCacheView<T>
-
remove
- Specified by:
remove
in interfaceMutableCacheView<T>
-
findByName
Description copied from interface:NamedCacheView
Finds all entities with a name equal to the provided value.- Specified by:
findByName
in interfaceNamedCacheView<T>
- Parameters:
name
- Name to search for.ignoreCase
- Ignore casing differences between the entity names and the provided name.- Returns:
- All elements that have a name equal to the provided.
- See Also:
-
findByName
@Nonnull public <C extends Collection<T>> C findByName(@Nonnull String name, boolean ignoreCase, @Nonnull Supplier<C> supplier) Description copied from interface:NamedCacheView
Finds all entities with a name equal to the provided value.- Specified by:
findByName
in interfaceNamedCacheView<T>
- Parameters:
name
- Name to search for.ignoreCase
- Ignore casing differences between the entity names and the provided name.supplier
- Supplier for the collection to add the elements to. The returned collection must be mutable.- Returns:
- The collection returned by
supplier
, after adding the matching elements. May be empty. - See Also:
-
findByNameContains
Description copied from interface:NamedCacheView
Finds all entities whose name contains the provided value.- Specified by:
findByNameContains
in interfaceNamedCacheView<T>
- Parameters:
name
- Name to search for.ignoreCase
- Ignore casing differences between the entity names and the provided name.- Returns:
- All elements that have a name containing the provided.
- See Also:
-
findByNameContains
@Nonnull public <C extends Collection<T>> C findByNameContains(@Nonnull String name, boolean ignoreCase, @Nonnull Supplier<C> supplier) Description copied from interface:NamedCacheView
Finds all entities whose name contains the provided value.- Specified by:
findByNameContains
in interfaceNamedCacheView<T>
- Parameters:
name
- Name to search for.ignoreCase
- Ignore casing differences between the entity names and the provided name.supplier
- Supplier for the collection to add the elements to. The returned collection must be mutable.- Returns:
- The collection returned by
supplier
, after adding the matching elements. May be empty. - See Also:
-
findByNameStartsWith
Description copied from interface:NamedCacheView
Finds all entities whose name starts with the provided value.- Specified by:
findByNameStartsWith
in interfaceNamedCacheView<T>
- Parameters:
name
- Name to search for.ignoreCase
- Ignore casing differences between the entity names and the provided name.- Returns:
- All elements that have a name starting with the provided.
- See Also:
-
findByNameStartsWith
@Nonnull public <C extends Collection<T>> C findByNameStartsWith(@Nonnull String name, boolean ignoreCase, @Nonnull Supplier<C> supplier) Description copied from interface:NamedCacheView
Finds all entities whose name starts with the provided value.- Specified by:
findByNameStartsWith
in interfaceNamedCacheView<T>
- Parameters:
name
- Name to search for.ignoreCase
- Ignore casing differences between the entity names and the provided name.supplier
- Supplier for the collection to add the elements to. The returned collection must be mutable.- Returns:
- The collection returned by
supplier
, after adding the matching elements. May be empty. - See Also:
-
findByNameEndsWith
Description copied from interface:NamedCacheView
Finds all entities whose name ends with the provided value.- Specified by:
findByNameEndsWith
in interfaceNamedCacheView<T>
- Parameters:
name
- Name to search for.ignoreCase
- Ignore casing differences between the entity names and the provided name.- Returns:
- All elements that have a name ending with the provided.
- See Also:
-
findByNameEndsWith
@Nonnull public <C extends Collection<T>> C findByNameEndsWith(@Nonnull String name, boolean ignoreCase, @Nonnull Supplier<C> supplier) Description copied from interface:NamedCacheView
Finds all entities whose name ends with the provided value.- Specified by:
findByNameEndsWith
in interfaceNamedCacheView<T>
- Parameters:
name
- Name to search for.ignoreCase
- Ignore casing differences between the entity names and the provided name.supplier
- Supplier for the collection to add the elements to. The returned collection must be mutable.- Returns:
- The collection returned by
supplier
, after adding the matching elements. May be empty. - See Also:
-
iterator
-
forEach
Description copied from interface:CacheView
Iterates this view, providing all elements to the given consumer. -
size
public long size() -
isEmpty
public boolean isEmpty() -
getById
-
findAny
Description copied from interface:CacheView
Returns any element in this cache that matches the given filter. There are no order guarantees if multiple elements match. Use with caution. -
find
Description copied from interface:CacheView
Returns all elements in this cache that matches the given filter. There are no order guarantees if multiple elements match. -
find
@Nonnull public <C extends Collection<T>> C find(@Nonnull Predicate<? super T> filter, @Nonnull Supplier<C> supplier) Description copied from interface:CacheView
Returns all elements in this cache that matches the given filter. There are no order guarantees if multiple elements match. -
collect
Description copied from interface:CacheView
Performs a mutable reduction operation on the elements of this cache using aCollector
. -
collect
@Nonnull public <R> R collect(@Nonnull Supplier<R> supplier, @Nonnull BiConsumer<R, ? super T> accumulator, @Nonnull BiConsumer<R, R> combiner) Description copied from interface:CacheView
Performs a mutable reduction operation on the elements of this cache.- Specified by:
collect
in interfaceCacheView<T>
- Type Parameters:
R
- The type of the result.- Parameters:
supplier
- A function that creates a new result container. For a parallel execution, this function may be called multiple times and must return a fresh value each time.accumulator
- An associative, non-interfering, stateless function for incorporating an additional element into a result.combiner
- An associative, non-interfering, stateless function for combining two values, which must be compatible with the accumulator function.- Returns:
- The result of the reduction.
- See Also:
-
reduce
@Nonnull public <U> U reduce(U identity, @Nonnull BiFunction<U, ? super T, U> accumulator, @Nonnull BinaryOperator<U> combiner) Description copied from interface:CacheView
Performs a reduction on the elements of this cache, using the provided identity, accumulation and combining functions.- Specified by:
reduce
in interfaceCacheView<T>
- Type Parameters:
U
- The type of the result.- Parameters:
identity
- The identity value for the combiner function.accumulator
- An associative, non-interfering, stateless function for incorporating an additional element into a result.combiner
- An associative, non-interfering, stateless function for combining two values, which must be compatible with the accumulator function- Returns:
- the result of the reduction
- See Also:
-
reduce
Description copied from interface:CacheView
Performs a reduction on the elements of this cache, using an associative accumulation function, and returns anOptional
describing the reduced value, if any. -
reduce
Description copied from interface:CacheView
Performs a reduction on the elements of this cache, using the provided identity value and an associative accumulation function, and returns the reduced value. -
anyMatch
Description copied from interface:CacheView
Returns whether any elements of this cache match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result. If the cache is empty thenfalse
is returned and the predicate is not evaluated. -
allMatch
Description copied from interface:CacheView
Returns whether all elements of this cache match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result. If the cache is empty thentrue
is returned and the predicate is not evaluated. -
noneMatch
Description copied from interface:CacheView
Returns whether no elements of this cache match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result. If the cache is empty thentrue
is returned and the predicate is not evaluated. -
min
Description copied from interface:CacheView
Returns the minimum element of this cache according to the providedComparator
. This is a special case of a reduction. -
max
Description copied from interface:CacheView
Returns the maximum element of this cache according to the providedComparator
. This is a special case of a reduction. -
count
Description copied from interface:CacheView
Returns the amount of elements that match the provided predicate. -
keys
-
values
-
snapshot
-
snapshot
-