Record Class NameEligibility

java.lang.Object
java.lang.Record
lol.trq.alts.account.NameEligibility
Record Components:
nameChangeAllowed - whether a name change is permitted now
createdAt - when the account was created, or null when the endpoint did not say
changedAt - when the name was last changed, or null when it never was or the endpoint did not say; added in 0.12.0

public record NameEligibility(boolean nameChangeAllowed, Instant createdAt, Instant changedAt) extends Record
Whether an account may change its name right now, from GET /minecraft/profile/namechange.

Mojang enforces a cooldown between name changes; nameChangeAllowed is whether the account is past it. createdAt is when the account was made, which a host turns into account age, and changedAt is when the name last changed — the anchor for the cooldown a caller may want to display.

Since:
0.11.0
  • Field Details

    • NAME_CHANGE_COOLDOWN

      public static final Duration NAME_CHANGE_COOLDOWN
      The documented wait between two name changes.
      Since:
      0.12.0
  • Constructor Details

    • NameEligibility

      public NameEligibility(boolean nameChangeAllowed, Instant createdAt)
      Creates an eligibility with no known last-change time — the shape this record had before changedAt was added.
      Parameters:
      nameChangeAllowed - whether a name change is permitted now
      createdAt - when the account was created, or null
      Since:
      0.11.0
    • NameEligibility

      public NameEligibility(boolean nameChangeAllowed, Instant createdAt, Instant changedAt)
      Creates an instance of a NameEligibility record class.
      Parameters:
      nameChangeAllowed - the value for the nameChangeAllowed record component
      createdAt - the value for the createdAt record component
      changedAt - the value for the changedAt record component
  • Method Details

    • ageAt

      public Duration ageAt(Instant now)
      Returns how long ago the account was created, or null when the creation time is unknown.
      Parameters:
      now - the current instant to measure against
      Returns:
      the account's age, or null
      Since:
      0.11.0
    • estimatedNextChange

      public Instant estimatedNextChange()
      Estimates the earliest instant the name can next be changed: the last change plus the documented NAME_CHANGE_COOLDOWN.

      An estimate, not the service's answer. The endpoint returns no such date; this is arithmetic over the one it does return and a cooldown length taken from documentation, which the service is free to change or to apply differently to a given account. Use it to show a user roughly when to come back. nameChangeAllowed() is the authority on whether a change is permitted now, and where the two disagree the flag is right.

      Returns:
      the estimated instant, or null when the last-change time is unknown — including for a name that has never been changed
      Since:
      0.12.0
    • estimatedWaitAt

      public Duration estimatedWaitAt(Instant now)
      Estimates how long remains until the name can next be changed, by the same arithmetic and with the same caveats as estimatedNextChange().
      Parameters:
      now - the current instant to measure against
      Returns:
      the estimated wait; zero when a change is already allowed or the estimate has passed, and null when a change is not allowed and there is nothing to estimate from
      Since:
      0.12.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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      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.
    • nameChangeAllowed

      @SerializedName("nameChangeAllowed") public boolean nameChangeAllowed()
      Returns the value of the nameChangeAllowed record component.
      Returns:
      the value of the nameChangeAllowed record component
    • createdAt

      @SerializedName("createdAt") public Instant createdAt()
      Returns the value of the createdAt record component.
      Returns:
      the value of the createdAt record component
    • changedAt

      @SerializedName("changedAt") public Instant changedAt()
      Returns the value of the changedAt record component.
      Returns:
      the value of the changedAt record component