BEGIN_PUBLIC
Implement isEqual for j2objc protobuf enums

- It needs to be based on getNumber(), as there might be aliases.
- This means it can't be pushed up to JavaLangEnum
- ComGoogleProtobufProtocolMessageEnum seems to be an interface, so I think that wouldn't work either.
- I am happy to gate this by the "generateProperties" case if you think code size is a concern here.
END_PUBLIC

PiperOrigin-RevId: 796857657
diff --git a/protobuf/compiler/src/google/protobuf/compiler/j2objc/j2objc_enum.cc b/protobuf/compiler/src/google/protobuf/compiler/j2objc/j2objc_enum.cc
index 91924ec..178ed6b 100644
--- a/protobuf/compiler/src/google/protobuf/compiler/j2objc/j2objc_enum.cc
+++ b/protobuf/compiler/src/google/protobuf/compiler/j2objc/j2objc_enum.cc
@@ -177,7 +177,9 @@
       CValuePreprocessorName(descriptor_));
 
   if (IsGenerateProperties(descriptor_->file())) {
-    printer->Print("- ($valuepreprocessorname$)number;\n",
+    printer->Print(
+        "- (BOOL)isEqual:(_Nullable id)other;\n"
+        "- ($valuepreprocessorname$)number;\n",
                    "valuepreprocessorname",
                    CValuePreprocessorName(descriptor_));
   }
@@ -328,6 +330,12 @@
       "is_closed", SimpleItoa(descriptor_->is_closed()));
 
   if (IsGenerateProperties(descriptor_->file())) {
+      printer->Print(
+      "- (BOOL)isEqual:(_Nullable id)other {\n"
+      "  return [self class] == [other class]\n"
+      "      && [self getNumber] == [(($classname$ *)other) getNumber];\n"
+      "}\n",
+      "classname", ClassName(descriptor_));
     for (int i = 0; i < canonical_values_.size(); i++) {
       printer->Print(
           "+ ($classname$ *) $name$ {\n"