Record Class UserPermission

java.lang.Object
java.lang.Record
de.murmelmeister.murmelapi.user.permission.UserPermission
Record Components:
userId - ID of the user to whom the permission is assigned
permission - The permission assigned to the user
expiresAt - Nullable expiration date and time of the permission
createdBy - ID of the user who created this permission
createdAt - Date and time when the permission was created
changedBy - Nullable ID of the user who last changed this permission
changedAt - Nullable date and time when the permission was last changed

public record UserPermission(int userId, String permission, LocalDateTime expiresAt, int createdBy, LocalDateTime createdAt, Integer changedBy, LocalDateTime changedAt) extends Record
Represents a permission assigned to a user, including expiration details. This record is immutable and provides methods to check if the permission has expired and to create a new instance with updated metadata.
  • Field Details

    • userId

      private final int userId
      The field for the userId record component.
    • permission

      private final String permission
      The field for the permission record component.
    • expiresAt

      private final LocalDateTime expiresAt
      The field for the expiresAt record component.
    • createdBy

      private final int createdBy
      The field for the createdBy record component.
    • createdAt

      private final LocalDateTime createdAt
      The field for the createdAt record component.
    • changedBy

      private final Integer changedBy
      The field for the changedBy record component.
    • changedAt

      private final LocalDateTime changedAt
      The field for the changedAt record component.
  • Constructor Details

    • UserPermission

      public UserPermission(int userId, String permission, LocalDateTime expiresAt, int createdBy, LocalDateTime createdAt, Integer changedBy, LocalDateTime changedAt)
      Creates an instance of a UserPermission record class.
      Parameters:
      userId - the value for the userId record component
      permission - the value for the permission record component
      expiresAt - the value for the expiresAt record component
      createdBy - the value for the createdBy record component
      createdAt - the value for the createdAt record component
      changedBy - the value for the changedBy record component
      changedAt - the value for the changedAt record component
  • Method Details

    • isExpired

      public boolean isExpired()
    • isPermanent

      public boolean isPermanent()
    • withUpdateMeta

      public UserPermission withUpdateMeta(LocalDateTime expiresAt, Integer changedBy, LocalDateTime changedAt)
    • 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.
    • userId

      public int userId()
      Returns the value of the userId record component.
      Returns:
      the value of the userId record component
    • permission

      public String permission()
      Returns the value of the permission record component.
      Returns:
      the value of the permission record component
    • expiresAt

      public LocalDateTime expiresAt()
      Returns the value of the expiresAt record component.
      Returns:
      the value of the expiresAt record component
    • createdBy

      public int createdBy()
      Returns the value of the createdBy record component.
      Returns:
      the value of the createdBy record component
    • createdAt

      public LocalDateTime createdAt()
      Returns the value of the createdAt record component.
      Returns:
      the value of the createdAt record component
    • changedBy

      public Integer changedBy()
      Returns the value of the changedBy record component.
      Returns:
      the value of the changedBy record component
    • changedAt

      public LocalDateTime changedAt()
      Returns the value of the changedAt record component.
      Returns:
      the value of the changedAt record component