Record Class EmailVerificationTokenRecord
java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.accountlifecycle.EmailVerificationTokenRecord
- Record Components:
tokenHash- non-blank token hashtenant- tenant scope;nullbecomesTenantId.DEFAULTsubjectId- subject whose email the token verifiesemail- non-blank email address being verifiedcreatedAt- when the token was issuedexpiresAt- absolute expiry, strictly aftercreatedAtconsumedAt- instant the token was consumed, or empty when still pending; if present must be strictly aftercreatedAt
@ExperimentalJSentinelApi
public record EmailVerificationTokenRecord(String tokenHash, TenantId tenant, SubjectId subjectId, String email, Instant createdAt, Instant expiresAt, Optional<Instant> consumedAt)
extends Record
Persistent representation of a single email-verification token.
Carries the email address the token confirms — different from a
password-reset record, where the address is implicit in the
subject. Single-use, hash-only, identical lifecycle shape to
PasswordResetTokenRecord.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theconsumedAtrecord component.Returns the value of thecreatedAtrecord component.email()Returns the value of theemailrecord 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.booleanReturns whether the token has been consumed.booleanReturnstruewhen the token is past its expiry at the supplied instant.Returns the value of thesubjectIdrecord component.tenant()Returns the value of thetenantrecord component.Returns the value of thetokenHashrecord component.final StringtoString()Returns a string representation of this record class.Returns a copy withconsumedAt()set toat.
-
Constructor Details
-
EmailVerificationTokenRecord
public EmailVerificationTokenRecord(String tokenHash, TenantId tenant, SubjectId subjectId, String email, Instant createdAt, Instant expiresAt, Optional<Instant> consumedAt) Validates the record components and normalisesnulltenant / consumedAt.- Parameters:
tokenHash- non-blank token hashtenant-nullbecomes DEFAULTsubjectId- non-null subjectemail- non-blank emailcreatedAt- non-null creation instantexpiresAt- non-null expiry, strictly after createdAtconsumedAt- null becomes empty Optional
-
-
Method Details
-
withConsumedAt
Returns a copy withconsumedAt()set toat.- Parameters:
at- instant the token was consumed; non-null- Returns:
- new record with
consumedAt = Optional.of(at)
-
isConsumed
public boolean isConsumed()Returns whether the token has been consumed.- Returns:
truewhen consumedAt is present
-
isExpired
Returnstruewhen the token is past its expiry at the supplied instant.- Parameters:
now- reference instant; non-null- Returns:
- whether the token is expired
-
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). -
tokenHash
-
tenant
-
subjectId
-
email
-
createdAt
-
expiresAt
-
consumedAt
Returns the value of theconsumedAtrecord component.- Returns:
- the value of the
consumedAtrecord component
-