Class RequiredValidator

  • All Implemented Interfaces:
    ConstraintValidator<Required>

    public class RequiredValidator
    extends java.lang.Object
    implements ConstraintValidator<Required>
    Validator that checks an object for emptiness. Emptiness is defined here as:
    • The value null
    • An object of type CharSequence with length 0
    • An empty array
    • An empty Collection
    • An empty Map
    Since:
    2.1
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private boolean err​(java.lang.String name)  
      void initialize​(Required anAnnotation)
      Called before this validator is used with the constraint annotation value.
      boolean isValid​(java.lang.String name, java.lang.Object value)
      Indicates if the given value is valid.
      • Methods inherited from class java.lang.Object

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

      • LOGGER

        private static final Logger LOGGER
      • annotation

        private Required annotation
    • Constructor Detail

      • RequiredValidator

        public RequiredValidator()
    • Method Detail

      • initialize

        public void initialize​(Required anAnnotation)
        Description copied from interface: ConstraintValidator
        Called before this validator is used with the constraint annotation value.
        Specified by:
        initialize in interface ConstraintValidator<Required>
        Parameters:
        anAnnotation - the annotation value this validator will be validating.
      • isValid

        public boolean isValid​(java.lang.String name,
                               java.lang.Object value)
        Description copied from interface: ConstraintValidator
        Indicates if the given value is valid.
        Specified by:
        isValid in interface ConstraintValidator<Required>
        Parameters:
        name - the name to use for error reporting
        value - the value to validate.
        Returns:
        true if the given value is valid.
      • err

        private boolean err​(java.lang.String name)