Humboldt Alignment Editor 2.5.0

eu.esdihumboldt.hale.common.schema.model.constraint
Class ConstraintUtil

java.lang.Object
  extended by eu.esdihumboldt.hale.common.schema.model.constraint.ConstraintUtil

public abstract class ConstraintUtil
extends Object

Helper for creating default constraints and dealing with the Constraint annotation. Caches immutable default constraints that have a default constructor.

Author:
Simon Templer
See Also:
Constraint, Definition.getConstraint(Class)

Constructor Summary
ConstraintUtil()
           
 
Method Summary
static Class<?> getConstraintType(Class<?> type)
          Determine the constraint type in the hierarchy of the given type, i.e.
static
<T> T
getDefaultConstraint(Class<T> constraintType, Definition<?> definition)
          Get the default constraint for the given constraint type.
static boolean isMutableConstraint(Class<?> type)
          Determine if the constraint type in the hierarchy of the given type is mutable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConstraintUtil

public ConstraintUtil()
Method Detail

getDefaultConstraint

public static <T> T getDefaultConstraint(Class<T> constraintType,
                                         Definition<?> definition)
                              throws IllegalArgumentException
Get the default constraint for the given constraint type.

Type Parameters:
T - the constraint type
Parameters:
constraintType - the concrete constraint type, i.e. a type annotated with Constraint and defining a default constructor and/or a constructor taking a Definition as an argument
definition - the definition the constraint will be associated to
Returns:
the default constraint of the given type
Throws:
IllegalArgumentException - if the given type is no constraint type or creating the default constraint fails
See Also:
Constraint, Definition.getConstraint(Class)

getConstraintType

public static Class<?> getConstraintType(Class<?> type)
                                  throws IllegalArgumentException
Determine the constraint type in the hierarchy of the given type, i.e. the type that is marked with Constraint

Parameters:
type - the type to determine the constraint type for
Returns:
the constraint type
Throws:
IllegalArgumentException - if no constraint type exists in the type hierarchy

isMutableConstraint

public static boolean isMutableConstraint(Class<?> type)
Determine if the constraint type in the hierarchy of the given type is mutable.

Parameters:
type - the type to determine the constraint type for
Returns:
if the constraint is mutable
Throws:
IllegalArgumentException - if no constraint type exists in the type hierarchy

Humboldt Alignment Editor 2.5.0

Build 2012-12-03_12-30-59
Revision 9d2dd4b0318cda9f1393b1ddd390f7f792d70a2d