package com.p3.bewoplaner.data.repository.specifications;

import com.p3.bewoplaner.data.repository.models.MessageRealm;

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

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

    private long mGroupId;
    private final long mUserId;

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

    public void setGroupId(long groupId) {
        mGroupId = groupId;
    }

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