org.unitils.objectvalidation.utils
Class Utils

java.lang.Object
  extended by org.unitils.objectvalidation.utils.Utils

public final class Utils
extends Object

Utility methods for the validation module.

Since:
Oct 10, 2013
Author:
Matthieu Mestrez

Method Summary
static void checkArgument(boolean expression, Object errorMessage)
           
static
<T> T
checkNotNull(T reference, Object errorMessage)
           
static
<T> List<Field>
findOneAndOnlyFieldForAnnotation(Class<? extends Object> classContainingField, Class<? extends Annotation> annotation, Class<T> fieldType)
          Will look in the test class to find a field of type 'fieldType' annotated with 'annotation'
static Object instantiate(Class<?> classToInstatiate)
           
static EqualsHashCodeValidator toEqualsHashCodeValidator(Class<?> classToCast)
           
static ObjectValidationRulesCollection toRulesCollection(Class<?> classToCast)
           
static ObjectValidationRulesCollection toRulesCollection(String rulesClassName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

findOneAndOnlyFieldForAnnotation

public static <T> List<Field> findOneAndOnlyFieldForAnnotation(Class<? extends Object> classContainingField,
                                                               Class<? extends Annotation> annotation,
                                                               Class<T> fieldType)
Will look in the test class to find a field of type 'fieldType' annotated with 'annotation'

Parameters:
classContainingField -
annotation -
fieldType -
Returns:
the field if it exists
Throws:
IllegalStateException - if there was an error retrieving the field.

toRulesCollection

public static ObjectValidationRulesCollection toRulesCollection(String rulesClassName)

toEqualsHashCodeValidator

public static EqualsHashCodeValidator toEqualsHashCodeValidator(Class<?> classToCast)

toRulesCollection

public static ObjectValidationRulesCollection toRulesCollection(Class<?> classToCast)

instantiate

public static Object instantiate(Class<?> classToInstatiate)

checkNotNull

public static <T> T checkNotNull(T reference,
                                 Object errorMessage)

checkArgument

public static void checkArgument(boolean expression,
                                 Object errorMessage)


Copyright © 2013-2015. All Rights Reserved.