Class VersionLookup

java.lang.Object
com.ultikits.ultitools.utils.VersionLookup

@Internal public final class VersionLookup extends Object
The answer to one catalogue version lookup, as the start-up update check needs it: a version was found, the catalogue confirmed it has nothing to offer, or the lookup failed (the catalogue could not be reached, answered with an error status, or sent a body that could not be read).

The public lookups (VersionUtils.getUltiToolsNewestVersion(), PluginInstallUtils.getPluginLatestVersion(String)) fold the last two into null and keep doing so; this type exists so the update check can report "incomplete" instead of "up to date" when a lookup failed (Phase 19, D19-032).

Since:
6.3.0
  • Field Details

    • UNREADABLE

      static final String UNREADABLE
      The failure description for an answer whose status was fine but whose body could not be read.
      See Also:
    • TOO_LARGE

      static final String TOO_LARGE
      The failure description for an answer longer than the client reads; the contract allows none.
      See Also:
    • NOT_SENT_PREFIX

      private static final String NOT_SENT_PREFIX
      The prefix SimpleHttpClient puts on the body it makes up when the request itself failed.
      See Also:
    • NONE_OFFERED

      private static final VersionLookup NONE_OFFERED
    • outcome

      private final VersionLookup.Outcome outcome
    • version

      private final String version
    • failure

      private final String failure
  • Constructor Details

  • Method Details

    • found

      public static VersionLookup found(String version)
      Parameters:
      version - the version the catalogue named
      Returns:
      a VersionLookup.Outcome.FOUND lookup
    • none

      public static VersionLookup none()
      Returns:
      the VersionLookup.Outcome.NONE lookup
    • failed

      public static VersionLookup failed(String failure)
      Parameters:
      failure - a short description of why the lookup established nothing
      Returns:
      a VersionLookup.Outcome.FAILED lookup
    • describe

      static String describe(int status, String body)
      Describes a non-2xx answer. SimpleHttpClient answers an I/O failure (refused, timed out, unknown host) with status 500 and a body starting "Error: "; that case is described as not reached rather than as a server error.
      Parameters:
      status - the HTTP status
      body - the body, possibly null
      Returns:
      a short description for the FINE detail line
    • getOutcome

      public VersionLookup.Outcome getOutcome()
      Returns:
      what the lookup established
    • getVersion

      public String getVersion()
      Returns:
      the version found, or null unless the outcome is VersionLookup.Outcome.FOUND
    • getFailure

      public String getFailure()
      Returns:
      a short description of why the lookup failed (for example HTTP 500), or null unless the outcome is VersionLookup.Outcome.FAILED
    • isFailed

      public boolean isFailed()
      Returns:
      true when the lookup established nothing
    • toString

      public String toString()
      Overrides:
      toString in class Object