Class ValidationResult

java.lang.Object
com.iizix.server.geo.ip2location.ValidationResult

public final class ValidationResult extends Object
The result of validating an IP2LocationAdminConfig: the errors that stop the configuration from being applied and the warnings that do not. Ported from the NetPhantom administration panel (co.mindus.ip2location.ui.ValidationResult); every message is paired with the name of the field it is about, so that a UI can put the message beside the field, which the NetPhantom message boxes did not need.

A result is immutable. valid() is the shared result with no messages.

Author:
Christopher Mindus
  • Method Details

    • valid

      public static ValidationResult valid()
      Gets the result of a valid configuration: no errors, no warnings.
      Returns:
      The shared valid result.
    • isValid

      public boolean isValid()
      Checks if the configuration can be applied: it has no errors (warnings do not count).
      Returns:
      true for no errors.
    • hasWarnings

      public boolean hasWarnings()
      Checks for warnings.
      Returns:
      true if there is at least one warning.
    • getErrors

      public List<ValidationResult.Message> getErrors()
      Gets the errors.
      Returns:
      The unmodifiable list, empty for none.
    • getWarnings

      public List<ValidationResult.Message> getWarnings()
      Gets the warnings.
      Returns:
      The unmodifiable list, empty for none.
    • getError

      public String getError(String field)
      Gets the first error about a field.
      Parameters:
      field - The field name.
      Returns:
      The message text, or null for none.
    • getFormattedMessages

      public String getFormattedMessages()
      Gets every message as text, errors first, each line prefixed with "ERROR: " or "Warning: ".
      Returns:
      The lines joined by a line feed, an empty string for a valid result without warnings.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • builder

      public static ValidationResult.Builder builder()
      Creates a builder.
      Returns:
      A new builder.