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.Nameable, Comparable<Permission>

public record Permission(@NonNull String name, int potency, long timeOutMillis) extends Record implements eu.cloudnetservice.common.Nameable, Comparable<Permission>
This permission record represents a permission for a permission group or user.
Since:
4.0
See Also:
  • Field Details

    • name

      @NonNull private final @NonNull String name
      The field for the name record component.
    • potency

      private final int potency
      The field for the potency record component.
    • timeOutMillis

      private final long timeOutMillis
      The field for the timeOutMillis record component.
  • Constructor Details

    • Permission

      public Permission(@NonNull @NonNull String name, int potency, long timeOutMillis)
      Creates an instance of a Permission record class.
      Parameters:
      name - the value for the name record component
      potency - the value for the potency record component
      timeOutMillis - the value for the timeOutMillis record component
  • Method Details

    • of

      @NonNull public static @NonNull Permission of(@NonNull @NonNull String permission)
      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

      @NonNull public static @NonNull Permission.Builder builder()
      Creates a new permission builder instance.
      Returns:
      the new builder instance.
    • builder

      @NonNull public static @NonNull Permission.Builder builder(@NonNull @NonNull Permission permission)
      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

      public int compareTo(@NonNull @NonNull Permission other)
      Compares the absolute potency of this permission with the absolute potency of the given permission.
      Specified by:
      compareTo in interface Comparable<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

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      @NonNull public @NonNull String name()
      Returns the value of the name record component.
      Specified by:
      name in interface eu.cloudnetservice.common.Nameable
      Returns:
      the value of the name record component
    • potency

      public int potency()
      Returns the value of the potency record component.
      Returns:
      the value of the potency record component
    • timeOutMillis

      public long timeOutMillis()
      Returns the value of the timeOutMillis record component.
      Returns:
      the value of the timeOutMillis record component