Skip to content

Poll equality #596

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

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
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 @@ -47,6 +47,13 @@ class Poll {
@Expose
var isVisible : Boolean = false

override fun equals(other: Any?): Boolean {
return other is Poll && this.id == other.id && this.totalVotes == other.totalVotes
&& this.question == other.question && this.options.size == other.options.size
&& this.options.containsAll(other.options) && other.options.containsAll(this.options)
}


//@Expose
//var homeAdapter : HomeAdapter? = null

Expand All @@ -72,6 +79,21 @@ class Poll {
//gui?.notifyDataSetChanged()
}

override fun hashCode(): Int {
var result = id ?: 0
result = 31 * result + (clubCode?.hashCode() ?: 0)
result = 31 * result + (question?.hashCode() ?: 0)
result = 31 * result + (createdDate?.hashCode() ?: 0)
result = 31 * result + (startDate?.hashCode() ?: 0)
result = 31 * result + (expireDate?.hashCode() ?: 0)
result = 31 * result + multiselect.hashCode()
result = 31 * result + (clubComment?.hashCode() ?: 0)
result = 31 * result + options.hashCode()
result = 31 * result + totalVotes
result = 31 * result + isVisible.hashCode()
return result
}

// Device id + poll id -> hash -> id

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,20 @@ class PollOption {
var selected : Boolean = false

var isVisible : Boolean = false
override fun equals(other: Any?): Boolean {
return other is PollOption && this.choice == other.choice && this.id == other.id
&& this.voteCount == other.voteCount
}

override fun hashCode(): Int {
var result = id ?: 0
result = 31 * result + (poll ?: 0)
result = 31 * result + (choice?.hashCode() ?: 0)
result = 31 * result + voteCount
result = 31 * result + selected.hashCode()
result = 31 * result + isVisible.hashCode()
return result
}


}