org.nuiton.validator.bean
Class BeanValidatorFactory

java.lang.Object
  extended by org.nuiton.validator.bean.BeanValidatorFactory

public class BeanValidatorFactory
extends Object

Factory of BeanValidator.

To obtain a new BeanValidator, use one of the method

 BeanValidatorFactory.newBeanValidator(XXX)
 

Since:
2.0
Author:
tchemit
See Also:
BeanValidator

Nested Class Summary
static interface BeanValidatorFactory.BeanValidatorCreator
          Contract to create a BeanValidator.
static class BeanValidatorFactory.DefaultBeanValidatorCreator
          Default implementation of BeanValidatorFactory.BeanValidatorCreator which just instanciate a BeanValidator from the given parameters.
 
Field Summary
protected static BeanValidatorFactory.BeanValidatorCreator creator
          Object to create new validators.
 
Constructor Summary
BeanValidatorFactory()
           
 
Method Summary
static BeanValidatorFactory.BeanValidatorCreator getCreator()
          Obtain the bean validator creator.
static boolean isDefaultCreator()
           
static
<O> BeanValidator<O>
newBeanValidator(Class<O> type, String context, NuitonValidatorScope... scopes)
          Obtain a new BeanValidator for the given parameters.
static
<O> BeanValidator<O>
newBeanValidator(String providerName, Class<O> type, String context, NuitonValidatorScope... scopes)
          Obtain a new BeanValidator for the given parameters.
static void setCreator(BeanValidatorFactory.BeanValidatorCreator creator)
          Sets an explicit bean validator creator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

creator

protected static BeanValidatorFactory.BeanValidatorCreator creator
Object to create new validators.

If none is given, it will use the default one, says the BeanValidatorFactory.DefaultBeanValidatorCreator.

Constructor Detail

BeanValidatorFactory

public BeanValidatorFactory()
Method Detail

getCreator

public static BeanValidatorFactory.BeanValidatorCreator getCreator()
Obtain the bean validator creator.

If none is defined, then will use a default one, says the BeanValidatorFactory.DefaultBeanValidatorCreator.

Returns:
the bean validator creator

setCreator

public static void setCreator(BeanValidatorFactory.BeanValidatorCreator creator)
Sets an explicit bean validator creator.

Parameters:
creator - the creator to use

isDefaultCreator

public static boolean isDefaultCreator()

newBeanValidator

public static <O> BeanValidator<O> newBeanValidator(Class<O> type,
                                                    String context,
                                                    NuitonValidatorScope... scopes)
                                         throws NullPointerException
Obtain a new BeanValidator for the given parameters.

Note: It will use the default provider of NuitonValidator

Type Parameters:
O - type of bean to validate
Parameters:
type - type of bean to validate
context - context of validation
scopes - authorized scopes (if null, will use all scopes)
Returns:
the new instanciated BeanValidator.
Throws:
NullPointerException - if type is null
See Also:
NuitonValidatorFactory.getDefaultProviderName()

newBeanValidator

public static <O> BeanValidator<O> newBeanValidator(String providerName,
                                                    Class<O> type,
                                                    String context,
                                                    NuitonValidatorScope... scopes)
                                         throws NullPointerException
Obtain a new BeanValidator for the given parameters.

Note: It will use the provider of NuitonValidator defined by the providerName.

Type Parameters:
O - type of bean to validate
Parameters:
providerName - name of NuitonValidator to use
type - type of bean to validate
context - context of validation
scopes - authorized scopes (if null, will use all scopes)
Returns:
the new instanciated BeanValidator.
Throws:
NullPointerException - if type is null
See Also:
NuitonValidatorFactory.getProvider(String)


Copyright © 2011-2012 CodeLutin. All Rights Reserved.