use of jakarta.validation.executable.ExecutableType 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.ExecutableType in project resteasy by resteasy.
the class GeneralValidatorImpl method getExecutableTypesOnMethodInHierarchy.
protected List<ExecutableType[]> getExecutableTypesOnMethodInHierarchy(Method method) {
Class<?> clazz = method.getDeclaringClass();
List<ExecutableType[]> typesList = new ArrayList<ExecutableType[]>();
while (clazz != null) {
// We start by examining the method itself.
Method superMethod = getSuperMethod(method, clazz);
if (superMethod != null) {
ExecutableType[] types = getExecutableTypesOnMethod(superMethod);
if (types != null) {
typesList.add(types);
}
}
typesList.addAll(getExecutableTypesOnMethodInInterfaces(clazz, method));
clazz = clazz.getSuperclass();
}
return typesList;
}
use of jakarta.validation.executable.ExecutableType in project resteasy by resteasy.
the class AbstractValidatorContextResolver method getContext.
public GeneralValidatorCDI getContext(Class<?> type) {
try {
BootstrapConfiguration bootstrapConfiguration = getConfig();
boolean isExecutableValidationEnabled = bootstrapConfiguration.isExecutableValidationEnabled();
Set<ExecutableType> defaultValidatedExecutableTypes = bootstrapConfiguration.getDefaultValidatedExecutableTypes();
return new GeneralValidatorImpl(getValidatorFactory(), isExecutableValidationEnabled, defaultValidatedExecutableTypes);
} catch (Exception e) {
throw new ValidationException(Messages.MESSAGES.unableToLoadValidationSupport(), e);
}
}
use of jakarta.validation.executable.ExecutableType 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.ExecutableType in project hibernate-validator by hibernate.
the class ValidationExtension method determineConstrainedMethods.
private <T> void determineConstrainedMethods(AnnotatedType<T> type, BeanDescriptor beanDescriptor, Set<AnnotatedCallable<? super T>> callables) {
List<Method> overriddenAndImplementedMethods = InheritedMethodsHelper.getAllMethods(type.getJavaClass());
for (AnnotatedMethod<? super T> annotatedMethod : type.getMethods()) {
Method method = annotatedMethod.getJavaMember();
Optional<String> correspondingProperty = getterPropertySelectionStrategyHelper.getProperty(method);
// obtain @ValidateOnExecution from the top-most method in the hierarchy
Method methodForExecutableTypeRetrieval = replaceWithOverriddenOrInterfaceMethod(method, overriddenAndImplementedMethods);
EnumSet<ExecutableType> classLevelExecutableTypes = executableTypesDefinedOnType(methodForExecutableTypeRetrieval.getDeclaringClass());
EnumSet<ExecutableType> memberLevelExecutableType = executableTypesDefinedOnMethod(methodForExecutableTypeRetrieval, correspondingProperty.isPresent());
ExecutableType currentExecutableType = correspondingProperty.isPresent() ? ExecutableType.GETTER_METHODS : ExecutableType.NON_GETTER_METHODS;
// validation occurs
if (veto(classLevelExecutableTypes, memberLevelExecutableType, currentExecutableType)) {
continue;
}
boolean needsValidation;
if (correspondingProperty.isPresent()) {
needsValidation = isGetterConstrained(beanDescriptor, method, correspondingProperty.get());
} else {
needsValidation = isNonGetterConstrained(beanDescriptor, method);
}
if (needsValidation) {
callables.add(annotatedMethod);
}
}
}
Aggregations