private Stream<AbstractMap.SimpleEntry<String, ParameterMeta>> toFlatNonPrimitivConfig(final List<ParameterMeta> config) { if (config == null || config.isEmpty()) { return empty(); } return config .stream() .filter(Objects::nonNull) .filter(p -> OBJECT.equals(p.getType()) || isArrayOfObject(p)) .filter(p -> p.getNestedParameters() != null) .flatMap(p -> concat(of(new AbstractMap.SimpleEntry<>(toJavaType(p).getName(), p)), toFlatNonPrimitivConfig(p.getNestedParameters()))); }
final String path = sanitizePropertyName(p.getPath()); final String name = sanitizePropertyName(p.getName()); final String type = p.getType().name(); final boolean isEnum = p.getType() == ParameterMeta.Type.ENUM; PropertyValidation validation = propertyValidationService.map(p.getMetadata());
private Class<?> toJavaType(final ParameterMeta p) { if (p.getType().equals(OBJECT) || p.getType().equals(ENUM)) { if (Class.class.isInstance(p.getJavaType())) { return Class.class.cast(p.getJavaType()); } throw new IllegalArgumentException("Unsupported type for parameter " + p.getPath() + " (from " + p.getSource().declaringClass() + "), ensure it is a Class<?>"); } if (p.getType().equals(ARRAY) && ParameterizedType.class.isInstance(p.getJavaType())) { final ParameterizedType parameterizedType = ParameterizedType.class.cast(p.getJavaType()); final Type[] arguments = parameterizedType.getActualTypeArguments(); if (arguments.length == 1 && Class.class.isInstance(arguments[0])) { return Class.class.cast(arguments[0]); } throw new IllegalArgumentException("Unsupported type for parameter " + p.getPath() + " (from " + p.getSource().declaringClass() + "), " + "ensure it is a ParameterizedType with one argument"); } throw new IllegalStateException("Parameter '" + p.getName() + "' is not an object."); }