Package com.mewna.catnip.cache.view
Class CompositeCacheView<T>
java.lang.Object
com.mewna.catnip.cache.view.CompositeCacheView<T>
- Type Parameters:
T
- Type of the entity held by this cache.
- Direct Known Subclasses:
CompositeNamedCacheView
A
CacheView
that's equivalent to a collection of provided ones.
Any update to any of the provided views will update this view.- Since:
- 12/15/18
- Author:
- natanbc
-
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.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.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
-
Field Details
-
sources
-
-
Constructor Details
-
CompositeCacheView
-
-
Method Details
-
forEach
Description copied from interface:CacheView
Iterates this view, providing all elements to the given consumer. -
size
@Nonnegative 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(@Nonnull 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
-
iterator
-