net.sf.jsefa.common.validator.provider
Class ValidatorProvider

java.lang.Object
  extended by net.sf.jsefa.common.validator.provider.ValidatorProvider

public final class ValidatorProvider
extends Object

Provider for Validators.

Each Validator must have a static factory method create , which is either parameterless or has exactly one parameter of type ValidatorConfiguration.

It is thread-safe.

Author:
Norman Lahme-Huetig

Constructor Summary
ValidatorProvider()
          Constructs a ValidatorProvider.
 
Method Summary
 ValidatorProvider createCopy()
          Creates a copy of this ValidatorProvider.
 Validator getForObjectType(Class<?> objectType, String[] constraints)
          Returns a Validator for the given object type and constraints.
 Validator getForValidatorType(Class<? extends Validator> validatorType, Class<?> objectType, String[] constraints)
          Returns an instance of the given Validator type initialized with the given constraints.
 boolean hasValidatorFor(Class<?> objectType)
          Returns true if and only if this provider has a Validator for the given object type.
 void registerValidatorType(Class<?> objectType, Class<? extends Validator> validatorType)
          Registers the given Validator type as being responsible for values of the given object type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidatorProvider

public ValidatorProvider()
Constructs a ValidatorProvider.

Method Detail

createCopy

public ValidatorProvider createCopy()
Creates a copy of this ValidatorProvider.

Returns:
a copy of this ValidatorProvider

hasValidatorFor

public boolean hasValidatorFor(Class<?> objectType)
Returns true if and only if this provider has a Validator for the given object type.

Parameters:
objectType - the type of the object a validator is needed for
Returns:
true if this provider has a Validator for the given type; false otherwise.

getForObjectType

public Validator getForObjectType(Class<?> objectType,
                                  String[] constraints)
Returns a Validator for the given object type and constraints.

Parameters:
objectType - the type of the object a validator is needed for
constraints - the constraints the validator must be initialized with
Returns:
the validator.

getForValidatorType

public Validator getForValidatorType(Class<? extends Validator> validatorType,
                                     Class<?> objectType,
                                     String[] constraints)
Returns an instance of the given Validator type initialized with the given constraints.

Parameters:
validatorType - the Validator type
objectType - the type of the object a validator is needed for
constraints - the constraints to initialize the validator with
Returns:
the validator

registerValidatorType

public void registerValidatorType(Class<?> objectType,
                                  Class<? extends Validator> validatorType)
Registers the given Validator type as being responsible for values of the given object type.

Parameters:
objectType - the object type
validatorType - the Validator type


Copyright © 2014. All rights reserved.