Skip to content

Instantly share code, notes, and snippets.

@ChanSek
Last active May 19, 2017 14:12
Show Gist options
  • Save ChanSek/bee7757d196f7162532a08ad30ce3c62 to your computer and use it in GitHub Desktop.
Save ChanSek/bee7757d196f7162532a08ad30ce3c62 to your computer and use it in GitHub Desktop.
User class after removing null
class User {
var userId: String = ""
var email: String = ""
var userName: String = ""
var name: String = ""
var phNumber: String = ""
var country: String = ""
var profilePic: String = ""
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other?.javaClass != javaClass) return false
other as UserSample
if (userId != other.userId) return false
if (email != other.email) return false
if (userName != other.userName) return false
if (name != other.name) return false
if (phNumber != other.phNumber) return false
if (country != other.country) return false
if (profilePic != other.profilePic) return false
return true
}
override fun hashCode(): Int {
var result = userId.hashCode()
result = 31 * result + email.hashCode()
result = 31 * result + userName.hashCode()
result = 31 * result + name.hashCode()
result = 31 * result + phNumber.hashCode()
result = 31 * result + country.hashCode()
result = 31 * result + profilePic.hashCode()
return result
}
override fun toString(): String {
return "UserSample{" +
"userId='" + userId + '\'' +
", email='" + email + '\'' +
", userName='" + userName + '\'' +
", name='" + name + '\'' +
", phNumber='" + phNumber + '\'' +
", country='" + country + '\'' +
", profilePic='" + profilePic + '\'' +
'}'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment