All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.path.android.jobqueue.nonPersistentQueue.CountWithGroupIdsResult Maven / Gradle / Ivy

package com.path.android.jobqueue.nonPersistentQueue;

import java.util.Set;

public class CountWithGroupIdsResult {
    private int count;
    private Set groupIds;

    public CountWithGroupIdsResult(int count, Set groupIds) {
        this.count = count;
        this.groupIds = groupIds;
    }

    public int getCount() {
        return count;
    }

    //nullable
    public Set getGroupIds() {
        return groupIds;
    }

    public CountWithGroupIdsResult mergeWith(CountWithGroupIdsResult other) {
        if(groupIds == null || other.groupIds == null) {
            this.count += other.count;
            if(groupIds == null) {
                groupIds = other.groupIds;
            }
            return this;
        }
        //there are some groups, we need to find if any group is in both lists
        int sharedGroups = 0;
        for(String groupId : other.groupIds) {
            if(groupIds.add(groupId) == false) {
                sharedGroups ++;
            }
        }
        count = count + other.count - sharedGroups;
        return this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy