T
- The cache typejava.lang.Iterable<T>
MemberCacheView
, ShardCacheView
, SnowflakeCacheView<T>
, UnifiedMemberCacheView
net.dv8tion.jda.core.utils.cache.impl.AbstractCacheView
, CacheView.SimpleCacheView
, ShardCacheViewImpl
, ShardCacheViewImpl.UnifiedShardCacheViewImpl
public interface CacheView<T>
extends java.lang.Iterable<T>
Modifier and Type | Interface | Description |
---|---|---|
static class |
CacheView.SimpleCacheView<T> |
Basic implementation of
CacheView interface. |
Modifier and Type | Method | Description |
---|---|---|
static <E> CacheView<E> |
all(java.util.Collection<? extends CacheView<E>> cacheViews) |
Creates a combined
CacheView
for all provided CacheView implementations. |
static <E> CacheView<E> |
all(java.util.function.Supplier<java.util.stream.Stream<CacheView<E>>> generator) |
Creates a combined
CacheView
for all provided CacheView implementations. |
static UnifiedMemberCacheView |
allMembers(java.util.Collection<MemberCacheView> cacheViews) |
Creates a combined
UnifiedMemberCacheView
for all provided MemberCacheView implementations. |
static UnifiedMemberCacheView |
allMembers(java.util.function.Supplier<java.util.stream.Stream<MemberCacheView>> generator) |
Creates a combined
UnifiedMemberCacheView
for all provided MemberCacheView implementations. |
static ShardCacheView |
allShards(java.util.Collection<ShardCacheView> cacheViews) |
Creates a combined
ShardCacheView
for all provided ShardCacheView implementations. |
static ShardCacheView |
allShards(java.util.function.Supplier<java.util.stream.Stream<ShardCacheView>> generator) |
Creates a combined
ShardCacheView
for all provided ShardCacheView implementations. |
static <E extends ISnowflake> |
allSnowflakes(java.util.Collection<SnowflakeCacheView<E>> cacheViews) |
Creates a combined
SnowflakeCacheView
for all provided SnowflakeCacheView implementations. |
static <E extends ISnowflake> |
allSnowflakes(java.util.function.Supplier<java.util.stream.Stream<SnowflakeCacheView<E>>> generator) |
Creates a combined
SnowflakeCacheView
for all provided SnowflakeCacheView implementations. |
java.util.List<T> |
asList() |
Creates an immutable snapshot of the current cache state.
|
java.util.Set<T> |
asSet() |
Creates an immutable snapshot of the current cache state.
|
default <R,A> R |
collect(java.util.stream.Collector<? super T,A,R> collector) |
Collects all cached entities into a single Collection using the provided
Collector . |
default java.util.List<T> |
getElementsByName(java.lang.String name) |
Creates an immutable list of all elements matching the given name.
|
java.util.List<T> |
getElementsByName(java.lang.String name,
boolean ignoreCase) |
Creates an immutable list of all elements matching the given name.
|
boolean |
isEmpty() |
Whether the cache is empty
|
java.util.stream.Stream<T> |
parallelStream() |
Creates a parallel
Stream of all cached elements. |
long |
size() |
The current size of this cache
This is a long as it may be a projected view of multiple caches
(See all(java.util.function.Supplier) ) |
java.util.stream.Stream<T> |
stream() |
Creates a
Stream of all cached elements. |
java.util.List<T> asList()
SortedSnowflakeCacheView
.java.util.Set<T> asSet()
long size()
long
as it may be a projected view of multiple caches
(See all(java.util.function.Supplier)
)
This is more efficient than creating a list or set snapshot first as it checks the size of the internal cache directly.
boolean isEmpty()
This is more efficient than creating a list or set snapshot first as it checks the size
of the internal cache directly.
On a projected cache view this will simply look through all projected views and return false
the moment it finds one that is not empty.
java.util.List<T> getElementsByName(java.lang.String name, boolean ignoreCase)
MemberCacheView
this will
check the Effective Name
of the cached members.name
- The name to checkignoreCase
- Whether to ignore case when comparing namesjava.lang.IllegalArgumentException
- If the provided name is null
default java.util.List<T> getElementsByName(java.lang.String name)
MemberCacheView
this will
check the Effective Name
of the cached members.name
- The name to checkjava.lang.IllegalArgumentException
- If the provided name is null
java.util.stream.Stream<T> stream()
Stream
of all cached elements.
SortedSnowflakeCacheView
.java.util.stream.Stream<T> parallelStream()
Stream
of all cached elements.
SortedSnowflakeCacheView
.default <R,A> R collect(java.util.stream.Collector<? super T,A,R> collector)
Collector
.
Shortcut for stream().collect(collector)
.R
- The output typeA
- The accumulator typecollector
- The collector used to collect the elementsjava.lang.IllegalArgumentException
- If the provided collector is null
static <E> CacheView<E> all(java.util.Collection<? extends CacheView<E>> cacheViews)
CacheView
for all provided CacheView implementations. This allows to combine cache of multiple
JDA sessions or Guilds.E
- The target type of the projectioncacheViews
- Collection of CacheView
implementationsstatic <E> CacheView<E> all(java.util.function.Supplier<java.util.stream.Stream<CacheView<E>>> generator)
CacheView
for all provided CacheView implementations. This allows to combine cache of multiple
JDA sessions or Guilds.E
- The target type of the projectiongenerator
- Stream generator of CacheView
implementationsstatic ShardCacheView allShards(java.util.Collection<ShardCacheView> cacheViews)
ShardCacheView
for all provided ShardCacheView implementations.cacheViews
- Collection of ShardCacheView
implementationsstatic ShardCacheView allShards(java.util.function.Supplier<java.util.stream.Stream<ShardCacheView>> generator)
ShardCacheView
for all provided ShardCacheView implementations.generator
- Stream generator of ShardCacheView
implementationsstatic <E extends ISnowflake> SnowflakeCacheView<E> allSnowflakes(java.util.Collection<SnowflakeCacheView<E>> cacheViews)
SnowflakeCacheView
for all provided SnowflakeCacheView implementations.
E
- The target type of the chaincacheViews
- Collection of SnowflakeCacheView
implementationsstatic <E extends ISnowflake> SnowflakeCacheView<E> allSnowflakes(java.util.function.Supplier<java.util.stream.Stream<SnowflakeCacheView<E>>> generator)
SnowflakeCacheView
for all provided SnowflakeCacheView implementations.
E
- The target type of the chaingenerator
- Stream generator of SnowflakeCacheView
implementationsstatic UnifiedMemberCacheView allMembers(java.util.Collection<MemberCacheView> cacheViews)
UnifiedMemberCacheView
for all provided MemberCacheView implementations.
cacheViews
- Collection of MemberCacheView
instancesstatic UnifiedMemberCacheView allMembers(java.util.function.Supplier<java.util.stream.Stream<MemberCacheView>> generator)
UnifiedMemberCacheView
for all provided MemberCacheView implementations.
generator
- Stream generator of MemberCacheView
instances