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

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

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

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);
    }
}