Class UnifiedChannelCacheView<C extends Channel>
java.lang.Object
net.dv8tion.jda.internal.utils.cache.UnifiedChannelCacheView<C>
- All Implemented Interfaces:
Iterable<C>
,CacheView<C>
,ChannelCacheView<C>
,SnowflakeCacheView<C>
public class UnifiedChannelCacheView<C extends Channel>
extends Object
implements ChannelCacheView<C>
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.dv8tion.jda.api.utils.cache.CacheView
CacheView.SimpleCacheView<T>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasList()
Creates an immutable snapshot of the current cache state.asSet()
Creates an immutable snapshot of the current cache state.void
getElementById
(long id) Retrieves the entity represented by the provided ID.getElementById
(ChannelType type, long id) Retrieves the entity represented by the provided ID.getElementsByName
(String name, boolean ignoreCase) Creates an immutable list of all elements matching the given name.boolean
isEmpty()
Whether the cache is emptyiterator()
Returns an iterator with direct access to the underlying data store.<T extends C>
ChannelCacheView<T> Creates a decorator around this cache, filtered to only provide access to the given type.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)
)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.api.utils.cache.CacheView
acceptStream, applyStream, collect, forEachUnordered, getElementsByName
Methods inherited from interface net.dv8tion.jda.api.utils.cache.ChannelCacheView
getElementById
Methods inherited from interface java.lang.Iterable
spliterator
Methods inherited from interface net.dv8tion.jda.api.utils.cache.SnowflakeCacheView
getElementById
-
Constructor Details
-
UnifiedChannelCacheView
-
-
Method Details
-
forEach
-
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
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. -
lockedIterator
Description copied from interface:CacheView
Returns an iterator with direct access to the underlying data store. This iterator does not support removing elements.
After usage this iterator should be closed to allow modifications by the library internals.Note: Order is not preserved in this iterator to be more efficient, if order is desired use
Iterable.iterator()
instead!- Specified by:
lockedIterator
in interfaceCacheView<C extends Channel>
- Returns:
ClosableIterator
holding a read-lock on the data structure.
-
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. -
getElementsByName
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<C extends Channel>
- Parameters:
name
- The name to checkignoreCase
- Whether to ignore case when comparing names- Returns:
- Immutable list of elements with the given name
-
stream
Description copied from interface:CacheView
-
parallelStream
Description copied from interface:CacheView
Creates a parallelStream
of all cached elements.
This will be sorted for aSortedSnowflakeCacheView
.- Specified by:
parallelStream
in interfaceCacheView<C extends Channel>
- Returns:
- Parallel Stream of elements
-
ofType
Description copied from interface:ChannelCacheView
Creates a decorator around this cache, filtered to only provide access to the given type.- Specified by:
ofType
in interfaceChannelCacheView<C extends Channel>
- Type Parameters:
T
- The type parameter- Parameters:
type
- The type class (LikeTextChannel.class
)- Returns:
- The filtered cache view
-
getElementById
Description copied from interface:ChannelCacheView
Retrieves the entity represented by the provided ID.- Specified by:
getElementById
in interfaceChannelCacheView<C extends Channel>
- Parameters:
type
- The expectedChannelType
id
- The ID of the entity- Returns:
- Possibly-null entity for the specified ID, null if the expected type is different from the actual type
-
getElementById
Description copied from interface:SnowflakeCacheView
Retrieves the entity represented by the provided ID.- Specified by:
getElementById
in interfaceSnowflakeCacheView<C extends Channel>
- Parameters:
id
- The ID of the entity- Returns:
- Possibly-null entity for the specified ID
-
iterator
-