@Immutable public interface Node
The Node class encapsulates more than just permission assignments.
Nodes are used to store data about inherited groups, as well as assigned
prefixes, suffixes and meta values.
Combining these various states into one object (a "node") means that a holder only has to have one type of data set (a set of nodes) in order to take on various properties.
It is recommended that users of the API make use of Streams
to manipulate data and obtain the required information.
This interface provides a number of methods to read the attributes of the node, as well as methods to query and extract additional state and properties from these settings.
Nodes have the following attributes:
permission - the actual permission stringvalue - the value of the node (false for negated)override - if the node is marked as having special priority over other nodesserver - the specific server where this node should applyworld - the specific world where this node should applycontext - the additional contexts required for this node to apply expiry - the time when this node should expireNodes can also fall into the following sub categories.
group node - a "group node" marks that the holder should inherit data from another groupprefix - represents an assigned prefixsuffix - represents an assigned suffixmeta - represents an assigned meta optionThe core node state must be immutable in all implementations.
for obtaining and constructing instances.| Modifier and Type | Interface and Description |
|---|---|
static interface |
Node.Builder
Builds a Node instance
|
| Modifier and Type | Method and Description |
|---|---|
default boolean |
almostEquals(Node other)
Deprecated.
in favour of
equals(Node, NodeEqualityPredicate) |
boolean |
appliesGlobally()
Gets if this node applies globally, and therefore has no specific context
|
default boolean |
equals(Node other,
NodeEqualityPredicate equalityPredicate)
Returns if this Node is equal to another node as defined by the given
NodeEqualityPredicate. |
boolean |
equals(Object obj)
Returns if this Node is equal to another node
|
default boolean |
equalsIgnoringValue(Node other)
Deprecated.
in favour of
equals(Node, NodeEqualityPredicate) |
default boolean |
equalsIgnoringValueOrTemp(Node other)
Deprecated.
in favour of
equals(Node, NodeEqualityPredicate) |
ContextSet |
getContexts()
Gets the extra contexts required for this node to apply
|
Date |
getExpiry()
Gets the date when this node will expire
|
long |
getExpiryUnixTime()
Gets a unix timestamp in seconds when this node will expire
|
ContextSet |
getFullContexts()
The same as
getContexts(), but also includes values for "server" and "world" keys if present. |
String |
getGroupName()
Gets the name of the group, if this is a group node.
|
Map.Entry<String,String> |
getMeta()
Gets the meta value from this node
|
String |
getPermission()
Gets the permission string
|
Map.Entry<Integer,String> |
getPrefix()
Gets the prefix value from this node
|
long |
getSecondsTilExpiry()
Gets the number of seconds until this permission will expire
|
Optional<String> |
getServer()
Gets the server this node applies on, if the node is server specific
|
Map.Entry<Integer,String> |
getSuffix()
Gets the suffix value from this node
|
default Tristate |
getTristate()
Gets the value of this node as a
Tristate |
default Boolean |
getValue()
Gets the value.
|
boolean |
getValuePrimitive()
Gets the value.
|
int |
getWildcardLevel()
Gets the level of this wildcard, higher is more specific
|
Optional<String> |
getWorld()
Gets the world this node applies on, if the node is world specific
|
boolean |
hasExpired()
Gets if the node has expired.
|
boolean |
hasSpecificContext()
Gets if this node has any specific context in order for it to apply
|
boolean |
isGroupNode()
Gets if this is a group node
|
boolean |
isMeta()
Gets if this node is a meta node
|
default boolean |
isNegated()
Gets if the node is negated
|
boolean |
isOverride()
Gets if this node is set to override explicitly.
|
default boolean |
isPermanent()
Gets if this node will not expire
|
boolean |
isPrefix()
Gets if this node is a prefix node
|
boolean |
isServerSpecific()
Gets if this node is server specific
|
boolean |
isSuffix()
Gets if this node is a suffix node
|
boolean |
isTemporary()
Gets if this node will expire in the future
|
boolean |
isWildcard()
Gets if this node is a wildcard node
|
boolean |
isWorldSpecific()
Gets if this node is server specific
|
List<String> |
resolveShorthand()
Resolves any shorthand parts of this node and returns the full list
|
boolean |
shouldApplyWithContext(ContextSet context)
Gets if this node should apply in the given context
|
boolean |
standardEquals(Node other,
StandardNodeEquality equalityPredicate)
Returns if this Node is equal to another node as defined by the given
StandardNodeEquality predicate. |
Node.Builder |
toBuilder()
Constructs a new builder initially containing the current properties of
this node.
|
@Nonnull String getPermission()
@Nonnull default Boolean getValue()
A negated node would return a value of false.
boolean getValuePrimitive()
A negated node would return a value of false.
@Nonnull default Tristate getTristate()
Tristatedefault boolean isNegated()
boolean isOverride()
This value does not persist across saves, and is therefore only useful for transient nodes
@Nonnull Optional<String> getServer()
Optional containing the server, if one is defined@Nonnull Optional<String> getWorld()
Optional containing the world, if one is definedboolean isServerSpecific()
boolean isWorldSpecific()
boolean appliesGlobally()
boolean hasSpecificContext()
boolean shouldApplyWithContext(@Nonnull ContextSet context)
context - the context key value pairs@Nonnull List<String> resolveShorthand()
boolean isTemporary()
default boolean isPermanent()
long getExpiryUnixTime()
throws IllegalStateException
IllegalStateException - if the node is not temporary@Nonnull Date getExpiry() throws IllegalStateException
Date when this node will expireIllegalStateException - if the node is not temporarylong getSecondsTilExpiry()
throws IllegalStateException
IllegalStateException - if the node is not temporaryboolean hasExpired()
This also returns false if the node is not temporary.
@Nonnull ContextSet getContexts()
@Nonnull ContextSet getFullContexts()
getContexts(), but also includes values for "server" and "world" keys if present.boolean isGroupNode()
@Nonnull String getGroupName() throws IllegalStateException
IllegalStateException - if this is not a group node. See isGroupNode()boolean isWildcard()
int getWildcardLevel()
throws IllegalStateException
IllegalStateException - if this is not a wildcardboolean isMeta()
@Nonnull Map.Entry<String,String> getMeta() throws IllegalStateException
IllegalStateException - if this node is not a meta nodeboolean isPrefix()
@Nonnull Map.Entry<Integer,String> getPrefix() throws IllegalStateException
IllegalStateException - if this node is a not a prefix nodeboolean isSuffix()
@Nonnull Map.Entry<Integer,String> getSuffix() throws IllegalStateException
IllegalStateException - if this node is a not a suffix nodeboolean equals(Object obj)
equals in class Objectobj - the other nodeStandardNodeEquality.EXACTboolean standardEquals(Node other, StandardNodeEquality equalityPredicate)
StandardNodeEquality predicate.other - the other nodeequalityPredicate - the predicatedefault boolean equals(Node other, NodeEqualityPredicate equalityPredicate)
NodeEqualityPredicate.other - the other nodeequalityPredicate - the predicate@Deprecated default boolean equalsIgnoringValue(@Nonnull Node other)
equals(Node, NodeEqualityPredicate)equals(Object), except doesn't take note of the
value.other - the other nodeStandardNodeEquality.IGNORE_VALUE@Deprecated default boolean almostEquals(@Nonnull Node other)
equals(Node, NodeEqualityPredicate)equals(Object), except doesn't take note of the
expiry time or value.other - the other nodeStandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE@Deprecated default boolean equalsIgnoringValueOrTemp(@Nonnull Node other)
equals(Node, NodeEqualityPredicate)equals(Object), except doesn't take note of the
value or if the node is temporary.other - the other nodeStandardNodeEquality.IGNORE_VALUE_OR_IF_TEMPORARYNode.Builder toBuilder()
Copyright © 2018. All rights reserved.