Class Validation


  • public class Validation
    extends Object
    This class is the entry point for Bean Validation. Bootstrapping is done as follows:
     {
       @code
       ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
     }
     

    Or, equivalently:

     {
       @code
       Configuration<?> configuration = Validation.byDefaultProvider().configure();
       ValidatorFactory factory = configuration.buildValidatorFactory();
     }
     

    Only the default provider is available for use, and thus the byProvider and providerResolver methods are not supported. Calling either of these methods will generate an exception.

    This class was modified by Google from the original javax.validation.Validation source to make it suitable for GWT.

    • Constructor Detail

      • Validation

        public Validation()
    • Method Detail

      • buildDefaultValidatorFactory

        public static javax.validation.ValidatorFactory buildDefaultValidatorFactory()
        Build and return a ValidatorFactory instance based on the default Bean Validation provider.

        The provider list is resolved using the default validation provider resolver logic.

        The code is semantically equivalent to Validation.byDefaultProvider().configure().buildValidatorFactory()
        Returns:
        ValidatorFactory instance.
        Throws:
        javax.validation.ValidationException - if the ValidatorFactory cannot be built
      • byDefaultProvider

        public static javax.validation.bootstrap.GenericBootstrap byDefaultProvider()
        Build a Configuration.
         Configuration<?> configuration = Validation.byDefaultProvider().configure();
         ValidatorFactory factory = configuration.buildValidatorFactory();
         

        The first available provider will be returned.

        Returns:
        instance building a generic Configuration complaint with the bootstrap state provided.
      • byProvider

        public static <T extends javax.validation.Configuration<T>,​U extends javax.validation.spi.ValidationProvider<T>> javax.validation.bootstrap.ProviderSpecificBootstrap<T> byProvider​(Class<U> providerType)
        Unsupported. Always throws an UnsupportedOperationException.
        Type Parameters:
        T - configuration type
        U - validation provider type
        Parameters:
        providerType - class of the provider type
        Returns:
        provider specific bootstrap
        Throws:
        UnsupportedOperationException - not supported