@SuppressWarnings( "unchecked" )
public void onChange(Object object) {
if (object == null) return;
Class entity = object.getClass();
WeakReference<ClassValidator> weakValidator = validators.get(entity);
ClassValidator validator = weakValidator != null ? weakValidator.get() : null;
if ( validator == null ) {
//initialize
//TODO reuse the same reflection manager?
validator = new ClassValidator(entity);
if ( ! validator.hasValidationRules() ) {
validator = NO_VALIDATOR;
}
validators.put( entity, new WeakReference<ClassValidator>(validator) );
currentValidators.add( validator );
}
if ( validator != NO_VALIDATOR ) {
validator.assertValid( object );
}
}