@Test public void testToBuilder() { Group.Builder goodb = Group.builder().setName("good"); Group parent = Group.builder().setName("parent").addGroup(goodb).build(); Group good = parent.findGroupNested("good").orElse(null); assertThat(good).isNotNull(); Group good2 = good.toBuilder().build(parent); assertThat(good).isEqualTo(good2); assertThat(good.hashCode()).isEqualTo(good2.hashCode()); }
public Builder toBuilder() { Builder builder = builder().setName(this.shortName).setNcfile(this.ncfile).addAttributes(this.attributes) .addDimensions(this.dimensions).addEnumTypedefs(this.enumTypedefs); this.groups.forEach(g -> builder.addGroup(g.toBuilder())); this.variables.forEach(v -> builder.addVariable(v.toBuilder())); return builder; }
Group { public Builder toBuilder() { Builder builder = builder().setName(this.shortName).setNcfile(this.ncfile).addAttributes(this.attributes) .addDimensions(this.dimensions).addEnumTypedefs(this.enumTypedefs); this.groups.forEach(g -> builder.addGroup(g.toBuilder())); this.variables.forEach(v -> builder.addVariable(v.toBuilder())); return builder; } }
Group { public Builder toBuilder() { Builder builder = builder().setName(this.shortName).setNcfile(this.ncfile).addAttributes(this.attributes) .addDimensions(this.dimensions).addEnumTypedefs(this.enumTypedefs); this.groups.forEach(g -> builder.addGroup(g.toBuilder())); this.variables.forEach(v -> builder.addVariable(v.toBuilder())); return builder; } private  Group(Builder builder, @Nullable Group parent); }
Group { public Builder toBuilder() { Builder builder = builder().setName(this.shortName).setNcfile(this.ncfile).addAttributes(this.attributes) .addDimensions(this.dimensions).addEnumTypedefs(this.enumTypedefs); this.groups.forEach(g -> builder.addGroup(g.toBuilder())); this.variables.forEach(v -> builder.addVariable(v.toBuilder())); return builder; } private  Group(Builder builder, @Nullable Group parent); AttributeContainer attributes(); Group commonParent(Group other); @Nullable Attribute findAttribute(String name); String findAttributeString(String attName, String defaultValue); Optional<Dimension> findDimension(String name); @Nullable Dimension findDimension(Dimension dim); @Nullable Dimension findDimensionLocal(String shortName); @Nullable EnumTypedef findEnumeration(String name); @Nullable Group findGroupLocal(String groupShortName); Optional<Group> findGroupNested(String groupShortName); @Nullable Variable findVariableByAttribute(String attName, String attValue); @Nullable Variable findVariableLocal(String varShortName); @Nullable Variable findVariableOrInParent(String varShortName); ImmutableList<Dimension> getDimensions(); ImmutableList<EnumTypedef> getEnumTypedefs(); String getFullName(); ImmutableList<Group> getGroups(); NetcdfFile getNetcdfFile(); @Nullable Group getParentGroup(); String getShortName(); ImmutableList<Variable> getVariables(); boolean isParent(Group other); boolean isRoot(); ImmutableList<Dimension> makeDimensionsList(String dimString); String getNameAndAttributes(); @Override String toString(); @Override boolean equals(Object oo); @Override int hashCode(); Builder toBuilder(); static Builder builder(); }
Group { public Builder toBuilder() { Builder builder = builder().setName(this.shortName).setNcfile(this.ncfile).addAttributes(this.attributes) .addDimensions(this.dimensions).addEnumTypedefs(this.enumTypedefs); this.groups.forEach(g -> builder.addGroup(g.toBuilder())); this.variables.forEach(v -> builder.addVariable(v.toBuilder())); return builder; } private  Group(Builder builder, @Nullable Group parent); AttributeContainer attributes(); Group commonParent(Group other); @Nullable Attribute findAttribute(String name); String findAttributeString(String attName, String defaultValue); Optional<Dimension> findDimension(String name); @Nullable Dimension findDimension(Dimension dim); @Nullable Dimension findDimensionLocal(String shortName); @Nullable EnumTypedef findEnumeration(String name); @Nullable Group findGroupLocal(String groupShortName); Optional<Group> findGroupNested(String groupShortName); @Nullable Variable findVariableByAttribute(String attName, String attValue); @Nullable Variable findVariableLocal(String varShortName); @Nullable Variable findVariableOrInParent(String varShortName); ImmutableList<Dimension> getDimensions(); ImmutableList<EnumTypedef> getEnumTypedefs(); String getFullName(); ImmutableList<Group> getGroups(); NetcdfFile getNetcdfFile(); @Nullable Group getParentGroup(); String getShortName(); ImmutableList<Variable> getVariables(); boolean isParent(Group other); boolean isRoot(); ImmutableList<Dimension> makeDimensionsList(String dimString); String getNameAndAttributes(); @Override String toString(); @Override boolean equals(Object oo); @Override int hashCode(); Builder toBuilder(); static Builder builder();  }