Interface Node
- All Known Subinterfaces:
ChatMetaNode<N,,B> DisplayNameNode,InheritanceNode,MetaNode,PermissionNode,PrefixNode,RegexPermissionNode,ScopedNode<N,,B> SuffixNode,WeightNode
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 4 key attributes:
key- the key of the nodevalue- the value of the node (false for negated)context- the contexts required for this node to applyexpiry- the time when this node should expire
These are the key attributes which are considered when evaluating node
equality.
Nodes can also optionally have metadata attached to them,
added during construction using NodeBuilder.withMetadata(NodeMetadataKey, Object), and
queried using metadata(NodeMetadataKey) and getMetadata(NodeMetadataKey).
Such metadata is never considered when evaluating equals(Object) or
equals(Node, NodeEqualityPredicate) (any form of equality check).
There are a number of node types, all of which extend from this class:
PermissionNode- represents an assigned permissionRegexPermissionNode- represents an assigned regex permissionInheritanceNode- an "inheritance node" marks that the holder should inherit data from another groupPrefixNode- represents an assigned prefixSuffixNode- represents an assigned suffixMetaNode- represents an assigned meta optionWeightNode- marks the weight of the object holding this nodeDisplayNameNode- marks the display name of the object holding this node
The core node state must be immutable in all implementations.
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull NodeBuilder<?, ?> Gets aNodeBuilderfor the given nodekey.booleanGets if this Node is equal to another node.booleanequals(@NonNull Node other, @NonNull NodeEqualityPredicate equalityPredicate) Gets if this Node is equal to another node as defined by the givenNodeEqualityPredicate.Gets the contexts required for this node to apply.Gets the time when this node will expire.Gets the time until this node will expire.getKey()Gets the key (String) of the node.<T> Optional<T> getMetadata(@NonNull NodeMetadataKey<T> key) Gets the metadata corresponding to the givenkey, if present.getType()Gets the type of the node.booleangetValue()Gets the value of the node.booleanGets if the node has expired.booleanGets if this node is assigned temporarily.default booleanGets if the node is negated.default <T> Tmetadata(@NonNull NodeMetadataKey<T> key) Gets the metadata corresponding to the givenkey, throwing an exception if no data is present.Resolves any shorthand parts of this node and returns the full list of resolved nodes.@NonNull NodeBuilder<?, ?> Gets aNodeBuilder, with the attributes of this node already applied.
-
Method Details
-
builder
Gets aNodeBuilderfor the given nodekey.- Parameters:
key- the key- Returns:
- the node builder
-
getType
-
getKey
-
getValue
boolean getValue()Gets the value of the node.A negated setting would result in a value of
false.- Returns:
- the nodes value
-
isNegated
default boolean isNegated()Gets if the node is negated.This is the inverse of the
value.- Returns:
- true if the node is negated
-
resolveShorthand
@NonNull @Unmodifiable Collection<String> resolveShorthand()Resolves any shorthand parts of this node and returns the full list of resolved nodes.The list will not contain the exact permission itself.
- Returns:
- a list of full nodes
-
hasExpiry
boolean hasExpiry()Gets if this node is assigned temporarily.- Returns:
- true if this node will expire in the future
-
getExpiry
-
hasExpired
boolean hasExpired()Gets if the node has expired.This returns false if the node is not temporary.
- Returns:
- true if this node has expired
-
getExpiryDuration
-
getContexts
@NonNull ImmutableContextSet getContexts()Gets the contexts required for this node to apply.- Returns:
- the contexts required for this node to apply
-
getMetadata
Gets the metadata corresponding to the givenkey, if present.- Type Parameters:
T- the metadata type- Parameters:
key- the key- Returns:
- the data, if present
-
metadata
Gets the metadata corresponding to the givenkey, throwing an exception if no data is present.- Type Parameters:
T- the metadata type- Parameters:
key- the key- Returns:
- the data
- Throws:
IllegalStateException- if data isn't present
-
equals
-
equals
Gets if this Node is equal to another node as defined by the givenNodeEqualityPredicate.- Parameters:
other- the other nodeequalityPredicate- the predicate- Returns:
- true if this node is considered equal
-
toBuilder
@NonNull NodeBuilder<?,?> toBuilder()Gets aNodeBuilder, with the attributes of this node already applied.- Returns:
- an editable, builder form of this node
-