Skip to content

Commit

Permalink
Update equals to include typed bag parent
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdowling committed Nov 11, 2019
1 parent 6c44750 commit dea5176
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@ public String toString() {
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Symbol)) {
} else if (!(o instanceof Symbol)) {
return false;
}
Symbol symbol = (Symbol) o;
return Objects.equals(namespace, symbol.namespace)
return super.equals(o)
&& Objects.equals(namespace, symbol.namespace)
&& Objects.equals(namespaceDelimiter, symbol.namespaceDelimiter)
&& Objects.equals(name, symbol.name)
&& getProperties().equals(symbol.getProperties())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ public boolean equals(Object o) {
}

SymbolDependency that = (SymbolDependency) o;
return dependencyType.equals(that.dependencyType)
return super.equals(o)
&& dependencyType.equals(that.dependencyType)
&& packageName.equals(that.packageName)
&& version.equals(that.version);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ public boolean equals(Object o) {
}

SymbolReference that = (SymbolReference) o;
return symbol.equals(that.symbol)
return super.equals(o)
&& symbol.equals(that.symbol)
&& getProperties().equals(that.getProperties())
&& options.equals(that.options)
&& alias.equals(that.alias);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import software.amazon.smithy.utils.MapUtils;

Expand Down Expand Up @@ -97,6 +98,22 @@ public <T> T expectProperty(String name, Class<T> type) {
"Property `%s` is not part of %s, `%s`", name, getClass().getSimpleName(), this)));
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
} else if (!(o instanceof TypedPropertiesBag)) {
return false;
} else {
return properties.equals(((TypedPropertiesBag) o).properties);
}
}

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

/**
* Builds a SymbolReference.
*/
Expand Down

0 comments on commit dea5176

Please sign in to comment.