Class CredentialStore.ReadResult

java.lang.Object
com.ultikits.ultitools.utils.CredentialStore.ReadResult
Enclosing class:
CredentialStore

public static final class CredentialStore.ReadResult extends Object
The outcome of a CredentialStore.read() call. Deliberately has no isEmpty()-style method that a caller could use to conflate isAbsent() with isParseFailure() -- the two are structurally distinct outcomes and must be checked separately.
  • Field Details

  • Constructor Details

  • Method Details

    • absent

      private static CredentialStore.ReadResult absent()
    • parsed

      private static CredentialStore.ReadResult parsed(Map<String,Object> data)
    • parseFailure

      private static CredentialStore.ReadResult parseFailure(String failureMessage)
    • failureMessage

      String failureMessage()
      The operator-facing description of a parse failure -- which file, that it was left untouched, and what to check -- for a caller that turns it into its own failure.
      Returns:
      the description, or null unless isParseFailure()
    • isAbsent

      public boolean isAbsent()
      Returns:
      true if data.json did not exist at read time
    • isParsed

      public boolean isParsed()
      Returns:
      true if data.json existed and parsed successfully
    • isParseFailure

      public boolean isParseFailure()
      Returns:
      true if the credential file existed but is empty, whitespace-only, the JSON literal null or not valid JSON -- a torn file, distinguishable from isAbsent() (#573) -- or if only an unreadable pre-6.3.0 file exists
    • data

      public Map<String,Object> data()
      The parsed content. An absent file yields an empty map, by definition.
      Returns:
      the parsed document
      Throws:
      IllegalStateException - if this result isParseFailure() -- there is no empty-map fallback for a torn file; the caller must check the outcome first