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

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

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

/**
 * Created by imarneanu on 3/6/17.
 */
public class GroupByIdSpecification implements RealmSpecification<GroupRealm> {

    private long mGroupId;
    private final long mUserId;

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

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

    public long getUserId() {
        return mUserId;
    }

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