Class ShardCacheViewImpl
java.lang.Object
net.dv8tion.jda.internal.utils.cache.ReadWriteLockCache<JDA>
net.dv8tion.jda.internal.utils.cache.ShardCacheViewImpl
- All Implemented Interfaces:
Iterable<JDA>
,CacheView<JDA>
,ShardCacheView
-
Nested Class Summary
Nested ClassesNested 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
clear()
boolean
void
getElementById
(int id) Retrieves the JDA instance represented by the provided shard ID.getElementsByName
(String name, boolean ignoreCase) Creates an immutable list of all elements matching the given name.gnu.trove.map.TIntObjectMap
<JDA> getMap()
int
hashCode()
boolean
isEmpty()
Whether the cache is emptyiterator()
gnu.trove.set.TIntSet
keySet()
Returns an iterator with direct access to the underlying data store.Creates a parallelStream
of all cached elements.remove
(int shardId) 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.toString()
Methods inherited from class net.dv8tion.jda.internal.utils.cache.ReadWriteLockCache
clearCachedLists, readLock, writeLock
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.ShardCacheView
getElementById
-
Constructor Details
-
ShardCacheViewImpl
public ShardCacheViewImpl() -
ShardCacheViewImpl
public ShardCacheViewImpl(int initialCapacity)
-
-
Method Details
-
clear
public void clear() -
remove
-
getMap
-
keySet
public gnu.trove.set.TIntSet keySet() -
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<JDA>
- 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<JDA>
- Parameters:
name
- The name to checkignoreCase
- Whether to ignore case when comparing names- Returns:
- Immutable list of elements with the given name
-
spliterator
- Specified by:
spliterator
in interfaceIterable<JDA>
-
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<JDA>
- Returns:
- Parallel Stream of elements
-
iterator
-
getElementById
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
-
hashCode
public int hashCode() -
equals
-
toString
-