Skip to content

Commit 901209f

Browse files
committed
equals/hashcode
Signed-off-by: salaboy <[email protected]>
1 parent 9784961 commit 901209f

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed

sdk/src/main/java/io/dapr/client/domain/ComponentMetadata.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
package io.dapr.client.domain;
1515

16+
import java.util.Objects;
17+
1618
/**
1719
* ComponentMetadata describes a Dapr Component.
1820
*/
@@ -50,4 +52,22 @@ public String getVersion() {
5052
return version;
5153
}
5254

55+
@Override
56+
public int hashCode() {
57+
return Objects.hash(name, type, version);
58+
}
59+
60+
@Override
61+
public boolean equals(Object obj) {
62+
if (this == obj)
63+
return true;
64+
if (obj == null)
65+
return false;
66+
if (getClass() != obj.getClass())
67+
return false;
68+
ComponentMetadata other = (ComponentMetadata) obj;
69+
return Objects.equals(name, other.name) && Objects.equals(type, other.type)
70+
&& Objects.equals(version, other.version);
71+
}
72+
5373
}

sdk/src/main/java/io/dapr/client/domain/DaprMetadata.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import java.util.Collections;
1717
import java.util.List;
18+
import java.util.Objects;
1819

1920
/**
2021
* DaprMetadata describes the Dapr Metadata.
@@ -61,4 +62,23 @@ public List<SubscriptionMetadata> getSubscriptions() {
6162
return subscriptions;
6263
}
6364

65+
@Override
66+
public int hashCode() {
67+
return Objects.hash(id, runtimeVersion, components, subscriptions);
68+
}
69+
70+
@Override
71+
public boolean equals(Object obj) {
72+
if (this == obj)
73+
return true;
74+
if (obj == null)
75+
return false;
76+
if (getClass() != obj.getClass())
77+
return false;
78+
DaprMetadata other = (DaprMetadata) obj;
79+
return Objects.equals(id, other.id) && Objects.equals(runtimeVersion, other.runtimeVersion)
80+
&& Objects.equals(components, other.components) && Objects.equals(subscriptions, other.subscriptions);
81+
}
82+
83+
6484
}

sdk/src/main/java/io/dapr/client/domain/RuleMetadata.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
package io.dapr.client.domain;
1515

16+
import java.util.Objects;
17+
1618
/**
1719
* RuleMetadata describes the Subscription Rule's Metadata.
1820
*/
@@ -30,4 +32,23 @@ public String getPath() {
3032
return path;
3133
}
3234

35+
@Override
36+
public int hashCode() {
37+
return Objects.hash(path);
38+
}
39+
40+
@Override
41+
public boolean equals(Object obj) {
42+
if (this == obj)
43+
return true;
44+
if (obj == null)
45+
return false;
46+
if (getClass() != obj.getClass())
47+
return false;
48+
RuleMetadata other = (RuleMetadata) obj;
49+
return Objects.equals(path, other.path);
50+
}
51+
52+
53+
3354
}

sdk/src/main/java/io/dapr/client/domain/SubscriptionMetadata.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import java.util.Collections;
1717
import java.util.List;
18+
import java.util.Objects;
1819

1920
/**
2021
* SubscriptionMetadata describes the Subscription Metadata.
@@ -61,5 +62,24 @@ public List<RuleMetadata> getRules() {
6162
return rules;
6263
}
6364

65+
@Override
66+
public int hashCode() {
67+
return Objects.hash(topic, pubsubname, deadLetterTopic, rules);
68+
}
69+
70+
@Override
71+
public boolean equals(Object obj) {
72+
if (this == obj)
73+
return true;
74+
if (obj == null)
75+
return false;
76+
if (getClass() != obj.getClass())
77+
return false;
78+
SubscriptionMetadata other = (SubscriptionMetadata) obj;
79+
return Objects.equals(topic, other.topic) && Objects.equals(pubsubname, other.pubsubname)
80+
&& Objects.equals(deadLetterTopic, other.deadLetterTopic) && Objects.equals(rules, other.rules);
81+
}
82+
83+
6484

6585
}

0 commit comments

Comments
 (0)