@Test public void testVariableSimpleBuilder() { Dimension dim1 = new Dimension("dim1", 1); Dimension dim2 = new Dimension("dim2", 2); VariableSimpleBuilder builder = new VariableSimpleBuilder("name", "desc", "units", DataType.INT, ImmutableList.of(dim1, dim2)); builder.addAttribute(new Attribute("name", 1.23)); builder.addAttribute("name2", "value2"); VariableSimpleIF vs = builder.build(); assertThat(vs.getShortName()).isEqualTo("name"); assertThat(vs.getFullName()).isEqualTo("name"); assertThat(vs.getDescription()).isEqualTo("desc"); assertThat(vs.getUnitsString()).isEqualTo("units"); assertThat(vs.getDataType()).isEqualTo(DataType.INT); assertThat(vs.getDimensions()).hasSize(2); assertThat(vs.getDimensions()).isInstanceOf(ImmutableList.class); assertThat(vs.getShape()).isEqualTo(new int[] {1, 2}); assertThat(vs.getRank()).isEqualTo(2); assertThat(vs.attributes().findAttributeString("name2", null)).isEqualTo("value2"); assertThat(vs.attributes().findAttributeDouble("name", 0.0)).isEqualTo(1.23); }
public VariableSimpleBuilder(String name, String desc, String units, DataType dt, List<Dimension> dims) { this.name = name; this.desc = desc; this.units = units; this.dt = dt; this.dims = (dims == null || dims.size() == 0) ? ImmutableList.of() : ImmutableList.copyOf(dims); this.atts = new AttributeContainerMutable(name); if (units != null) { atts.addAttribute(new Attribute(CDM.UNITS, units)); } if (desc != null) { atts.addAttribute(new Attribute(CDM.LONG_NAME, desc)); } }
VariableSimpleBuilder { public VariableSimpleBuilder(String name, String desc, String units, DataType dt, List<Dimension> dims) { this.name = name; this.desc = desc; this.units = units; this.dt = dt; this.dims = (dims == null || dims.size() == 0) ? ImmutableList.of() : ImmutableList.copyOf(dims); this.atts = new AttributeContainerMutable(name); if (units != null) { atts.addAttribute(new Attribute(CDM.UNITS, units)); } if (desc != null) { atts.addAttribute(new Attribute(CDM.LONG_NAME, desc)); } } }
VariableSimpleBuilder { public VariableSimpleBuilder(String name, String desc, String units, DataType dt, List<Dimension> dims) { this.name = name; this.desc = desc; this.units = units; this.dt = dt; this.dims = (dims == null || dims.size() == 0) ? ImmutableList.of() : ImmutableList.copyOf(dims); this.atts = new AttributeContainerMutable(name); if (units != null) { atts.addAttribute(new Attribute(CDM.UNITS, units)); } if (desc != null) { atts.addAttribute(new Attribute(CDM.LONG_NAME, desc)); } } VariableSimpleBuilder(String name, String desc, String units, DataType dt, List<Dimension> dims); }
VariableSimpleBuilder { public VariableSimpleBuilder(String name, String desc, String units, DataType dt, List<Dimension> dims) { this.name = name; this.desc = desc; this.units = units; this.dt = dt; this.dims = (dims == null || dims.size() == 0) ? ImmutableList.of() : ImmutableList.copyOf(dims); this.atts = new AttributeContainerMutable(name); if (units != null) { atts.addAttribute(new Attribute(CDM.UNITS, units)); } if (desc != null) { atts.addAttribute(new Attribute(CDM.LONG_NAME, desc)); } } VariableSimpleBuilder(String name, String desc, String units, DataType dt, List<Dimension> dims); static VariableSimpleBuilder fromMember(StructureMembers.Member m); static VariableSimpleBuilder makeScalar(String name, String desc, String units, DataType dt); static VariableSimpleBuilder makeString(String name, String desc, String units, int str_len); VariableSimpleBuilder addAttribute(Attribute att); VariableSimpleBuilder addAttribute(String name, String value); VariableSimpleIF build(); }
VariableSimpleBuilder { public VariableSimpleBuilder(String name, String desc, String units, DataType dt, List<Dimension> dims) { this.name = name; this.desc = desc; this.units = units; this.dt = dt; this.dims = (dims == null || dims.size() == 0) ? ImmutableList.of() : ImmutableList.copyOf(dims); this.atts = new AttributeContainerMutable(name); if (units != null) { atts.addAttribute(new Attribute(CDM.UNITS, units)); } if (desc != null) { atts.addAttribute(new Attribute(CDM.LONG_NAME, desc)); } } VariableSimpleBuilder(String name, String desc, String units, DataType dt, List<Dimension> dims); static VariableSimpleBuilder fromMember(StructureMembers.Member m); static VariableSimpleBuilder makeScalar(String name, String desc, String units, DataType dt); static VariableSimpleBuilder makeString(String name, String desc, String units, int str_len); VariableSimpleBuilder addAttribute(Attribute att); VariableSimpleBuilder addAttribute(String name, String value); VariableSimpleIF build();  }