Class AddressValidationResult
java.lang.Object
com.onenetwork.platform.common.addressvalidation.AddressValidationResult
public class AddressValidationResult
extends java.lang.Object
Represents the result from a AddressValidation request.
The result can be considered either valid or not valid. Valid results have a suggested Address and possibly suggested changes.
Not valid results will not have a suggested Address and will have at least one error message describing what went wrong.
-
Method Summary
Modifier and Type Method Description java.lang.String
getDefaultErrorMessage(java.util.Locale locale)
Returns a generic error message describing the issue with the AddressValidationResult.java.util.List<java.lang.String>
getErrorMessages()
Gets error messages for the Address Validation.java.util.List<AddressFieldChange>
getFieldAdjustments()
Returns a List of changes that were made (assuming the API supports this information) to the Address.java.util.Optional<Address>
getSuggestedAddress()
If the Address Validator was capable of determining a unique address the result will be an Address with all the fields modified to match what the validator suggested.static AddressValidationResult
invalid(java.lang.String... errors)
Generates an AddressValidationResult with the given errors.static AddressValidationResult
invalid(java.util.List<java.lang.String> errors)
Generates an AddressValidationResult with the given errors.boolean
isValid()
If the AddressValidator was able to determine a unique address matching the input Address.static AddressValidationResult
success(Address suggested, Address original)
Generates an AddressValidationResult which successfully matched with an Address.
-
Method Details
-
success
Generates an AddressValidationResult which successfully matched with an Address. It will return true for isValid() and may suggested field changes. -
invalid
Generates an AddressValidationResult with the given errors. Erorrs must not be null or empty. If it is, an Exception will be thrown. -
invalid
Generates an AddressValidationResult with the given errors. Erorrs must not be null or empty. If it is, an Exception will be thrown. -
getSuggestedAddress
If the Address Validator was capable of determining a unique address the result will be an Address with all the fields modified to match what the validator suggested. If the Address Validator was not able to determine a unique address the result will be empty -
getFieldAdjustments
Returns a List of changes that were made (assuming the API supports this information) to the Address. If no changes are made then an empty List will be returned. (Not null) -
getErrorMessages
public java.util.List<java.lang.String> getErrorMessages()Gets error messages for the Address Validation. If no errors occurred then the resulting List will be empty (non-null). -
isValid
public boolean isValid()If the AddressValidator was able to determine a unique address matching the input Address. This does not necessarily mean that no adjustments were made, but it does mean that getSuggestedAddress() should return a usable value. If this returns false, the AddressValidator was not able to determine an Address that matched the provided values. This means that getSuggestedAddress() will not return a value. -
getDefaultErrorMessage
public java.lang.String getDefaultErrorMessage(java.util.Locale locale)Returns a generic error message describing the issue with the AddressValidationResult. If no errors were found in the validation this will return null
-