Class UnifiedCacheViewImpl<T,E extends CacheView<T>>
java.lang.Object
net.dv8tion.jda.internal.utils.cache.UnifiedCacheViewImpl<T,E>
- Direct Known Subclasses:
UnifiedCacheViewImpl.UnifiedMemberCacheViewImpl
,UnifiedCacheViewImpl.UnifiedSnowflakeCacheView
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
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
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.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 java.lang.Iterable
spliterator
-
Constructor Details
-
UnifiedCacheViewImpl
-
-
Method Details
-
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. -
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<T>
- Returns:
ClosableIterator
holding a read-lock on the data structure.
-
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<T>
- 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<T>
- Returns:
- Parallel Stream of elements
-
iterator
-