else
{
if( value == null )
{
violations = new ArrayList<ConstraintViolation>();
violations.add( new ConstraintViolation( name, OPTIONAL, null ) );
}
}
if( violations == null && value != null )
{
for( ConstraintInstance constraint : constraints )
{
boolean valid;
try
{
valid = constraint.isValid( value );
}
catch( NullPointerException e )
{
// A NPE is the same as a failing constraint
valid = false;
}
if( !valid )
{
if( violations == null )
{
violations = new ArrayList<ConstraintViolation>();
}
ConstraintViolation violation = new ConstraintViolation( name, constraint.annotation(), value );
violations.add( violation );
}
}
}