package de.beyondsoft.ownchat.data.repository.specifications;

import de.beyondsoft.ownchat.data.repository.models.MessageRealm;

import io.realm.Realm;
import io.realm.RealmQuery;

/**
 * Created by Rares Teodorescu on 22/02/2017.
 */
public class MessageByIdSpecification implements RealmSpecification<MessageRealm> {

    private String mMessageId;
    private long mUserId;

    public MessageByIdSpecification(long userId) {
        mUserId = userId;
    }

    public long getUserId() {
        return mUserId;
    }

    public void setMessageId(String messageId) {
        mMessageId = messageId;
    }

    @Override
    public RealmQuery<MessageRealm> toRealmQuery(Realm realm) {
        return realm.where(MessageRealm.class)
                .equalTo(MessageRealm.ID, mMessageId)
                .equalTo(MessageRealm.USER_ID, mUserId);
    }
}
