Class BulkEntryResult

java.lang.Object
lol.trq.alts.bulk.BulkEntryResult

public final class BulkEntryResult extends Object
What became of one entry in a bulk run.

The label is the resolved username, or a positional "entry 12" before one is known. It is deliberately never the input line: for an import that line is a credential, and results are exactly what a host renders into a list and writes to a log.

A result is exactly one of a success with an account or a failure without one. A final class rather than a record since 1.0.0, so a later field is an addition and not a break: the library builds results with success(int, AltAccount, String, int) and failure, and a host's test can too. Two results are equal when every field is.

Since:
0.9.0
  • Method Details

    • success

      public static BulkEntryResult success(int index, AltAccount account, String message, int attempts)
      Creates a successful result.
      Parameters:
      index - the entry's position
      account - the account it produced
      message - a short description
      attempts - how many times it was tried
      Returns:
      a successful result labelled with the account's username
      Throws:
      NullPointerException - if account is null
      Since:
      0.9.0
    • success

      public static BulkEntryResult success(int index, AltAccount account, Entitlements entitlements, String message, int attempts)
      Creates a successful entitlement-sweep result.
      Parameters:
      index - the entry's position
      account - the account that was read
      entitlements - what it owns
      message - a short description
      attempts - how many times it was tried
      Returns:
      a successful result carrying the entitlements
      Throws:
      NullPointerException - if account is null
      Since:
      0.12.0
    • failure

      public static BulkEntryResult failure(int index, String label, AltsFailure failure, int attempts)
      Creates a failed result, whose message is the failure's.
      Parameters:
      index - the entry's position
      label - a name safe to display, never the input line
      failure - why the entry failed
      attempts - how many times it was tried
      Returns:
      a failed result
      Throws:
      NullPointerException - if failure is null
      Since:
      1.0.0
    • positionalLabel

      public static String positionalLabel(int index)
      Returns the label an entry carries before it has resolved a name.
      Parameters:
      index - the entry's position
      Returns:
      a positional label
      Since:
      0.9.0
    • index

      public int index()
      Returns the entry's position in the list it was given, counting from 0.
      Returns:
      the index
      Since:
      0.9.0
    • label

      public String label()
      Returns a name safe to display and log: the resolved username, or a positional label.
      Returns:
      the label
      Since:
      0.9.0
    • account

      public AltAccount account()
      Returns the resolved or refreshed account.
      Returns:
      the account, or null when the entry failed
      Since:
      0.9.0
    • failure

      public Optional<AltsFailure> failure()
      Returns why the entry failed; carried since 1.0.0 in place of the former success flag and reason.
      Returns:
      the failure, or empty when the entry succeeded
      Since:
      1.0.0
    • message

      public String message()
      Returns a short human-readable description; on a failure, the failure's message.
      Returns:
      the message
      Since:
      0.9.0
    • attempts

      public int attempts()
      Returns how many times this entry was tried, counting the first.
      Returns:
      the attempt count
      Since:
      0.9.0
    • entitlements

      public Entitlements entitlements()
      Returns what the account owns, on a successful entry of an entitlement sweep.
      Returns:
      the entitlements, or null for every other kind of run and for a failed entry
      Since:
      0.12.0
    • success

      public boolean success()
      Returns whether the entry succeeded.
      Returns:
      true when there is no failure
      Since:
      0.9.0
    • equals

      public boolean equals(Object o)
      Returns whether o is a result with every field equal to this one's.
      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare
      Returns:
      true when every field is equal
      Since:
      0.9.0
    • hashCode

      public int hashCode()
      Returns a hash over every field, consistent with equals(Object).
      Overrides:
      hashCode in class Object
      Returns:
      the hash
      Since:
      0.9.0
    • toString

      public String toString()
      Returns every field, in the form the record printed them; the account describes itself with its credentials redacted.
      Overrides:
      toString in class Object
      Returns:
      a description
      Since:
      0.9.0