Class RoleImpl
- java.lang.Object
-
- org.javacord.core.entity.permission.RoleImpl
-
- All Implemented Interfaces:
java.lang.Comparable<Role>
,java.util.Formattable
,Deletable
,DiscordEntity
,Mentionable
,Nameable
,Role
,Permissionable
,Updatable<Role>
,UpdatableFromCache<Role>
,RoleAttachableListenerManager
,InternalRoleAttachableListenerManager
public class RoleImpl extends java.lang.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 int
compareTo(Role role)
java.util.concurrent.CompletableFuture<java.lang.Void>
delete(java.lang.String reason)
boolean
equals(java.lang.Object o)
DiscordApi
getApi()
Gets the discord api instance.java.util.Optional<java.awt.Color>
getColor()
int
getColorAsInt()
Gets the color of the role asint
.java.util.Optional<Icon>
getIcon()
java.util.Optional<Icon>
getIcon(int size)
java.util.Optional<java.lang.String>
getIconHash()
long
getId()
Gets the id of this object.java.lang.String
getName()
Permissions
getPermissions()
int
getRawPosition()
java.util.Optional<RoleTags>
getRoleTags()
Server
getServer()
java.util.Optional<java.lang.String>
getUnicodeEmojiIcon()
java.util.Set<User>
getUsers()
int
hashCode()
boolean
hasUser(User user)
boolean
isDisplayedSeparately()
boolean
isManaged()
boolean
isMentionable()
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(java.lang.String name)
Sets the name of the role.void
setPermissions(PermissionsImpl permissions)
Sets the permissions of the role.void
setRawPosition(int position)
Sets the raw position of the role.java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.javacord.api.entity.Deletable
delete, deleteAfter, deleteAfter, deleteAfter, deleteAfter
-
Methods inherited from interface org.javacord.api.entity.DiscordEntity
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 interface org.javacord.api.entity.permission.Role
addUser, addUser, createUpdater, getAllowedPermissions, getCurrentCachedInstance, getMentionTag, getPosition, 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
-
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(java.lang.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.
-
setRawPosition
public void setRawPosition(int position)
Sets the raw position of the role.- Parameters:
position
- The raw position to set.
-
getApi
public DiscordApi getApi()
Description copied from interface:InternalRoleAttachableListenerManager
Gets the discord api instance.- Specified by:
getApi
in interfaceDeletable
- 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.
-
getRoleTags
public java.util.Optional<RoleTags> getRoleTags()
- Specified by:
getRoleTags
in interfaceRole
-
getRawPosition
public int getRawPosition()
- Specified by:
getRawPosition
in interfaceRole
-
getIconHash
public java.util.Optional<java.lang.String> getIconHash()
- Specified by:
getIconHash
in interfaceRole
-
getUnicodeEmojiIcon
public java.util.Optional<java.lang.String> getUnicodeEmojiIcon()
- Specified by:
getUnicodeEmojiIcon
in interfaceRole
-
getColor
public java.util.Optional<java.awt.Color> getColor()
-
isMentionable
public boolean isMentionable()
- Specified by:
isMentionable
in interfaceRole
-
isDisplayedSeparately
public boolean isDisplayedSeparately()
- Specified by:
isDisplayedSeparately
in interfaceRole
-
getPermissions
public Permissions getPermissions()
- Specified by:
getPermissions
in interfaceRole
-
delete
public java.util.concurrent.CompletableFuture<java.lang.Void> delete(java.lang.String reason)
-
compareTo
public int compareTo(Role role)
Implementation note: Only roles from the same server can be compared
- Specified by:
compareTo
in interfacejava.lang.Comparable<Role>
- Throws:
java.lang.IllegalArgumentException
- If the roles are on different servers.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-