TUM CCSM Commons

edu.tum.cs.commons.constraint
Class ConstraintValidator

java.lang.Object
  extended by edu.tum.cs.commons.constraint.ConstraintValidator

public class ConstraintValidator
extends java.lang.Object

A class for storing constraints in the context of classes for which the constraint applies. Additionally it provides methods for checking all matching constraints for a given class.

Version:
$Rev: 26283 $
Author:
hummelb, $Author: juergens $
Rating:
GREEN Hash: 161B52F22D19EF2632D009F5148C7727

Constructor Summary
ConstraintValidator()
           
 
Method Summary
<T> void
addConstraint(java.lang.Class<? extends T> clazz, ILocalConstraint<T> constraint)
          Adds a constraint for a class.
 void checkConstaints(java.lang.Object o)
          Checks all constraints to the given object which are applicable to it.
<X extends java.lang.Exception>
void
checkConstaints(java.lang.Object o, IExceptionHandler<ConstraintViolationException,X> handler)
          Checks all constraints to the given object which are applicable to it.
<T,X_WALKER extends java.lang.Exception>
void
validateMesh(T start, IMeshWalker<T,X_WALKER> walker)
          Validates all reachable elements of a mesh.
<T,X extends java.lang.Exception,X_WALKER extends java.lang.Exception>
void
validateMesh(T start, IMeshWalker<T,X_WALKER> walker, IExceptionHandler<ConstraintViolationException,X> handler)
          Validates all reachable elements of a mesh.
<T,X_WALKER extends java.lang.Exception>
void
validateTree(T root, ITreeWalker<T,X_WALKER> walker)
          Validates all nodes of a tree.
<T,X extends java.lang.Exception,X_WALKER extends java.lang.Exception>
void
validateTree(T root, ITreeWalker<T,X_WALKER> walker, IExceptionHandler<ConstraintViolationException,X> handler)
          Validates all nodes of a tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConstraintValidator

public ConstraintValidator()
Method Detail

addConstraint

public <T> void addConstraint(java.lang.Class<? extends T> clazz,
                              ILocalConstraint<T> constraint)
Adds a constraint for a class.


checkConstaints

public void checkConstaints(java.lang.Object o)
                     throws ConstraintViolationException
Checks all constraints to the given object which are applicable to it.

Throws:
ConstraintViolationException - if any constraint is violated

checkConstaints

public <X extends java.lang.Exception> void checkConstaints(java.lang.Object o,
                                                            IExceptionHandler<ConstraintViolationException,X> handler)
                     throws X extends java.lang.Exception
Checks all constraints to the given object which are applicable to it. If a constraint is violated, the thrown exception is handled by the given provider.

Throws:
X extends java.lang.Exception

validateTree

public <T,X_WALKER extends java.lang.Exception> void validateTree(T root,
                                                                  ITreeWalker<T,X_WALKER> walker)
                  throws ConstraintViolationException,
                         X_WALKER extends java.lang.Exception
Validates all nodes of a tree. The first violation found is propagated to the top using a ConstraintViolationException.

Parameters:
root - the root of the tree.
walker - the walker used to navigate the tree.
Throws:
ConstraintViolationException - if a constraint violation was found.
X_WALKER - if the walker throws an exception.
X_WALKER extends java.lang.Exception

validateTree

public <T,X extends java.lang.Exception,X_WALKER extends java.lang.Exception> void validateTree(T root,
                                                                                                ITreeWalker<T,X_WALKER> walker,
                                                                                                IExceptionHandler<ConstraintViolationException,X> handler)
                  throws X extends java.lang.Exception,
                         X_WALKER extends java.lang.Exception
Validates all nodes of a tree.

Parameters:
root - the root of the tree.
walker - the walker used to navigate the tree.
handler - the exception handler used for dealing with constraint violations.
Throws:
X - if the constraint violation handler throws it.
X_WALKER - if the walker throws an exception.
X extends java.lang.Exception

validateMesh

public <T,X_WALKER extends java.lang.Exception> void validateMesh(T start,
                                                                  IMeshWalker<T,X_WALKER> walker)
                  throws ConstraintViolationException,
                         X_WALKER extends java.lang.Exception
Validates all reachable elements of a mesh. The first violation found is propagated to the top using a ConstraintViolationException.

Parameters:
start - the start element of the mesh.
walker - the walker used to navigate the mesh.
Throws:
ConstraintViolationException - if a constraint violation was found.
X_WALKER - if the walker throws an exception.
X_WALKER extends java.lang.Exception

validateMesh

public <T,X extends java.lang.Exception,X_WALKER extends java.lang.Exception> void validateMesh(T start,
                                                                                                IMeshWalker<T,X_WALKER> walker,
                                                                                                IExceptionHandler<ConstraintViolationException,X> handler)
                  throws X extends java.lang.Exception,
                         X_WALKER extends java.lang.Exception
Validates all reachable elements of a mesh.

Parameters:
start - the start element of the mesh.
walker - the walker used to navigate the mesh.
handler - the exception handler used for dealing with constraint violations.
Throws:
X - if the constraint violation handler throws it.
X_WALKER - if the walker throws an exception.
X extends java.lang.Exception

TUM CCSM Commons

TUM CCSM Commons - 2.7