Package org.javacord.core.util.cache
Class MemberCache
- java.lang.Object
-
- org.javacord.core.util.cache.MemberCache
-
public class MemberCache extends java.lang.Object
An immutable cache for all member entities.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MemberCache
addMember(Member member)
Adds a member to the cache.static MemberCache
empty()
Gets an empty channel cache.java.util.Optional<Member>
getMemberByIdAndServer(long id, long serverId)
Gets the member with the given id in the server with the given id.java.util.Set<Member>
getMembers()
Gets all channels in the cache.java.util.Set<Member>
getMembersById(long id)
Get all members with the given id.java.util.Set<Member>
getMembersByServer(long serverId)
Get all members in the server with the given id.java.util.Set<Server>
getServers(long userId)
Gets all servers that the user with the given id is a member of.UserCache
getUserCache()
Gets the underlying user cache.MemberCache
removeMember(Member member)
Removes a member from the cache.
-
-
-
Method Detail
-
empty
public static MemberCache empty()
Gets an empty channel cache.- Returns:
- An empty channel cache.
-
addMember
public MemberCache addMember(Member member)
Adds a member to the cache.Automatically updates the underlying user cache, too.
- Parameters:
member
- The member to add.- Returns:
- The new member cache.
-
removeMember
public MemberCache removeMember(Member member)
Removes a member from the cache.Automatically updates the underlying user cache, too.
- Parameters:
member
- The member to remove.- Returns:
- The new member cache.
-
getServers
public java.util.Set<Server> getServers(long userId)
Gets all servers that the user with the given id is a member of.- Parameters:
userId
- The id of the user.- Returns:
- All servers that the user with the given id is a member of.
-
getUserCache
public UserCache getUserCache()
Gets the underlying user cache.- Returns:
- The underlying user cache.
-
getMembers
public java.util.Set<Member> getMembers()
Gets all channels in the cache.- Returns:
- All channels.
-
getMembersById
public java.util.Set<Member> getMembersById(long id)
Get all members with the given id.- Parameters:
id
- The id of the member.- Returns:
- All member with the given id.
-
getMembersByServer
public java.util.Set<Member> getMembersByServer(long serverId)
Get all members in the server with the given id.- Parameters:
serverId
- The server id.- Returns:
- All member of the server with the given id.
-
getMemberByIdAndServer
public java.util.Optional<Member> getMemberByIdAndServer(long id, long serverId)
Gets the member with the given id in the server with the given id.- Parameters:
id
- The id of the member.serverId
- The server id.- Returns:
- The member.
-
-