if (isOneToMany() && (value instanceof List)) {
return;
}
if (!isPrimitive() && !(value instanceof BaseOBObjectDef)) {
final ValidationException ve = new ValidationException();
ve.addMessage(this, "Property " + this + " only allows reference instances of type "
+ BaseOBObjectDef.class.getName() + " but the value is an instanceof "
+ value.getClass().getName());
throw ve;
} else if (isPrimitive()) {
// this specific conversion is allowed
final boolean intToLong = getPrimitiveObjectType().isAssignableFrom(Long.class)
&& value.getClass().isAssignableFrom(Integer.class);
if (!intToLong && !getPrimitiveObjectType().isInstance(value)) {
final ValidationException ve = new ValidationException();
ve.addMessage(this, "Property " + this + " only allows instances of "
+ getPrimitiveObjectType().getName() + " but the value is an instanceof "
+ value.getClass().getName());
throw ve;
}
final PropertyValidator v = getValidator();
if (v != null) {
final String msg = v.validate(value);
if (msg != null) {
final ValidationException ve = new ValidationException();
ve.addMessage(this, msg);
throw ve;
}
}
}
}