Skip to content

Commit

Permalink
remove manual hashCode and equals from models
Browse files Browse the repository at this point in the history
  • Loading branch information
luca committed Nov 27, 2019
1 parent 0d2bfa9 commit 5326e64
Show file tree
Hide file tree
Showing 16 changed files with 14 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,4 @@ data class ArticleAttachment(
fun getCharset(): String? {
return preferences["Charset"] as String?
}

override fun hashCode(): Int = id
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as ArticleAttachment

if (id != other.id) return false

return true
}
}
15 changes: 1 addition & 14 deletions lib/src/main/java/com/kirkbushman/zammad/models/Group.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,4 @@ data class Group(
@Json(name = "users")
val users: List<String>?

) : Parcelable, Identifiable, Creatable, Updatable {

override fun hashCode() = id
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as Group

if (id != other.id) return false

return true
}
}
) : Parcelable, Identifiable, Creatable, Updatable
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,7 @@ data class OnlineNotification(
@Json(name = "created_by_id")
override val createdById: Int

) : Parcelable, Identifiable, Creatable, Updatable {

override fun hashCode(): Int = id
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as OnlineNotification

if (id != other.id) return false

return true
}
}
) : Parcelable, Identifiable, Creatable, Updatable

enum class NotificationType(val typeStr: String) {

Expand Down
18 changes: 1 addition & 17 deletions lib/src/main/java/com/kirkbushman/zammad/models/Organization.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,4 @@ data class Organization(
@Json(name = "members")
val members: List<String>?

) : Parcelable, Identifiable, Creatable, Updatable {

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as Organization

if (id != other.id) return false

return true
}

override fun hashCode(): Int {
return id.hashCode()
}
}
) : Parcelable, Identifiable, Creatable, Updatable
15 changes: 1 addition & 14 deletions lib/src/main/java/com/kirkbushman/zammad/models/Overview.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,7 @@ data class Overview(
@Json(name = "users")
val users: List<String>?

) : Parcelable, Identifiable, Creatable, Updatable {

override fun hashCode(): Int = id
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as Overview

if (id != other.id) return false

return true
}
}
) : Parcelable, Identifiable, Creatable, Updatable

@JsonClass(generateAdapter = true)
@Parcelize
Expand Down
15 changes: 1 addition & 14 deletions lib/src/main/java/com/kirkbushman/zammad/models/Role.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,4 @@ data class Role(
@Json(name = "permission_ids")
val permissionIds: List<Int>

) : Parcelable, Identifiable, Creatable, Updatable {

override fun hashCode(): Int = id
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as Role

if (id != other.id) return false

return true
}
}
) : Parcelable, Identifiable, Creatable, Updatable
15 changes: 1 addition & 14 deletions lib/src/main/java/com/kirkbushman/zammad/models/Tag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,4 @@ data class Tag(
@Json(name = "count")
val count: Int

) : Parcelable, Identifiable {

override fun hashCode(): Int = id
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as Tag

if (id != other.id) return false

return true
}
}
) : Parcelable, Identifiable
15 changes: 1 addition & 14 deletions lib/src/main/java/com/kirkbushman/zammad/models/Ticket.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,4 @@ data class Ticket(
@Json(name = "updated_by")
override val updatedBy: String?

) : Parcelable, Identifiable, Creatable, Updatable {

override fun hashCode() = id.hashCode()
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as Ticket

if (id != other.id) return false

return true
}
}
) : Parcelable, Identifiable, Creatable, Updatable
12 changes: 0 additions & 12 deletions lib/src/main/java/com/kirkbushman/zammad/models/TicketArticle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,6 @@ data class TicketArticle(

) : Parcelable, Identifiable, Creatable, Updatable {

override fun hashCode(): Int = id
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as TicketArticle

if (id != other.id) return false

return true
}

fun hasAttachments(): Boolean {
return attachments.isNotEmpty()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,4 @@ data class TicketPriority(
@Json(name = "updated_by")
override val updatedBy: String?

) : Parcelable, Identifiable, Creatable, Updatable {

override fun hashCode(): Int = id
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as TicketPriority

if (id != other.id) return false

return true
}
}
) : Parcelable, Identifiable, Creatable, Updatable
15 changes: 1 addition & 14 deletions lib/src/main/java/com/kirkbushman/zammad/models/TicketState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,4 @@ data class TicketState(
@Json(name = "updated_by")
override val updatedBy: String?

) : Parcelable, Identifiable, Creatable, Updatable {

override fun hashCode() = id.hashCode()
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as TicketState

if (id != other.id) return false

return true
}
}
) : Parcelable, Identifiable, Creatable, Updatable
15 changes: 1 addition & 14 deletions lib/src/main/java/com/kirkbushman/zammad/models/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,4 @@ data class User(
@Json(name = "authorizations")
val authorizations: List<String>?

) : Parcelable, Identifiable, Creatable, Updatable {

override fun hashCode() = id.hashCode()
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as User

if (id != other.id) return false

return true
}
}
) : Parcelable, Identifiable, Creatable, Updatable
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ class ObjectActivity : AppCompatActivity() {
object_text.text = newObject.toString()
})
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ class ObjectsActivity : AppCompatActivity() {
controller.setObjects(objects)
})
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ class ObjectsController(private val callback: OnClickCallback) : EpoxyController
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ class ObjectHolder : KotlinHolder() {
val objectDisplay by bind<TextView>(R.id.object_display)
val objectDataType by bind<TextView>(R.id.object_data_type)
val objectObject by bind<TextView>(R.id.object_object)
}
}

0 comments on commit 5326e64

Please sign in to comment.