@Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Struct other = (Struct) obj;
        if (schema != other.schema)
            return false;
        for (int i = 0; i < this.values.length; i++) {
            BoundField f = this.schema.get(i);
            boolean result;
            if (f.def.type.isArray()) {
                result = Arrays.equals((Object[]) this.get(f), (Object[]) other.get(f));
            } else {
                Object thisField = this.get(f);
                Object otherField = other.get(f);
                result = Objects.equals(thisField, otherField);
            }
            if (!result)
                return false;
        }
        return true;
    }
@Test
    public void testEquals() {
        Struct struct1 = new Struct(FLAT_STRUCT_SCHEMA)
                .set("int8", (byte) 12)
                .set("int16", (short) 12)
                .set("int32", 12)
                .set("int64", (long) 12)
                .set("boolean", true)
                .set("float64", 0.5)
                .set("string", "foobar");
        Struct struct2 = new Struct(FLAT_STRUCT_SCHEMA)
                .set("int8", (byte) 12)
                .set("int16", (short) 12)
                .set("int32", 12)
                .set("int64", (long) 12)
                .set("boolean", true)
                .set("float64", 0.5)
                .set("string", "foobar");
        Struct struct3 = new Struct(FLAT_STRUCT_SCHEMA)
                .set("int8", (byte) 12)
                .set("int16", (short) 12)
                .set("int32", 12)
                .set("int64", (long) 12)
                .set("boolean", true)
                .set("float64", 0.5)
                .set("string", "mismatching string");

        assertEquals(struct1, struct2);
        assertNotEquals(struct1, struct3);

        Object[] array = {(byte) 1, (byte) 2};
        struct1 = new Struct(NESTED_SCHEMA)
                .set("array", array)
                .set("nested", new Struct(NESTED_CHILD_SCHEMA).set("int8", (byte) 12));
        Object[] array2 = {(byte) 1, (byte) 2};
        struct2 = new Struct(NESTED_SCHEMA)
                .set("array", array2)
                .set("nested", new Struct(NESTED_CHILD_SCHEMA).set("int8", (byte) 12));
        Object[] array3 = {(byte) 1, (byte) 2, (byte) 3};
        struct3 = new Struct(NESTED_SCHEMA)
                .set("array", array3)
                .set("nested", new Struct(NESTED_CHILD_SCHEMA).set("int8", (byte) 13));

        assertEquals(struct1, struct2);
        assertNotEquals(struct1, struct3);
    }