Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#2286] Distribution.java correct equals method. #4507

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}
Loading