javax.validation
Class Validation

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

public class Validation
extends java.lang.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 ValidatorFactory buildDefaultValidatorFactory()
          Build and return a ValidatorFactory instance based on the default Bean Validation provider and following the XML configuration.
static GenericBootstrap byDefaultProvider()
          Build a Configuration.
static
<T extends Configuration<T>,U extends ValidationProvider<T>>
ProviderSpecificBootstrap<T>
byProvider(java.lang.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 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 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 Configuration<T>,U extends ValidationProvider<T>> ProviderSpecificBootstrap<T> byProvider(java.lang.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.


Submit a bug or feature

Copyright © 2009-2011, Oracle Corporation and/or its affiliates. All Rights Reserved. Use is subject to license terms.

Generated on 10-February-2011 12:41