Skip to content

Commit

Permalink
Distribution.java correct equals method
Browse files Browse the repository at this point in the history
  • Loading branch information
lokendra005 committed Aug 13, 2024
1 parent a8de245 commit 36b790d
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,20 @@ default Expression[] children() {
/**
* Indicates whether some other object is "equal to" this one.
*
* @param distribution The reference distribution object with which to compare.
* @param obj The reference object with which to compare.
* @return returns true if this object is the same as the obj argument; false otherwise.
*/
default boolean equals(Distribution distribution) {
if (distribution == null) {
default boolean equals(Distribution obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}

return strategy().equals(distribution.strategy())
&& number() == distribution.number()
&& Arrays.equals(expressions(), distribution.expressions());

Distribution that = (Distribution) obj;
return number() == that.number()
&& strategy().equals(that.strategy())
&& Arrays.equals(expressions(), that.expressions());
}
}

0 comments on commit 36b790d

Please sign in to comment.