Class ValidatedConversion

  • All Implemented Interfaces:
    Conversion<java.lang.Object,​java.lang.Object>

    public class ValidatedConversion
    extends java.lang.Object
    implements Conversion<java.lang.Object,​java.lang.Object>
    Performs one or more validations against the values of a given record.
    • Constructor Summary

      Constructors 
      Constructor 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)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • regexToMatch

        private final java.lang.String regexToMatch
      • nullable

        private final boolean nullable
      • allowBlanks

        private final boolean allowBlanks
      • oneOf

        private final java.util.Set<java.lang.String> oneOf
      • noneOf

        private final java.util.Set<java.lang.String> noneOf
      • matcher

        private final java.util.regex.Matcher matcher
      • validators

        private final Validator[] validators
    • Constructor Detail

      • ValidatedConversion

        public ValidatedConversion()
      • ValidatedConversion

        public ValidatedConversion​(java.lang.String regexToMatch)
      • ValidatedConversion

        public ValidatedConversion​(boolean nullable,
                                   boolean allowBlanks)
      • ValidatedConversion

        public ValidatedConversion​(boolean nullable,
                                   boolean allowBlanks,
                                   java.lang.String[] oneOf,
                                   java.lang.String[] noneOf,
                                   java.lang.String regexToMatch)
      • ValidatedConversion

        public ValidatedConversion​(boolean nullable,
                                   boolean allowBlanks,
                                   java.lang.String[] oneOf,
                                   java.lang.String[] noneOf,
                                   java.lang.String regexToMatch,
                                   java.lang.Class[] validators)
    • Method Detail

      • instantiateValidators

        private Validator[] instantiateValidators​(java.lang.Class[] validators)
      • execute

        public java.lang.Object execute​(java.lang.Object input)
        Description copied from interface: Conversion
        Converts a value of type I to a value of type O. When used in conjunction with the 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 I
        Specified by:
        execute in interface Conversion<java.lang.Object,​java.lang.Object>
        Parameters:
        input - the input of type I to be converted to an object of type O
        Returns:
        the conversion result.
      • revert

        public java.lang.Object revert​(java.lang.Object input)
        Description copied from interface: Conversion
        Converts a value of type O to a value of type I. When used in conjunction with the 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 O
        Specified by:
        revert in interface Conversion<java.lang.Object,​java.lang.Object>
        Parameters:
        input - the input of type O to be converted to an object of type I
        Returns:
        the conversion result.
      • validate

        protected void validate​(java.lang.Object value)