Skip to content

Instantly share code, notes, and snippets.

@ChanSek
Created May 19, 2017 14:04
Show Gist options
  • Save ChanSek/0ac90d29a8d53cb47a4413454ebdad9b to your computer and use it in GitHub Desktop.
Save ChanSek/0ac90d29a8d53cb47a4413454ebdad9b to your computer and use it in GitHub Desktop.
Java sample User class for migrating to Kotlin
public class User {
private String userId;
private String email;
private String userName;
private String name;
private String phNumber;
private String country;
private String profilePic;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhNumber() {
return phNumber;
}
public void setPhNumber(String phNumber) {
this.phNumber = phNumber;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getProfilePic() {
return profilePic;
}
public void setProfilePic(String profilePic) {
this.profilePic = profilePic;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UserSample that = (UserSample) o;
if (userId != null ? !userId.equals(that.userId) : that.userId != null) return false;
if (email != null ? !email.equals(that.email) : that.email != null) return false;
if (userName != null ? !userName.equals(that.userName) : that.userName != null)
return false;
if (name != null ? !name.equals(that.name) : that.name != null) return false;
if (phNumber != null ? !phNumber.equals(that.phNumber) : that.phNumber != null)
return false;
if (country != null ? !country.equals(that.country) : that.country != null) return false;
return profilePic != null ? profilePic.equals(that.profilePic) : that.profilePic == null;
}
@Override
public int hashCode() {
int result = userId != null ? userId.hashCode() : 0;
result = 31 * result + (email != null ? email.hashCode() : 0);
result = 31 * result + (userName != null ? userName.hashCode() : 0);
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (phNumber != null ? phNumber.hashCode() : 0);
result = 31 * result + (country != null ? country.hashCode() : 0);
result = 31 * result + (profilePic != null ? profilePic.hashCode() : 0);
return result;
}
@Override
public String toString() {
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