Class ShardCacheViewImpl.UnifiedShardCacheViewImpl
- java.lang.Object
-
- net.dv8tion.jda.bot.utils.cache.impl.ShardCacheViewImpl.UnifiedShardCacheViewImpl
-
- All Implemented Interfaces:
java.lang.Iterable<JDA>
,ShardCacheView
,CacheView<JDA>
- Enclosing class:
- ShardCacheViewImpl
public static class ShardCacheViewImpl.UnifiedShardCacheViewImpl extends java.lang.Object implements ShardCacheView
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.dv8tion.jda.core.utils.cache.CacheView
CacheView.SimpleCacheView<T>
-
-
Constructor Summary
Constructors Constructor Description UnifiedShardCacheViewImpl(java.util.function.Supplier<java.util.stream.Stream<ShardCacheView>> generator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<JDA>
asList()
Creates an immutable snapshot of the current cache state.java.util.Set<JDA>
asSet()
Creates an immutable snapshot of the current cache state.JDA
getElementById(int id)
Retrieves the JDA instance represented by the provided shard ID.java.util.List<JDA>
getElementsByName(java.lang.String name, boolean ignoreCase)
Creates an immutable list of all elements matching the given name.boolean
isEmpty()
Whether the cache is emptyjava.util.Iterator<JDA>
iterator()
java.util.stream.Stream<JDA>
parallelStream()
Creates a parallelStream
of all cached elements.long
size()
The current size of this cache
This is along
as it may be a projected view of multiple caches (SeeCacheView.all(java.util.function.Supplier)
)java.util.stream.Stream<JDA>
stream()
Creates aStream
of all cached elements.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.dv8tion.jda.core.utils.cache.CacheView
collect, getElementsByName
-
Methods inherited from interface net.dv8tion.jda.bot.utils.cache.ShardCacheView
getElementById
-
-
-
-
Constructor Detail
-
UnifiedShardCacheViewImpl
public UnifiedShardCacheViewImpl(java.util.function.Supplier<java.util.stream.Stream<ShardCacheView>> generator)
-
-
Method Detail
-
size
public long size()
Description copied from interface:CacheView
The current size of this cache
This is along
as it may be a projected view of multiple caches (SeeCacheView.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.
-
isEmpty
public boolean isEmpty()
Description copied from interface:CacheView
Whether the cache is emptyThis 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.
-
asList
public java.util.List<JDA> asList()
Description copied from interface:CacheView
Creates an immutable snapshot of the current cache state.
This will copy all elements contained in this cache into a list.
This will be sorted for aSortedSnowflakeCacheView
.
-
asSet
public java.util.Set<JDA> asSet()
Description copied from interface:CacheView
Creates an immutable snapshot of the current cache state.
This will copy all elements contained in this cache into a set.
-
getElementsByName
public java.util.List<JDA> getElementsByName(java.lang.String name, boolean ignoreCase)
Description copied from interface:CacheView
Creates an immutable list of all elements matching the given name.
For aMemberCacheView
this will check theEffective Name
of the cached members.- Specified by:
getElementsByName
in interfaceCacheView<JDA>
- Parameters:
name
- The name to checkignoreCase
- Whether to ignore case when comparing names- Returns:
- Immutable list of elements with the given name
-
getElementById
public JDA getElementById(int id)
Description copied from interface:ShardCacheView
Retrieves the JDA instance represented by the provided shard ID.- Specified by:
getElementById
in interfaceShardCacheView
- Parameters:
id
- The ID of the entity- Returns:
- Possibly-null entity for the specified shard ID
-
stream
public java.util.stream.Stream<JDA> stream()
Description copied from interface:CacheView
Creates aStream
of all cached elements.
This will be sorted for aSortedSnowflakeCacheView
.
-
parallelStream
public java.util.stream.Stream<JDA> parallelStream()
Description copied from interface:CacheView
Creates a parallelStream
of all cached elements.
This will be sorted for aSortedSnowflakeCacheView
.- Specified by:
parallelStream
in interfaceCacheView<JDA>
- Returns:
- Parallel Stream of elements
-
-