Record Class LoginResult
java.lang.Object
java.lang.Record
lol.trq.alts.auth.LoginResult
- Record Components:
account- the signed-in account, ornullwhen the sign-in failedfailure- why the sign-in failed, or empty when it succeeded
What a sign-in came to: the account it produced, or the failure that stopped it.
Every sign-in route returns one; none of them throws at the caller or completes its future
exceptionally. A host branches on failure().map(AltsFailure::kind); the message is for showing.
- Since:
- 0.2.0, moved from
AltLoginCallback.LoginResultin 1.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionLoginResult(AltAccount account, Optional<AltsFailure> failure) Checks that a result is exactly one of a success with an account or a failure without one. -
Method Summary
Modifier and TypeMethodDescriptionaccount()Returns the value of theaccountrecord component.final booleanIndicates whether some other object is "equal to" this one.failure()Returns the value of thefailurerecord component.static LoginResultfailure(AltsFailure failure) Creates a failed result.static LoginResultfailure(AltsFailure.Kind kind, String message) Creates a failed result with a fresh failure ofkind.final inthashCode()Returns a hash code value for this object.message()Returns a short description to show: the failure's message, or a fixed phrase on success.booleansuccess()Returns whether the sign-in succeeded.static LoginResultsuccess(AltAccount account) Creates a successful result.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
LoginResult
Checks that a result is exactly one of a success with an account or a failure without one.- Throws:
NullPointerException- iffailureis null, or a success carries no accountIllegalArgumentException- if a failure carries an account- Since:
- 1.0.0
-
-
Method Details
-
success
Creates a successful result.- Parameters:
account- the account that was signed in- Returns:
- the result
- Since:
- 0.2.0
-
failure
Creates a failed result.- Parameters:
failure- why the sign-in failed- Returns:
- the result
- Since:
- 1.0.0
-
failure
Creates a failed result with a fresh failure ofkind.- Parameters:
kind- what kind of failure it ismessage- a short description built by the library- Returns:
- the result
- Since:
- 1.0.0
-
success
public boolean success()Returns whether the sign-in succeeded.- Returns:
- true when there is no failure
- Since:
- 0.2.0
-
message
Returns a short description to show: the failure's message, or a fixed phrase on success. Never branch on it.- Returns:
- the description
- Since:
- 0.2.0
-
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). -
account
-
failure
-