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.

Replaceable via @Service.

Author:
harald
  • Constructor Details

    • ValidatorCache

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

    • getInstance

      public static ValidatorCache getInstance()
      Gets 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 validators of both are applied.
      Parameters:
      clazz - the class to inspect
      Returns:
      the validators for this class
      See Also:
    • getFieldValidators

      public List<Validator> getFieldValidators(Field field, Method method)
      Gets the 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 object validators