public class IBANValidator
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
IBANValidator.Validator |
Modifier and Type | Field and Description |
---|---|
private static IBANValidator.Validator[] |
DEFAULT_FORMATS |
static IBANValidator |
DEFAULT_IBAN_VALIDATOR |
private java.util.Map<java.lang.String,IBANValidator.Validator> |
formatValidators |
Constructor and Description |
---|
IBANValidator()
Create a default IBAN validator.
|
IBANValidator(IBANValidator.Validator[] formatMap)
Create an IBAN validator from the specified map of IBAN formats.
|
Modifier and Type | Method and Description |
---|---|
private java.util.Map<java.lang.String,IBANValidator.Validator> |
createValidators(IBANValidator.Validator[] formatMap) |
IBANValidator.Validator[] |
getDefaultValidators()
Gets a copy of the default Validators.
|
static IBANValidator |
getInstance()
Return a singleton instance of the IBAN validator using the default formats
|
IBANValidator.Validator |
getValidator(java.lang.String code)
Get the Validator for a given IBAN
|
boolean |
hasValidator(java.lang.String code)
Does the class have the required validator?
|
boolean |
isValid(java.lang.String code)
Validate an IBAN Code.
|
IBANValidator.Validator |
setValidator(IBANValidator.Validator validator)
Installs a validator.
|
IBANValidator.Validator |
setValidator(java.lang.String countryCode,
int length,
java.lang.String format)
Installs a validator.
|
private final java.util.Map<java.lang.String,IBANValidator.Validator> formatValidators
private static final IBANValidator.Validator[] DEFAULT_FORMATS
public static final IBANValidator DEFAULT_IBAN_VALIDATOR
public IBANValidator()
public IBANValidator(IBANValidator.Validator[] formatMap)
formatMap
- map of IBAN formatspublic static IBANValidator getInstance()
private java.util.Map<java.lang.String,IBANValidator.Validator> createValidators(IBANValidator.Validator[] formatMap)
public boolean isValid(java.lang.String code)
Validate an IBAN Code.
value
- The value validation is being performed ontrue
if the value is validpublic boolean hasValidator(java.lang.String code)
code
- the code to checkpublic IBANValidator.Validator[] getDefaultValidators()
public IBANValidator.Validator getValidator(java.lang.String code)
code
- a string starting with the ISO country code (e.g. an IBAN)null
if there is not one registered.public IBANValidator.Validator setValidator(IBANValidator.Validator validator)
validator
- the instance to install.null
if there was nonejava.lang.IllegalStateException
- if an attempt is made to modify the singleton validatorpublic IBANValidator.Validator setValidator(java.lang.String countryCode, int length, java.lang.String format)
countryCode
- length
- the length of the IBAN. Must be ≥ 8 and ≤ 32.
If the length is < 0, the validator is removed, and the format is not used.format
- the format of the IBAN (as a regular expression)null
if there was nonejava.lang.IllegalArgumentException
- if there is a problemjava.lang.IllegalStateException
- if an attempt is made to modify the singleton validator