public class ValidatedConversion extends java.lang.Object implements Conversion<java.lang.Object,java.lang.Object>
Modifier and Type | Field and Description |
---|---|
private boolean |
allowBlanks |
private java.util.regex.Matcher |
matcher |
private java.util.Set<java.lang.String> |
noneOf |
private boolean |
nullable |
private java.util.Set<java.lang.String> |
oneOf |
private java.lang.String |
regexToMatch |
private Validator[] |
validators |
Constructor and Description |
---|
ValidatedConversion() |
ValidatedConversion(boolean nullable,
boolean allowBlanks) |
ValidatedConversion(boolean nullable,
boolean allowBlanks,
java.lang.String[] oneOf,
java.lang.String[] noneOf,
java.lang.String regexToMatch) |
ValidatedConversion(boolean nullable,
boolean allowBlanks,
java.lang.String[] oneOf,
java.lang.String[] noneOf,
java.lang.String regexToMatch,
java.lang.Class[] validators) |
ValidatedConversion(java.lang.String regexToMatch) |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
execute(java.lang.Object input)
Converts a value of type I to a value of type O.
|
private Validator[] |
instantiateValidators(java.lang.Class[] validators) |
java.lang.Object |
revert(java.lang.Object input)
Converts a value of type O to a value of type I.
|
protected void |
validate(java.lang.Object value) |
private final java.lang.String regexToMatch
private final boolean nullable
private final boolean allowBlanks
private final java.util.Set<java.lang.String> oneOf
private final java.util.Set<java.lang.String> noneOf
private final java.util.regex.Matcher matcher
private final Validator[] validators
public ValidatedConversion()
public ValidatedConversion(java.lang.String regexToMatch)
public ValidatedConversion(boolean nullable, boolean allowBlanks)
public ValidatedConversion(boolean nullable, boolean allowBlanks, java.lang.String[] oneOf, java.lang.String[] noneOf, java.lang.String regexToMatch)
public ValidatedConversion(boolean nullable, boolean allowBlanks, java.lang.String[] oneOf, java.lang.String[] noneOf, java.lang.String regexToMatch, java.lang.Class[] validators)
private Validator[] instantiateValidators(java.lang.Class[] validators)
public java.lang.Object execute(java.lang.Object input)
Conversion
Convert
annotation, this method will perform
the conversion from a parsed input String
(if no other conversion has been applied before)
to a value of the desired type, and the result will be assigned to the annotated field. Note that conversions can be
chained so you need to make sure the input type of any previous conversion is compatible with Iexecute
in interface Conversion<java.lang.Object,java.lang.Object>
input
- the input of type I to be converted to an object of type Opublic java.lang.Object revert(java.lang.Object input)
Conversion
Convert
annotation, this method will
convert the value of the annotated field so it can be written to the output (usually a String
). Note that conversions can be
chained so you need to make sure the type of any previous conversion is compatible with Orevert
in interface Conversion<java.lang.Object,java.lang.Object>
input
- the input of type O to be converted to an object of type Iprotected void validate(java.lang.Object value)