public void checkValidReplacement ( Element newValue ) throws EvaluationException { // Only need to check if new values is not undef or null. Undef or null // can replace any value. if ( ! ( newValue instanceof Undef ) && ! ( newValue instanceof Null ) ) { if ( ! this . getClass ( ) . isAssignableFrom ( newValue . getClass ( ) ) ) { throw new EvaluationException ( MessageUtils . format ( MSG_INVALID_REPLACEMENT , this . getTypeAsString ( ) , newValue . getTypeAsString ( ) ) ) ; } } }
Check that the newValue is a valid replacement for the this value . This implementation will check if the newValue is assignable from the current value or that the newValue is either undef or null . If not an evaluation exception will be thrown . This implementation should be overridden if more liberal replacements are allowed .