use of jakarta.validation.executable.ExecutableType 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.ExecutableType 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.ExecutableType in project resteasy by resteasy.
the class GeneralValidatorImpl method getExecutableTypesOnMethodInInterfaces.
protected List<ExecutableType[]> getExecutableTypesOnMethodInInterfaces(Class<?> clazz, Method method) {
List<ExecutableType[]> typesList = new ArrayList<ExecutableType[]>();
Class<?>[] interfaces = clazz.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
Method interfaceMethod = getSuperMethod(method, interfaces[i]);
if (interfaceMethod != null) {
ExecutableType[] types = getExecutableTypesOnMethod(interfaceMethod);
if (types != null) {
typesList.add(types);
}
}
List<ExecutableType[]> superList = getExecutableTypesOnMethodInInterfaces(interfaces[i], method);
if (superList.size() > 0) {
typesList.addAll(superList);
}
}
return typesList;
}
use of jakarta.validation.executable.ExecutableType 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