@SuppressWarnings({ "unchecked", "rawtypes" }) public static boolean validates(final Rewrite event, final EvaluationContext context, Validator<?> validator, final Object value) { if (validator != null) { if (value != null && value.getClass().isArray()) { Object[] values = (Object[]) value; for (int i = 0; i < values.length; i++) { if (!((Validator) validator).isValid(event, context, values[i])) { return false; } } } else return ((Validator) validator).isValid(event, context, value); } return true; }
@SuppressWarnings({ "unchecked", "rawtypes" }) public static boolean validates(final Rewrite event, final EvaluationContext context, Validator<?> validator, final Object value) { if (validator != null) { if (value != null && value.getClass().isArray()) { Object[] values = (Object[]) value; for (int i = 0; i < values.length; i++) { if (!((Validator) validator).isValid(event, context, values[i])) { return false; } } } else return ((Validator) validator).isValid(event, context, value); } return true; }
@Override @SuppressWarnings({ "rawtypes", "unchecked" }) public boolean isValid(Rewrite event, EvaluationContext context, Object value) { Validator validator = null; // let one of the SPI implementations build the validator Iterator<ValidatorProvider> providers = ServiceLoader.load(ValidatorProvider.class).iterator(); while (providers.hasNext()) { ValidatorProvider provider = providers.next(); if (targetType != null) { validator = provider.getByTargetType(targetType); } else if (validatorType != null) { validator = provider.getByValidatorType(validatorType); } else { validator = provider.getByValidatorId(validatorId); } if (validator != null) { break; } } Assert.notNull(validator, "Got no validator from any ValidatorProvider for: " + this.toString()); return validator.isValid(event, context, value); }
@Override @SuppressWarnings({ "rawtypes", "unchecked" }) public boolean isValid(Rewrite event, EvaluationContext context, Object value) { Validator validator = null; // let one of the SPI implementations build the validator Iterator<ValidatorProvider> providers = ServiceLoader.load(ValidatorProvider.class).iterator(); while (providers.hasNext()) { ValidatorProvider provider = providers.next(); if (targetType != null) { validator = provider.getByTargetType(targetType); } else if (validatorType != null) { validator = provider.getByValidatorType(validatorType); } else { validator = provider.getByValidatorId(validatorId); } if (validator != null) { break; } } Assert.notNull(validator, "Got no validator from any ValidatorProvider for: " + this.toString()); return validator.isValid(event, context, value); }