Record Class AccountStatus
java.lang.Object
java.lang.Record
lol.trq.alts.auth.AccountStatus
- Record Components:
account- the account this describes, possibly with freshly issued credentialsstate- the machine-readable outcomefailure- why the account is not usable, or empty when it is; carried since 1.0.0 in place of the former reason, message and wait
public record AccountStatus(AltAccount account, AccountStatus.State state, Optional<AltsFailure> failure)
extends Record
What an account is worth right now, without having logged into it.
The account carried back is the record as it now stands — renewed credentials included — so
a caller updates its own view from one place rather than reassembling it.
state() says what the account is; failure() says why it is not usable, in the
library's one failure model. A rate limit, for one, is the state AccountStatus.State.UNREACHABLE with a
failure of kind AltsFailure.Kind.RATE_LIMITED, whose AltsFailure.retryAfter() carries
the wait when the service stated one.
- Since:
- 0.8.0
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionAccountStatus(AltAccount account, AccountStatus.State state, Optional<AltsFailure> failure) Checks that a usable state carries no failure and every other state carries 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 AccountStatusfailure(AltAccount account, AccountStatus.State state, AltsFailure failure) Creates a status for an account that cannot be used as it stands.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 when the account is usable.static AccountStatusrenewed(AltAccount account) Creates a status for an account that was renewed.state()Returns the value of thestaterecord component.final StringtoString()Returns a string representation of this record class.booleanusable()Returns whether the account can be logged into as it stands.static AccountStatusvalid(AltAccount account) Creates a status for an account whose stored credentials work.
-
Constructor Details
-
AccountStatus
Checks that a usable state carries no failure and every other state carries one.- Throws:
NullPointerException- ifstateorfailureis nullIllegalArgumentException- if the failure does not match the state- Since:
- 1.0.0
-
-
Method Details
-
usable
public boolean usable()Returns whether the account can be logged into as it stands.- Returns:
- true if the state is
AccountStatus.State.VALIDorAccountStatus.State.RENEWED - Since:
- 0.8.0
-
message
Returns a short description to show: the failure's message, or a fixed phrase when the account is usable. Never branch on it.- Returns:
- the description
- Since:
- 0.8.0
-
valid
Creates a status for an account whose stored credentials work.- Parameters:
account- the account- Returns:
- a valid status
- Since:
- 0.8.0
-
renewed
Creates a status for an account that was renewed.- Parameters:
account- the account carrying the freshly issued credentials- Returns:
- a renewed status
- Since:
- 0.8.0
-
failure
public static AccountStatus failure(AltAccount account, AccountStatus.State state, AltsFailure failure) Creates a status for an account that cannot be used as it stands.- Parameters:
account- the account this describesstate- the outcome; notAccountStatus.State.VALIDorAccountStatus.State.RENEWEDfailure- why the account is not usable- Returns:
- a failed status
- Since:
- 1.0.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
-
state
-
failure
-