private Set containerElements()

in bval-jsr/src/main/java/org/apache/bval/jsr/xml/MappingValidator.java [190:220]


    private Set<ContainerElementKey> containerElements(Meta<?> meta,
        List<ContainerElementTypeType> containerElementTypes) {
        if (containerElementTypes.isEmpty()) {
            return Collections.emptySet();
        }
        final Class<?> containerType = TypeUtils.getRawType(meta.getType(), null);
        final int typeParameterCount = containerType.getTypeParameters().length;
        if (typeParameterCount == 0) {
            Exceptions.raise(ValidationException::new, "Cannot specify container element types for %s",
                meta.describeHost());
        }
        return containerElementTypes.stream().map(e -> {
            Integer typeArgumentIndex = e.getTypeArgumentIndex();
            if (typeArgumentIndex == null) {
                if (typeParameterCount > 1) {
                    Exceptions.raise(ValidationException::new,
                        "Unable to resolve unspecified type argument index for %s", meta.describeHost());
                }
                typeArgumentIndex = Integer.valueOf(0);
            }
            final ContainerElementKey result = new ContainerElementKey(containerType, typeArgumentIndex);

            final Meta.ForContainerElement elementMeta = new Meta.ForContainerElement(meta, result);

            constraints(elementMeta, e.getConstraint());
            containerElements(elementMeta, e.getContainerElementType());

            return result;
        }).collect(Collectors.toMap(Function.identity(), ContainerElementKey::getTypeArgumentIndex, enforceUniqueness(
            "Duplicate XML constrained container element %d of " + meta.describeHost(), Function.identity()))).keySet();
    }