@JavaDerive(equals=true)

@JavaDerive(equals=true) on a parcelable or an union produces equals and
hashCode implementations for the Java backend.

equals is implemented by calling Objects.deepEquals for each pairs of
the two objects.

hashCode is implemented by converting the fields into Object[] and pass
it to Objects.deepHashCode.

Bug: 161442291
Test: aidl_unittests
Test: atest aidl_integration_test
Change-Id: I28edd08a9ca49cc2883cbc225358796785beed73
diff --git a/aidl_language.cpp b/aidl_language.cpp
index a7b8645..38af0bc 100644
--- a/aidl_language.cpp
+++ b/aidl_language.cpp
@@ -126,7 +126,11 @@
       {AidlAnnotation::Type::HIDE, "Hide", {}, false},
       {AidlAnnotation::Type::BACKING, "Backing", {{"type", "String"}}, false},
       {AidlAnnotation::Type::JAVA_PASSTHROUGH, "JavaPassthrough", {{"annotation", "String"}}, true},
-      {AidlAnnotation::Type::JAVA_DERIVE, "JavaDerive", {{"toString", "boolean"}}, false},
+      {AidlAnnotation::Type::JAVA_DERIVE,
+        "JavaDerive",
+        {{"toString", "boolean"},
+          {"equals", "boolean"}},
+        false},
       {AidlAnnotation::Type::JAVA_ONLY_IMMUTABLE, "JavaOnlyImmutable", {}, false},
       {AidlAnnotation::Type::FIXED_SIZE, "FixedSize", {}, false},
       {AidlAnnotation::Type::DESCRIPTOR, "Descriptor", {{"value", "String"}}, false},