Search in sources :

Example 1 with ContainerElementTypeDescriptor

use of javax.validation.metadata.ContainerElementTypeDescriptor in project minijax by minijax.

the class MinijaxContainerElementTypeDescriptor method build.

public static Set<ContainerElementTypeDescriptor> build(final Class<?> elementClass, final AnnotatedParameterizedType annotatedType) {
    final Set<ContainerElementTypeDescriptor> result = new HashSet<>();
    final Class<?> containerClass = ReflectionUtils.getRawType(annotatedType);
    int argIndex = 0;
    for (final AnnotatedType typeArg : annotatedType.getAnnotatedActualTypeArguments()) {
        final Set<ConstraintDescriptor<?>> constraintDescriptors = new HashSet<>();
        for (final Annotation annotation : typeArg.getAnnotations()) {
            final MinijaxConstraintDescriptor<?> constraintDescriptor = MinijaxConstraintDescriptor.build(typeArg, annotation);
            if (constraintDescriptor != null) {
                constraintDescriptors.add(constraintDescriptor);
            }
        }
        if (!constraintDescriptors.isEmpty()) {
            result.add(new MinijaxContainerElementTypeDescriptor(elementClass, containerClass, argIndex, constraintDescriptors));
        }
        argIndex++;
    }
    return result;
}
Also used : ContainerElementTypeDescriptor(javax.validation.metadata.ContainerElementTypeDescriptor) AnnotatedType(java.lang.reflect.AnnotatedType) ConstraintDescriptor(javax.validation.metadata.ConstraintDescriptor) Annotation(java.lang.annotation.Annotation) HashSet(java.util.HashSet)

Aggregations

Annotation (java.lang.annotation.Annotation)1 AnnotatedType (java.lang.reflect.AnnotatedType)1 HashSet (java.util.HashSet)1 ConstraintDescriptor (javax.validation.metadata.ConstraintDescriptor)1 ContainerElementTypeDescriptor (javax.validation.metadata.ContainerElementTypeDescriptor)1