Class ValidationResult
java.lang.Object
com.iizix.server.geo.ip2location.ValidationResult
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
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classCollects the messages of a validation and builds the result.static final recordOne message of a validation: the field it is about and the text.Method Summary
Modifier and TypeMethodDescriptionstatic ValidationResult.Builderbuilder()Creates a builder.Gets the first error about a field.Gets the errors.Gets every message as text, errors first, each line prefixed with"ERROR: "or"Warning: ".Gets the warnings.booleanChecks for warnings.booleanisValid()Checks if the configuration can be applied: it has no errors (warnings do not count).toString()static ValidationResultvalid()Gets the result of a valid configuration: no errors, no warnings.
Method Details
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
Gets the errors.- Returns:
- The unmodifiable list, empty for none.
getWarnings
Gets the warnings.- Returns:
- The unmodifiable list, empty for none.
getError
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
builder