Record Class Permission
java.lang.Object
java.lang.Record
eu.cloudnetservice.driver.permission.Permission
- Record Components:
name- the permission to represent with this record.potency- the potency of this permission. The potency determines if a permission is added or subtracted from other permissions with the same name. If the resulting potency is negative the permission is not granted.timeOutMillis- the milliseconds to the absolute time at which this permission should expire. A timeout lower than 1 indicates a permission to be permanent.
- All Implemented Interfaces:
eu.cloudnetservice.common.Named,Comparable<Permission>
public record Permission(@NonNull String name, int potency, long timeOutMillis)
extends Record
implements eu.cloudnetservice.common.Named, Comparable<Permission>
This permission record represents a permission for a permission group or user.
- Since:
- 4.0
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionThe field for thenamerecord component.private final intThe field for thepotencyrecord component.private final longThe field for thetimeOutMillisrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionPermission(@NonNull String name, int potency, long timeOutMillis) Creates an instance of aPermissionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull Permission.Builderbuilder()Creates a new permission builder instance.static @NonNull Permission.Builderbuilder(@NonNull Permission permission) Creates a new permission builder instance and copies all values of the given permission into the new builder.intcompareTo(@NonNull Permission other) Compares the absolute potency of this permission with the absolute potency of the given permission.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.name()Returns the value of thenamerecord component.static @NonNull PermissionCreates a new permission with the given name.intpotency()Returns the value of thepotencyrecord component.longReturns the value of thetimeOutMillisrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
name
The field for thenamerecord component. -
potency
private final int potencyThe field for thepotencyrecord component. -
timeOutMillis
private final long timeOutMillisThe field for thetimeOutMillisrecord component.
-
-
Constructor Details
-
Permission
Creates an instance of aPermissionrecord class.- Parameters:
name- the value for thenamerecord componentpotency- the value for thepotencyrecord componenttimeOutMillis- the value for thetimeOutMillisrecord component
-
-
Method Details
-
of
Creates a new permission with the given name. The potency and timeOutMillis default to 0.- Parameters:
permission- the permission to create- Returns:
- the new permission.
- Throws:
NullPointerException- if the given permission is null.
-
builder
Creates a new permission builder instance.- Returns:
- the new builder instance.
-
builder
Creates a new permission builder instance and copies all values of the given permission into the new builder.- Parameters:
permission- the permission to copy from.- Returns:
- the new builder instance with values of the given permission.
- Throws:
NullPointerException- if the given permission is null.
-
compareTo
Compares the absolute potency of this permission with the absolute potency of the given permission.- Specified by:
compareToin interfaceComparable<Permission>- Parameters:
other- the permission to compare this one to.- Returns:
Integer.compare(int, int)with both potencies.- Throws:
NullPointerException- if the given permission is null.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
name
Returns the value of thenamerecord component.- Specified by:
namein interfaceeu.cloudnetservice.common.Named- Returns:
- the value of the
namerecord component
-
potency
public int potency()Returns the value of thepotencyrecord component.- Returns:
- the value of the
potencyrecord component
-
timeOutMillis
public long timeOutMillis()Returns the value of thetimeOutMillisrecord component.- Returns:
- the value of the
timeOutMillisrecord component
-