package pl.komunikator.komunikator.entity;

import java.util.Date;

import io.realm.RealmList;
import io.realm.RealmObject;
import io.realm.annotations.Ignore;
import io.realm.annotations.PrimaryKey;

/**
 * Created by Tenek on 11.04.2017.
 */

public class User extends RealmObject {
    @Ignore
    private static User instance = null;
    @PrimaryKey
    private Long id;
    private String username;
    private String password;
    private Date birthDate;
    private Long latitude;
    private Long Longitude;
    private RealmList<Conversation> conversations;
    private String email;

    public RealmList<User> friends;

    public static User getLoggedUser() {
        return instance;
    }

    public static void setLoggedUser(User user) {
        instance = user;
    }

    public static void logout() {
        instance = null;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Date getBirthDate() {
        return birthDate;
    }

    public void setBirthDate(Date birthDate) {
        this.birthDate = birthDate;
    }

    public Long getLatitude() {
        return latitude;
    }

    public void setLatitude(Long latitude) {
        this.latitude = latitude;
    }

    public Long getLongitude() {
        return Longitude;
    }

    public void setLongitude(Long longitude) {
        Longitude = longitude;
    }

    public RealmList<Conversation> getConversations() {
        return conversations;
    }

    public void setConversations(RealmList<Conversation> conversations) {
        this.conversations = conversations;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }
}
@@ -37,16 +37,60 @@
 ntity;%0A%0A
+import android.support.annotation.NonNull;%0A%0A
 import j
@@ -320,16 +320,38 @@
 mObject 
+implements Comparable 
 %7B%0A    @I
@@ -2143,9 +2143,373 @@
 ;%0A    %7D%0A
+%0A    @Override%0A    public int compareTo(@NonNull Object o) %7B%0A        try %7B%0A            User user = (User) o;%0A            if (id %3C user.id) %7B%0A                return -1;%0A            %7D else if (id %3E user.id) %7B%0A                return 1;%0A            %7D else %7B%0A                return 0;%0A            %7D%0A        %7D catch (Exception e) %7B%0A            throw e;%0A        %7D%0A    %7D%0A%0A
 %7D

Make User class implement Comparable interface