Record Class PermissionNode
java.lang.Object
java.lang.Record
fr.fidorial.permission.PermissionNode
- All Implemented Interfaces:
Comparable<PermissionNode>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PermissionNodeThe node matching every permission.static final StringWildcard segment. -
Constructor Summary
ConstructorsConstructorDescriptionPermissionNode(String path) Creates an instance of aPermissionNoderecord class. -
Method Summary
Modifier and TypeMethodDescriptionAppends a child segment.intcompareTo(PermissionNode other) booleancovers(PermissionNode other) Tests whether this node coversother, taking wildcards into account.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanBuilds the lookup chain for this node, ordered from most specific to least specific.static PermissionNodeCreates a node from its textual path.path()Returns the value of thepathrecord component.segments()toString()Returns a string representation of this record class.
-
Field Details
-
ROOT
The node matching every permission. -
WILDCARD
-
-
Constructor Details
-
PermissionNode
Creates an instance of aPermissionNoderecord class.- Parameters:
path- the value for thepathrecord component
-
-
Method Details
-
of
Creates a node from its textual path.- Parameters:
path- dot-separated path- Returns:
- the node
- Throws:
IllegalArgumentException- if the path is malformed
-
segments
-
isWildcard
public boolean isWildcard()- Returns:
truewhen the last segment is a wildcard
-
lookupChain
Builds the lookup chain for this node, ordered from most specific to least specific.a.b.cyieldsa.b.c,a.b.*,a.*and finally*. The resolver walks this list and stops on the first decided state, which is what gives more specific rules priority over broader ones.- Returns:
- the ordered lookup chain, always at least one element long
-
covers
Tests whether this node coversother, taking wildcards into account.- Parameters:
other- node being tested- Returns:
trueif a rule on this node applies toother
-
child
Appends a child segment.- Parameters:
segment- segment to append- Returns:
- the child node
-
compareTo
- Specified by:
compareToin interfaceComparable<PermissionNode>
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
path
Returns the value of thepathrecord component.- Returns:
- the value of the
pathrecord component
-