use of jakarta.validation.executable.ValidateOnExecution in project resteasy by resteasy.
the class GeneralValidatorImpl method getExecutableTypesOnMethod.
protected static ExecutableType[] getExecutableTypesOnMethod(Method method) {
ValidateOnExecution voe = method.getAnnotation(ValidateOnExecution.class);
if (voe == null || voe.type().length == 0) {
return null;
}
ExecutableType[] types = voe.type();
if (types == null || types.length == 0) {
return null;
}
return types;
}
use of jakarta.validation.executable.ValidateOnExecution in project hibernate-validator by hibernate.
the class ValidationExtension method executableTypesDefinedOnMethod.
private EnumSet<ExecutableType> executableTypesDefinedOnMethod(Method method, boolean isGetter) {
ValidateOnExecution validateOnExecutionAnnotation = method.getAnnotation(ValidateOnExecution.class);
EnumSet<ExecutableType> executableTypes = commonExecutableTypeChecks(validateOnExecutionAnnotation);
if (executableTypes.contains(ExecutableType.IMPLICIT)) {
if (isGetter) {
executableTypes.add(ExecutableType.GETTER_METHODS);
} else {
executableTypes.add(ExecutableType.NON_GETTER_METHODS);
}
}
return executableTypes;
}
use of jakarta.validation.executable.ValidateOnExecution in project hibernate-validator by hibernate.
the class ValidationExtension method executableTypesDefinedOnType.
private EnumSet<ExecutableType> executableTypesDefinedOnType(Class<?> clazz) {
ValidateOnExecution validateOnExecutionAnnotation = clazz.getAnnotation(ValidateOnExecution.class);
EnumSet<ExecutableType> executableTypes = commonExecutableTypeChecks(validateOnExecutionAnnotation);
if (executableTypes.contains(ExecutableType.IMPLICIT)) {
return DEFAULT_EXECUTABLE_TYPES;
}
return executableTypes;
}
use of jakarta.validation.executable.ValidateOnExecution in project hibernate-validator by hibernate.
the class ValidationExtension method executableTypesDefinedOnConstructor.
private EnumSet<ExecutableType> executableTypesDefinedOnConstructor(Constructor<?> constructor) {
ValidateOnExecution validateOnExecutionAnnotation = constructor.getAnnotation(ValidateOnExecution.class);
EnumSet<ExecutableType> executableTypes = commonExecutableTypeChecks(validateOnExecutionAnnotation);
if (executableTypes.contains(ExecutableType.IMPLICIT)) {
executableTypes.add(ExecutableType.CONSTRUCTORS);
}
return executableTypes;
}
use of jakarta.validation.executable.ValidateOnExecution in project resteasy by resteasy.
the class GeneralValidatorImpl method isMethodValidatable.
@Override
public boolean isMethodValidatable(Method m) {
if (!isExecutableValidationEnabled) {
return false;
}
ExecutableType[] types = null;
List<ExecutableType[]> typesList = getExecutableTypesOnMethodInHierarchy(m);
if (typesList.size() > 1) {
throw new ValidationException(Messages.MESSAGES.validateOnExceptionOnMultipleMethod());
}
if (typesList.size() == 1) {
types = typesList.get(0);
} else {
ValidateOnExecution voe = m.getDeclaringClass().getAnnotation(ValidateOnExecution.class);
if (voe == null) {
types = defaultValidatedExecutableTypes;
} else {
if (voe.type().length > 0) {
types = voe.type();
} else {
types = defaultValidatedExecutableTypes;
}
}
}
boolean isGetterMethod = isGetter(m);
for (int i = 0; i < types.length; i++) {
switch(types[i]) {
case IMPLICIT:
case ALL:
return true;
case NONE:
continue;
case NON_GETTER_METHODS:
if (!isGetterMethod) {
return true;
}
continue;
case GETTER_METHODS:
if (isGetterMethod) {
return true;
}
continue;
default:
continue;
}
}
return false;
}
Aggregations