Class TraversableResolvers

java.lang.Object
org.hibernate.validator.internal.engine.resolver.TraversableResolvers

public class TraversableResolvers extends Object
  • Method Details

    • getDefault

      public static TraversableResolver getDefault()
      Initializes and returns the default TraversableResolver depending on the environment.

      If JPA 2 is present in the classpath, a JPATraversableResolver instance is returned.

      Otherwise, it returns an instance of the default TraverseAllTraversableResolver.

    • wrapWithCachingForSingleValidation

      public static TraversableResolver wrapWithCachingForSingleValidation(TraversableResolver traversableResolver, boolean traversableResolverResultCacheEnabled)
      Potentially wrap the TraversableResolver into a caching one.

      If traversableResolver is TraverseAllTraversableResolver.INSTANCE, we don't wrap it and it is returned directly. Same if the caching is explicitly disabled.

      If traversableResolver is an instance of our JPATraversableResolver, we wrap it with a caching wrapper specially tailored for the requirements of the spec. It is a very common case as it is used as soon as we have a JPA implementation in the classpath so optimizing this case is worth it.

      In all the other cases, we wrap the resolver for caching.

      Note that, in the TraversableResolver is wrapped, a new instance is returned each time and it should be used only for the duration of a validation call.

      Returns:
      The resolver for the duration of a validation call.