Skip to content

Commit

Permalink
Poll equality
Browse files Browse the repository at this point in the history
  • Loading branch information
JSnipes29 committed Jan 26, 2024
1 parent 0714682 commit d560f0f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
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
}


}

0 comments on commit d560f0f

Please sign in to comment.