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 assignedpermission- The permission assigned to the userexpiresAt- Nullable expiration date and time of the permissioncreatedBy- ID of the user who created this permissioncreatedAt- Date and time when the permission was createdchangedBy- Nullable ID of the user who last changed this permissionchangedAt- 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 Summary
FieldsModifier and TypeFieldDescriptionprivate final LocalDateTimeThe field for thechangedAtrecord component.private final IntegerThe field for thechangedByrecord component.private final LocalDateTimeThe field for thecreatedAtrecord component.private final intThe field for thecreatedByrecord component.private final LocalDateTimeThe field for theexpiresAtrecord component.private final StringThe field for thepermissionrecord component.private final intThe field for theuserIdrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionUserPermission(int userId, String permission, LocalDateTime expiresAt, int createdBy, LocalDateTime createdAt, Integer changedBy, LocalDateTime changedAt) Creates an instance of aUserPermissionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thechangedAtrecord component.Returns the value of thechangedByrecord component.Returns the value of thecreatedAtrecord component.intReturns the value of thecreatedByrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theexpiresAtrecord component.final inthashCode()Returns a hash code value for this object.booleanbooleanReturns the value of thepermissionrecord component.final StringtoString()Returns a string representation of this record class.intuserId()Returns the value of theuserIdrecord component.withUpdateMeta(LocalDateTime expiresAt, Integer changedBy, LocalDateTime changedAt)
-
Field Details
-
userId
private final int userIdThe field for theuserIdrecord component. -
permission
The field for thepermissionrecord component. -
expiresAt
The field for theexpiresAtrecord component. -
createdBy
private final int createdByThe field for thecreatedByrecord component. -
createdAt
The field for thecreatedAtrecord component. -
changedBy
The field for thechangedByrecord component. -
changedAt
The field for thechangedAtrecord component.
-
-
Constructor Details
-
UserPermission
public UserPermission(int userId, String permission, LocalDateTime expiresAt, int createdBy, LocalDateTime createdAt, Integer changedBy, LocalDateTime changedAt) Creates an instance of aUserPermissionrecord class.- Parameters:
userId- the value for theuserIdrecord componentpermission- the value for thepermissionrecord componentexpiresAt- the value for theexpiresAtrecord componentcreatedBy- the value for thecreatedByrecord componentcreatedAt- the value for thecreatedAtrecord componentchangedBy- the value for thechangedByrecord componentchangedAt- the value for thechangedAtrecord component
-
-
Method Details
-
isExpired
public boolean isExpired() -
isPermanent
public boolean isPermanent() -
withUpdateMeta
public UserPermission withUpdateMeta(LocalDateTime expiresAt, Integer changedBy, LocalDateTime changedAt) -
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 '=='. -
userId
public int userId()Returns the value of theuserIdrecord component.- Returns:
- the value of the
userIdrecord component
-
permission
Returns the value of thepermissionrecord component.- Returns:
- the value of the
permissionrecord component
-
expiresAt
Returns the value of theexpiresAtrecord component.- Returns:
- the value of the
expiresAtrecord component
-
createdBy
public int createdBy()Returns the value of thecreatedByrecord component.- Returns:
- the value of the
createdByrecord component
-
createdAt
Returns the value of thecreatedAtrecord component.- Returns:
- the value of the
createdAtrecord component
-
changedBy
Returns the value of thechangedByrecord component.- Returns:
- the value of the
changedByrecord component
-
changedAt
Returns the value of thechangedAtrecord component.- Returns:
- the value of the
changedAtrecord component
-