public static Stub convertToStub( JavaLanguageVariable variable, StubTypeTreeRepository typeTreeRepository) { Stub stub = new Stub(); stub.setStubName(variable.getVariableName()); stub.setRequired(variable.isRequired()); stub.setMultiOccurs(variable.isMultiOccurs()); stub.setType(variable.getType()); if (variable.getType().isAnnotationPresent(XmlType.class) && !variable.getType().isEnum()) { convertFieldsToChildStubs(stub, variable.getType(), typeTreeRepository); } return stub; }
private static void convertFieldsToChildStubs( Stub parentStub, Class<?> type, StubTypeTreeRepository typeTreeRepository) { for (Field childField : type.getDeclaredFields()) { Stub child = convertToStub(createVariableFromField(childField), typeTreeRepository); parentStub.addChild(child); } LinkedList<FieldsOfSubType> fieldsOfSubTypes = getFieldsOfSubTypes(type, typeTreeRepository); for (FieldsOfSubType fieldsOfSubType : fieldsOfSubTypes) { for (Field field : fieldsOfSubType.fields) { Stub childStub = convertToStub(createVariableFromField(field), typeTreeRepository); childStub.setSubTypeOfParentStub(fieldsOfSubType.subType); parentStub.addChild(childStub); } } }