Class ValidatorCache

java.lang.Object
org.tentackle.validate.ValidatorCache

@Service(ValidatorCache.class) public class ValidatorCache extends Object
Holds all fixed validators cached for all classes.

All validators bound by an annotation are considered fixed and can be cached.
This is a singleton.

Author:
harald
  • Constructor Details

    • ValidatorCache

      public ValidatorCache()
      Creates a validator cache.
  • Method Details

    • getInstance

      public static ValidatorCache getInstance()
      The singleton.
      Returns:
      the singleton
    • invalidate

      public void invalidate()
      Invalidates the cache.
    • getFieldValidators

      public List<Validator> getFieldValidators(Class<?> clazz)
      Gets all validators for all annotated fields or methods.
      If an attribute is annotated both at the field and the (getter-)method level, the method gets precedence.
      Parameters:
      clazz - the class to inspect
      Returns:
      the validators for this class and scope
    • getFieldValidators

      public List<Validator> getFieldValidators(Field field, Method method)
      Get validators for an annotated field and/or method.
      Parameters:
      field - the field, null if none
      method - the (getter-)method, null if none
      Returns:
      the validators
    • getObjectValidators

      public List<Validator> getObjectValidators(Class<?> clazz)
      Gets all validators for an annotated class.
      Parameters:
      clazz - the class to inspect
      Returns:
      the list of field validators