@Test public void testAddDeclaration() { final StringBuilder builder = new StringBuilder(); structure.addDeclaration(builder, 1); final String declaration = builder.toString(); assertThat(declaration).isEqualTo(" 1 " + FIELD.getDeclaration() + "\n"); }
void addDeclaration(final StringBuilder builder, final int level) { for (final Field field : getFields()) { builder.append(StringUtils.repeat(" ", level * 2)); builder.append(level).append(" "); builder.append(field.getDeclaration()); builder.append("\n"); if (field.getType().isComplexType()) { ((StructureImpl) field.getStructure()).addDeclaration(builder, level + 1); } } }
StructureImpl implements Structure { void addDeclaration(final StringBuilder builder, final int level) { for (final Field field : getFields()) { builder.append(StringUtils.repeat(" ", level * 2)); builder.append(level).append(" "); builder.append(field.getDeclaration()); builder.append("\n"); if (field.getType().isComplexType()) { ((StructureImpl) field.getStructure()).addDeclaration(builder, level + 1); } } } }
StructureImpl implements Structure { void addDeclaration(final StringBuilder builder, final int level) { for (final Field field : getFields()) { builder.append(StringUtils.repeat(" ", level * 2)); builder.append(level).append(" "); builder.append(field.getDeclaration()); builder.append("\n"); if (field.getType().isComplexType()) { ((StructureImpl) field.getStructure()).addDeclaration(builder, level + 1); } } } StructureImpl(final Map<String, Field> fields); }
StructureImpl implements Structure { void addDeclaration(final StringBuilder builder, final int level) { for (final Field field : getFields()) { builder.append(StringUtils.repeat(" ", level * 2)); builder.append(level).append(" "); builder.append(field.getDeclaration()); builder.append("\n"); if (field.getType().isComplexType()) { ((StructureImpl) field.getStructure()).addDeclaration(builder, level + 1); } } } StructureImpl(final Map<String, Field> fields); @Override Field getField(final String fieldName); @Override List<Field> getFields(); @Override DataType getType(final String fieldName); @Override boolean hasMember(final String fieldName); }
StructureImpl implements Structure { void addDeclaration(final StringBuilder builder, final int level) { for (final Field field : getFields()) { builder.append(StringUtils.repeat(" ", level * 2)); builder.append(level).append(" "); builder.append(field.getDeclaration()); builder.append("\n"); if (field.getType().isComplexType()) { ((StructureImpl) field.getStructure()).addDeclaration(builder, level + 1); } } } StructureImpl(final Map<String, Field> fields); @Override Field getField(final String fieldName); @Override List<Field> getFields(); @Override DataType getType(final String fieldName); @Override boolean hasMember(final String fieldName);  }