StructDefinitionType extends UnqualifiedType { public int getFieldIndex(String fieldToRemove) { if (!fieldNames.contains(fieldToRemove)) { throw new IllegalArgumentException(unknownFieldMessage(fieldToRemove)); } return fieldNames.indexOf(fieldToRemove); } 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();  }
@Test public void getFieldIndex() { StructDefinitionType t = new StructDefinitionType(new StructNameType("astruct"), Arrays.asList("x", "y"), Arrays.asList(BasicType.VEC4, BasicType.IVEC3)); assertEquals(0, t.getFieldIndex("x")); assertEquals(1, t.getFieldIndex("y")); }
@Test(expected = IllegalArgumentException.class) public void getFieldIndex2() { StructDefinitionType t = new StructDefinitionType(new StructNameType("astruct"), Arrays.asList("x", "y"), Arrays.asList(BasicType.VEC4, BasicType.IVEC3)); t.getFieldIndex("z"); }