Class RoleImpl
- java.lang.Object
-
- org.javacord.core.entity.permission.RoleImpl
-
- All Implemented Interfaces:
Comparable<Role>
,Formattable
,DiscordEntity
,Mentionable
,Nameable
,Role
,Permissionable
,Updatable<Role>
,UpdatableFromCache<Role>
,RoleAttachableListenerManager
,InternalRoleAttachableListenerManager
public class RoleImpl extends Object implements Role, InternalRoleAttachableListenerManager
The implementation ofRole
.
-
-
Constructor Summary
Constructors Constructor Description RoleImpl(DiscordApiImpl api, ServerImpl server, com.fasterxml.jackson.databind.JsonNode data)
Creates a new role object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addUserToCache(User user)
Adds a user to the role.int
compareTo(Role role)
CompletableFuture<Void>
delete()
boolean
equals(Object o)
DiscordApi
getApi()
Gets the discord api instance.Optional<Color>
getColor()
int
getColorAsInt()
Gets the color of the role asint
.long
getId()
Gets the id of this object.String
getName()
Permissions
getPermissions()
int
getPosition()
Server
getServer()
Collection<User>
getUsers()
int
hashCode()
boolean
isDisplayedSeparately()
boolean
isManaged()
boolean
isMentionable()
void
removeUserFromCache(User user)
Removes a user from the role.void
setColor(int color)
Sets the color of the role.void
setHoist(boolean hoist)
Sets the hoist flag of the role.void
setMentionable(boolean mentionable)
Sets the mentionable flag of the role.void
setName(String name)
Sets the name of the role.void
setPermissions(PermissionsImpl permissions)
Sets the permissions of the role.void
setPosition(int position)
Sets the position of the role.String
toString()
-
Methods inherited from interface org.javacord.api.entity.DiscordEntity
getCreationTimestamp, getCreationTimestamp, getIdAsString
-
Methods inherited from interface org.javacord.core.listener.server.role.InternalRoleAttachableListenerManager
addRoleAttachableListener, addRoleChangeColorListener, addRoleChangeHoistListener, addRoleChangeMentionableListener, addRoleChangeNameListener, addRoleChangePermissionsListener, addRoleChangePositionListener, addRoleDeleteListener, addServerChannelChangeOverwrittenPermissionsListener, addUserRoleAddListener, addUserRoleRemoveListener, getRoleAttachableListeners, getRoleChangeColorListeners, getRoleChangeHoistListeners, getRoleChangeMentionableListeners, getRoleChangeNameListeners, getRoleChangePermissionsListeners, getRoleChangePositionListeners, getRoleDeleteListeners, getServerChannelChangeOverwrittenPermissionsListeners, getUserRoleAddListeners, getUserRoleRemoveListeners, removeListener, removeRoleAttachableListener
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.javacord.api.entity.permission.Role
addUser, addUser, createUpdater, getAllowedPermissions, getCurrentCachedInstance, getMentionTag, getUnsetPermissions, isEveryoneRole, removeUser, removeUser, updateColor, updateDisplaySeparatelyFlag, updateMentionableFlag, updateName, updatePermissions
-
Methods inherited from interface org.javacord.api.entity.UpdatableFromCache
getLatestInstance
-
-
-
-
Constructor Detail
-
RoleImpl
public RoleImpl(DiscordApiImpl api, ServerImpl server, com.fasterxml.jackson.databind.JsonNode data)
Creates a new role object.- Parameters:
api
- The discord api instance.server
- The server of the role.data
- The json data of the role.
-
-
Method Detail
-
addUserToCache
public void addUserToCache(User user)
Adds a user to the role.- Parameters:
user
- The user to add.
-
removeUserFromCache
public void removeUserFromCache(User user)
Removes a user from the role.- Parameters:
user
- The user to remove.
-
getColorAsInt
public int getColorAsInt()
Gets the color of the role asint
.- Returns:
- The color of the role as
int
.
-
setColor
public void setColor(int color)
Sets the color of the role.- Parameters:
color
- The color to set.
-
setHoist
public void setHoist(boolean hoist)
Sets the hoist flag of the role.- Parameters:
hoist
- The hoist flag to set.
-
setMentionable
public void setMentionable(boolean mentionable)
Sets the mentionable flag of the role.- Parameters:
mentionable
- The mentionable flag to set.
-
setName
public void setName(String name)
Sets the name of the role.- Parameters:
name
- The name to set.
-
setPermissions
public void setPermissions(PermissionsImpl permissions)
Sets the permissions of the role.- Parameters:
permissions
- The permissions to set.
-
setPosition
public void setPosition(int position)
Sets the position of the role.- Parameters:
position
- The position to set.
-
getApi
public DiscordApi getApi()
Description copied from interface:InternalRoleAttachableListenerManager
Gets the discord api instance.- Specified by:
getApi
in interfaceDiscordEntity
- Specified by:
getApi
in interfaceInternalRoleAttachableListenerManager
- Returns:
- The discord api instance.
-
getId
public long getId()
Description copied from interface:InternalRoleAttachableListenerManager
Gets the id of this object.- Specified by:
getId
in interfaceDiscordEntity
- Specified by:
getId
in interfaceInternalRoleAttachableListenerManager
- Returns:
- The id of this object.
-
getPosition
public int getPosition()
- Specified by:
getPosition
in interfaceRole
-
isMentionable
public boolean isMentionable()
- Specified by:
isMentionable
in interfaceRole
-
isDisplayedSeparately
public boolean isDisplayedSeparately()
- Specified by:
isDisplayedSeparately
in interfaceRole
-
getUsers
public Collection<User> getUsers()
-
getPermissions
public Permissions getPermissions()
- Specified by:
getPermissions
in interfaceRole
-
delete
public CompletableFuture<Void> delete()
-
compareTo
public int compareTo(Role role)
Implementation note: Only roles from the same server can be compared
- Specified by:
compareTo
in interfaceComparable<Role>
- Throws:
IllegalArgumentException
- If the roles are on different servers.
-
-