Commit f09d5d35 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito Committed by GitHub

Merge pull request #526 from estevanfick/develop

[FIX] Missing name field in Realm database.
parents 7d8390a7 1264e85d
package chat.rocket.persistence.realm.models.ddp; package chat.rocket.persistence.realm.models.ddp;
import java.util.ArrayList;
import java.util.List;
import chat.rocket.core.models.Email;
import chat.rocket.core.models.User;
import io.realm.Realm; import io.realm.Realm;
import io.realm.RealmList; import io.realm.RealmList;
import io.realm.RealmObject; import io.realm.RealmObject;
import io.realm.RealmQuery; import io.realm.RealmQuery;
import io.realm.annotations.PrimaryKey; import io.realm.annotations.PrimaryKey;
import java.util.ArrayList;
import java.util.List;
import chat.rocket.core.models.Email;
import chat.rocket.core.models.User;
/** /**
* RealmUser. * RealmUser.
*/ */
...@@ -19,6 +19,7 @@ import chat.rocket.core.models.User; ...@@ -19,6 +19,7 @@ import chat.rocket.core.models.User;
public class RealmUser extends RealmObject { public class RealmUser extends RealmObject {
public static final String ID = "_id"; public static final String ID = "_id";
public static final String NAME = "name";
public static final String USERNAME = "username"; public static final String USERNAME = "username";
public static final String STATUS = "status"; public static final String STATUS = "status";
public static final String UTC_OFFSET = "utcOffset"; public static final String UTC_OFFSET = "utcOffset";
...@@ -31,6 +32,7 @@ public class RealmUser extends RealmObject { ...@@ -31,6 +32,7 @@ public class RealmUser extends RealmObject {
public static final String STATUS_OFFLINE = "offline"; public static final String STATUS_OFFLINE = "offline";
@PrimaryKey private String _id; @PrimaryKey private String _id;
private String name;
private String username; private String username;
private String status; private String status;
private double utcOffset; private double utcOffset;
...@@ -57,6 +59,14 @@ public class RealmUser extends RealmObject { ...@@ -57,6 +59,14 @@ public class RealmUser extends RealmObject {
this.username = username; this.username = username;
} }
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getStatus() { public String getStatus() {
return status; return status;
} }
...@@ -96,6 +106,7 @@ public class RealmUser extends RealmObject { ...@@ -96,6 +106,7 @@ public class RealmUser extends RealmObject {
return User.builder() return User.builder()
.setId(_id) .setId(_id)
.setName(name)
.setUsername(username) .setUsername(username)
.setStatus(status) .setStatus(status)
.setUtcOffset(utcOffset) .setUtcOffset(utcOffset)
...@@ -108,6 +119,7 @@ public class RealmUser extends RealmObject { ...@@ -108,6 +119,7 @@ public class RealmUser extends RealmObject {
public String toString() { public String toString() {
return "RealmUser{" + return "RealmUser{" +
"_id='" + _id + '\'' + "_id='" + _id + '\'' +
", name='" + name + '\'' +
", username='" + username + '\'' + ", username='" + username + '\'' +
", status='" + status + '\'' + ", status='" + status + '\'' +
", utcOffset=" + utcOffset + ", utcOffset=" + utcOffset +
...@@ -133,6 +145,9 @@ public class RealmUser extends RealmObject { ...@@ -133,6 +145,9 @@ public class RealmUser extends RealmObject {
if (_id != null ? !_id.equals(user._id) : user._id != null) { if (_id != null ? !_id.equals(user._id) : user._id != null) {
return false; return false;
} }
if (name != null ? !name.equals(user.name) : user.name != null) {
return false;
}
if (username != null ? !username.equals(user.username) : user.username != null) { if (username != null ? !username.equals(user.username) : user.username != null) {
return false; return false;
} }
...@@ -151,6 +166,7 @@ public class RealmUser extends RealmObject { ...@@ -151,6 +166,7 @@ public class RealmUser extends RealmObject {
int result; int result;
long temp; long temp;
result = _id != null ? _id.hashCode() : 0; result = _id != null ? _id.hashCode() : 0;
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (username != null ? username.hashCode() : 0); result = 31 * result + (username != null ? username.hashCode() : 0);
result = 31 * result + (status != null ? status.hashCode() : 0); result = 31 * result + (status != null ? status.hashCode() : 0);
temp = Double.doubleToLongBits(utcOffset); temp = Double.doubleToLongBits(utcOffset);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment