Add proper `hashCode`/`equals` to `CppModuleMap`.
RELNOTES: None.
@@ -62,6 +62,28 @@ public final class CppModuleMap {
return umbrellaHeader;
}
+ @Override
+ public int hashCode() {
+ // It would be incorrect for two CppModuleMap instances in the same build graph to have the same
+ // artifact but different names or umbrella headers. Since Artifacts' hash codes are cached, use
+ // only it for efficiency.
+ return artifact.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (other instanceof CppModuleMap) {
+ CppModuleMap that = (CppModuleMap) other;
+ return artifact.equals(that.artifact)
+ && umbrellaHeader.equals(that.umbrellaHeader)
+ && name.equals(that.name);
+ }
+ return false;
+ }
+
@Override
public String toString() {
return name + "@" + artifact;
