} else if (!descendants.isEmpty()) { for (Property descendant : descendants) { if (TypeUtils.isCollection(descendant.getTypeRef())) { methods.addAll(ToMethod.ADD_TO_COLLECTION.apply(descendant)); methods.addAll(ToMethod.REMOVE_FROM_COLLECTION.apply(descendant));
properties.add(buildableField(toAdd)); for (Property descendant : descendants) { if (TypeUtils.isCollection(descendant.getTypeRef())) { methods.addAll(ToMethod.ADD_TO_COLLECTION.apply(descendant)); methods.addAll(ToMethod.REMOVE_FROM_COLLECTION.apply(descendant));
public static JSONSchemaProps from(TypeRef typeRef) { //1. Handle Collections and Arrays if (typeRef.getDimensions() > 0 || TypeUtils.isCollection(typeRef)) { return new JSONSchemaPropsBuilder() .withType("array") .withNewItems() .withSchema(from(TypeAs.combine(TypeAs.UNWRAP_ARRAY_OF, TypeAs.UNWRAP_COLLECTION_OF).apply(typeRef))) .and() .build(); //2. Handle Standard Types } else if (TYPE_MAP.containsKey(typeRef)) { return new JSONSchemaPropsBuilder() .withType(TYPE_MAP.get(typeRef)) .build(); //3. Handle Optionals } else if (TypeUtils.isOptional(typeRef)) { return from(TypeAs.UNWRAP_OPTIONAL_OF.apply(typeRef)); //4. Handle complex types } else if (typeRef instanceof ClassRef) { ClassRef classRef = (ClassRef) typeRef; TypeDef def = classRef.getDefinition(); return from(def); } return null; } }