javax.validation
Class Validation

java.lang.Object
  extended by javax.validation.Validation

public class Validation
extends Object

This class is the entry point for Bean Validation. There are three ways to bootstrap it:

Note:

Author:
Emmanuel Bernard, Hardy Ferentschik

Constructor Summary
Validation()
           
 
Method Summary
static javax.validation.ValidatorFactory buildDefaultValidatorFactory()
          Build and return a ValidatorFactory instance based on the default Bean Validation provider and following the XML configuration.
static javax.validation.bootstrap.GenericBootstrap byDefaultProvider()
          Build a Configuration.
static
<T extends javax.validation.Configuration<T>,U extends javax.validation.spi.ValidationProvider<T>>
javax.validation.bootstrap.ProviderSpecificBootstrap<T>
byProvider(Class<U> providerType)
          Build a Configuration for a particular provider implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 and following the XML configuration.

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:
ValidationException - if the ValidatorFactory cannot be built

byDefaultProvider

public static javax.validation.bootstrap.GenericBootstrap byDefaultProvider()
Build a Configuration. The provider list is resolved using the strategy provided to the bootstrap state.
 Configuration<?> configuration = Validation
    .byDefaultProvider()
    .providerResolver( new MyResolverStrategy() )
    .configure();
 ValidatorFactory factory = configuration.buildValidatorFactory();
 
The provider can be specified in the XML configuration. If the XML configuration does not exsist or if no provider is specified, the first available provider will be returned.

Returns:
instance building a generic Configuration compliant 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)
Build a Configuration for a particular provider implementation. Optionally overrides the provider resolution strategy used to determine the provider.

Used by applications targeting a specific provider programmatically.

 ACMEConfiguration configuration =
     Validation.byProvider(ACMEProvider.class)
             .providerResolver( new MyResolverStrategy() )
             .configure();
 
, where ACMEConfiguration is the Configuration sub interface uniquely identifying the ACME Bean Validation provider. and ACMEProvider is the ValidationProvider implementation of the ACME provider.

Parameters:
providerType - the ValidationProvider implementation type
Returns:
instance building a provider specific Configuration sub interface implementation.


Copyright © 2007-2013 The Apache Software Foundation. All Rights Reserved.