@Override public void validateResourceAndInputParams( final Object resource, final Invocable resourceMethod, final Object[] args) { final Set<ConstraintViolation<Object>> constraintViolations = new HashSet<ConstraintViolation<Object>>(); final BeanDescriptor beanDescriptor = getConstraintsForClass(resource.getClass()); // Resource validation. if (beanDescriptor.isBeanConstrained()) { constraintViolations.addAll(validate(resource)); } if (resourceMethod != null && configuration.getBootstrapConfiguration().isExecutableValidationEnabled()) { final Method handlingMethod = resourceMethod.getHandlingMethod(); // Resource method validation - input parameters. final MethodDescriptor methodDescriptor = beanDescriptor.getConstraintsForMethod( handlingMethod.getName(), handlingMethod.getParameterTypes()); if (methodDescriptor != null && methodDescriptor.hasConstrainedParameters()) { constraintViolations.addAll( forExecutables().validateParameters(resource, handlingMethod, args)); } } if (!constraintViolations.isEmpty()) { throw new ConstraintViolationException(constraintViolations); } }
@Override public boolean hasConstraints() { if (beanDescriptor.isBeanConstrained() || !beanDescriptor.getConstrainedConstructors().isEmpty() || !beanDescriptor .getConstrainedMethods(MethodType.NON_GETTER, MethodType.GETTER) .isEmpty()) { return true; } return false; }