Skip to content

Commit

Permalink
equals/hashcode
Browse files Browse the repository at this point in the history
  • Loading branch information
salaboy committed Jun 11, 2024
1 parent 9d2954c commit 564217f
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
20 changes: 20 additions & 0 deletions sdk/src/main/java/io/dapr/client/domain/ComponentMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

package io.dapr.client.domain;

import java.util.Objects;

/**
* ComponentMetadata describes a Dapr Component.
*/
Expand Down Expand Up @@ -50,4 +52,22 @@ public String getVersion() {
return version;
}

@Override
public int hashCode() {
return Objects.hash(name, type, version);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ComponentMetadata other = (ComponentMetadata) obj;
return Objects.equals(name, other.name) && Objects.equals(type, other.type)
&& Objects.equals(version, other.version);
}

}
20 changes: 20 additions & 0 deletions sdk/src/main/java/io/dapr/client/domain/DaprMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
* DaprMetadata describes the Dapr Metadata.
Expand Down Expand Up @@ -61,4 +62,23 @@ public List<SubscriptionMetadata> getSubscriptions() {
return subscriptions;
}

@Override
public int hashCode() {
return Objects.hash(id, runtimeVersion, components, subscriptions);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
DaprMetadata other = (DaprMetadata) obj;
return Objects.equals(id, other.id) && Objects.equals(runtimeVersion, other.runtimeVersion)
&& Objects.equals(components, other.components) && Objects.equals(subscriptions, other.subscriptions);
}


}
21 changes: 21 additions & 0 deletions sdk/src/main/java/io/dapr/client/domain/RuleMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

package io.dapr.client.domain;

import java.util.Objects;

/**
* RuleMetadata describes the Subscription Rule's Metadata.
*/
Expand All @@ -30,4 +32,23 @@ public String getPath() {
return path;
}

@Override
public int hashCode() {
return Objects.hash(path);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
RuleMetadata other = (RuleMetadata) obj;
return Objects.equals(path, other.path);
}



}
20 changes: 20 additions & 0 deletions sdk/src/main/java/io/dapr/client/domain/SubscriptionMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
* SubscriptionMetadata describes the Subscription Metadata.
Expand Down Expand Up @@ -61,5 +62,24 @@ public List<RuleMetadata> getRules() {
return rules;
}

@Override
public int hashCode() {
return Objects.hash(topic, pubsubname, deadLetterTopic, rules);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SubscriptionMetadata other = (SubscriptionMetadata) obj;
return Objects.equals(topic, other.topic) && Objects.equals(pubsubname, other.pubsubname)
&& Objects.equals(deadLetterTopic, other.deadLetterTopic) && Objects.equals(rules, other.rules);
}



}

0 comments on commit 564217f

Please sign in to comment.