StructDefinitionType extends UnqualifiedType { @Override public boolean equals(Object that) { if (this == that) { return true; } if (!(that instanceof StructDefinitionType)) { return false; } final StructDefinitionType thatStructDefinitionType = (StructDefinitionType) that; if (!this.structNameType.equals(thatStructDefinitionType.structNameType)) { return false; } if (hasStructNameType()) { assert equalFields(thatStructDefinitionType); return true; } return equalFields(thatStructDefinitionType); } 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 testEquals() { final StructDefinitionType t1 = new StructDefinitionType(new StructNameType("astruct"), Arrays.asList("x", "y"), Arrays.asList(BasicType.MAT4X4, BasicType.VEC4)); final StructDefinitionType t2 = new StructDefinitionType(new StructNameType("astruct"), Arrays.asList("x", "y"), Arrays.asList(BasicType.MAT4X4, BasicType.VEC4)); final StructDefinitionType t3 = new StructDefinitionType(new StructNameType("anotherstruct"), Arrays.asList("x", "y"), Arrays.asList(BasicType.MAT4X4, BasicType.VEC4)); final StructDefinitionType t4 = new StructDefinitionType(Optional.empty(), Arrays.asList("x", "y"), Arrays.asList(BasicType.MAT4X4, BasicType.VEC4)); final StructDefinitionType t5 = new StructDefinitionType(Optional.empty(), Arrays.asList("x", "y"), Arrays.asList(BasicType.MAT4X4, BasicType.VEC4)); final StructDefinitionType t6 = new StructDefinitionType(Optional.empty(), Arrays.asList("x", "y"), Arrays.asList(BasicType.MAT3X4, BasicType.VEC4)); assertEquals(t1, t2); assertEquals(t1.hashCode(), t2.hashCode()); assertEquals(t4, t5); assertEquals(t4.hashCode(), t5.hashCode()); assertNotEquals(t1, t3); assertNotEquals(t1, t4); assertNotEquals(t5, t6); }