@Test public void testSelect() { Variable.Builder<?> varb1 = Variable.builder().setName("var1").setDataType(DataType.FLOAT); Variable.Builder<?> varb2 = Variable.builder().setName("var2").setDataType(DataType.INT); Structure.Builder<?> structb = Structure.builder().setName("top").addMemberVariables(ImmutableList.of(varb1, varb2)); Structure struct = structb.build(makeDummyGroup()); assertThat(struct.getNumberOfMemberVariables()).isEqualTo(2); assertThat(struct.findVariable("var1")).isNotNull(); assertThat(struct.findVariable("var2")).isNotNull(); Structure selected = struct.select("var1"); assertThat(selected.getNumberOfMemberVariables()).isEqualTo(1); assertThat(selected.findVariable("var1")).isNotNull(); assertThat(selected.findVariable("var2")).isNull(); }
public Structure select(List<String> memberNames) { Structure.Builder<?> result = this.toBuilder(); result.setElementSize(this.elementSize); List<Variable.Builder<?>> selected = new ArrayList<>(); for (String name : memberNames) { result.findMemberVariable(name).ifPresent(selected::add); } result.vbuilders = selected; result.isSubset = true; return result.build(getParentGroup()); }
Structure extends Variable { public Structure select(List<String> memberNames) { Structure.Builder<?> result = this.toBuilder(); result.setElementSize(this.elementSize); List<Variable.Builder<?>> selected = new ArrayList<>(); for (String name : memberNames) { result.findMemberVariable(name).ifPresent(selected::add); } result.vbuilders = selected; result.isSubset = true; return result.build(getParentGroup()); } }
Structure extends Variable { public Structure select(List<String> memberNames) { Structure.Builder<?> result = this.toBuilder(); result.setElementSize(this.elementSize); List<Variable.Builder<?>> selected = new ArrayList<>(); for (String name : memberNames) { result.findMemberVariable(name).ifPresent(selected::add); } result.vbuilders = selected; result.isSubset = true; return result.build(getParentGroup()); } protected  Structure(Builder<?> builder, Group parentGroup); }
Structure extends Variable { public Structure select(List<String> memberNames) { Structure.Builder<?> result = this.toBuilder(); result.setElementSize(this.elementSize); List<Variable.Builder<?>> selected = new ArrayList<>(); for (String name : memberNames) { result.findMemberVariable(name).ifPresent(selected::add); } result.vbuilders = selected; result.isSubset = true; return result.build(getParentGroup()); } protected  Structure(Builder<?> builder, Group parentGroup); @Nullable Variable findVariable(String shortName); int getNumberOfMemberVariables(); @Override int getElementSize(); ImmutableList<Variable> getVariables(); ImmutableList<String> getVariableNames(); boolean isSubset(); StructureMembers makeStructureMembers(); Structure select(List<String> memberNames); Structure select(String varName); @Deprecated StructureData readStructure(int index); @Deprecated ArrayStructure readStructure(int start, int count); @Deprecated StructureDataIterator getStructureIterator(); @Deprecated StructureDataIterator getStructureIterator(int bufferSize); String getNameAndAttributes(); @Override Builder<?> toBuilder(); static Builder<?> builder(); }
Structure extends Variable { public Structure select(List<String> memberNames) { Structure.Builder<?> result = this.toBuilder(); result.setElementSize(this.elementSize); List<Variable.Builder<?>> selected = new ArrayList<>(); for (String name : memberNames) { result.findMemberVariable(name).ifPresent(selected::add); } result.vbuilders = selected; result.isSubset = true; return result.build(getParentGroup()); } protected  Structure(Builder<?> builder, Group parentGroup); @Nullable Variable findVariable(String shortName); int getNumberOfMemberVariables(); @Override int getElementSize(); ImmutableList<Variable> getVariables(); ImmutableList<String> getVariableNames(); boolean isSubset(); StructureMembers makeStructureMembers(); Structure select(List<String> memberNames); Structure select(String varName); @Deprecated StructureData readStructure(int index); @Deprecated ArrayStructure readStructure(int start, int count); @Deprecated StructureDataIterator getStructureIterator(); @Deprecated StructureDataIterator getStructureIterator(int bufferSize); String getNameAndAttributes(); @Override Builder<?> toBuilder(); static Builder<?> builder();  }