@Test public void insertField() throws Exception { StructDefinitionType t = new StructDefinitionType(new StructNameType("temp"), Arrays.asList("a", "b"), Arrays.asList(BasicType.FLOAT, BasicType.FLOAT)); t.insertField(2, "c", BasicType.FLOAT); assertEquals(t.getNumFields(), 3); assertEquals("c", t.getFieldNames().get(2)); }
public void insertField(int index, String name, Type type) { if (index < 0 || index > fieldNames.size()) { throw new IndexOutOfBoundsException("Cannot insert field at index " + index + " when struct has " + fieldNames.size() + " fields"); } fieldNames.add(index, name); fieldTypes.add(index, type); }
StructDefinitionType extends UnqualifiedType { public void insertField(int index, String name, Type type) { if (index < 0 || index > fieldNames.size()) { throw new IndexOutOfBoundsException("Cannot insert field at index " + index + " when struct has " + fieldNames.size() + " fields"); } fieldNames.add(index, name); fieldTypes.add(index, type); } }
StructDefinitionType extends UnqualifiedType { public void insertField(int index, String name, Type type) { if (index < 0 || index > fieldNames.size()) { throw new IndexOutOfBoundsException("Cannot insert field at index " + index + " when struct has " + fieldNames.size() + " fields"); } fieldNames.add(index, name); fieldTypes.add(index, type); } StructDefinitionType(Optional<StructNameType> structNameType,
                               List<String> fieldNames,
                               List<Type> fieldTypes);  StructDefinitionType(StructNameType structNameType,
                              List<String> fieldNames,
                              List<Type> fieldTypes); }
StructDefinitionType extends UnqualifiedType { public void insertField(int index, String name, Type type) { if (index < 0 || index > fieldNames.size()) { throw new IndexOutOfBoundsException("Cannot insert field at index " + index + " when struct has " + fieldNames.size() + " fields"); } fieldNames.add(index, name); fieldTypes.add(index, type); } StructDefinitionType(Optional<StructNameType> structNameType,
                               List<String> fieldNames,
                               List<Type> fieldTypes);  StructDefinitionType(StructNameType structNameType,
                              List<String> fieldNames,
                              List<Type> fieldTypes); boolean hasStructNameType(); StructNameType getStructNameType(); List<String> getFieldNames(); List<Type> getFieldTypes(); Type getFieldType(String name); Type getFieldType(int index); String getFieldName(int index); int getNumFields(); void insertField(int index, String name, Type type); void removeField(String fieldToRemove); void setFieldName(int index, String fieldName); void setFieldType(int index, Type type); int getFieldIndex(String fieldToRemove); boolean hasField(String nameToCheck); @Override void accept(IAstVisitor visitor); @Override StructDefinitionType clone(); @Override boolean hasCanonicalConstant(Scope scope); @Override Expr getCanonicalConstant(Scope scope); @Override boolean equals(Object that); @Override int hashCode(); }
StructDefinitionType extends UnqualifiedType { public void insertField(int index, String name, Type type) { if (index < 0 || index > fieldNames.size()) { throw new IndexOutOfBoundsException("Cannot insert field at index " + index + " when struct has " + fieldNames.size() + " fields"); } fieldNames.add(index, name); fieldTypes.add(index, type); } StructDefinitionType(Optional<StructNameType> structNameType,
                               List<String> fieldNames,
                               List<Type> fieldTypes);  StructDefinitionType(StructNameType structNameType,
                              List<String> fieldNames,
                              List<Type> fieldTypes); boolean hasStructNameType(); StructNameType getStructNameType(); List<String> getFieldNames(); List<Type> getFieldTypes(); Type getFieldType(String name); Type getFieldType(int index); String getFieldName(int index); int getNumFields(); void insertField(int index, String name, Type type); void removeField(String fieldToRemove); void setFieldName(int index, String fieldName); void setFieldType(int index, Type type); int getFieldIndex(String fieldToRemove); boolean hasField(String nameToCheck); @Override void accept(IAstVisitor visitor); @Override StructDefinitionType clone(); @Override boolean hasCanonicalConstant(Scope scope); @Override Expr getCanonicalConstant(Scope scope); @Override boolean equals(Object that); @Override int hashCode();  }