Record Class LoginResult

java.lang.Object
java.lang.Record
lol.trq.alts.auth.LoginResult
Record Components:
account - the signed-in account, or null when the sign-in failed
failure - why the sign-in failed, or empty when it succeeded

public record LoginResult(AltAccount account, Optional<AltsFailure> failure) extends Record
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.LoginResult in 1.0.0
  • Constructor Details

  • Method Details

    • success

      public static LoginResult success(AltAccount account)
      Creates a successful result.
      Parameters:
      account - the account that was signed in
      Returns:
      the result
      Since:
      0.2.0
    • failure

      public static LoginResult failure(AltsFailure failure)
      Creates a failed result.
      Parameters:
      failure - why the sign-in failed
      Returns:
      the result
      Since:
      1.0.0
    • failure

      public static LoginResult failure(AltsFailure.Kind kind, String message)
      Creates a failed result with a fresh failure of kind.
      Parameters:
      kind - what kind of failure it is
      message - 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

      public String 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

      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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • account

      public AltAccount account()
      Returns the value of the account record component.
      Returns:
      the value of the account record component
    • failure

      public Optional<AltsFailure> failure()
      Returns the value of the failure record component.
      Returns:
      the value of the failure record component