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

com.kolibrifx.plovercrest.server.internal.protocol.SubscriberEntryCollection Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2010-2017, KolibriFX AS. Licensed under the Apache License, version 2.0.
 */

package com.kolibrifx.plovercrest.server.internal.protocol;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class SubscriberEntryCollection {
    private final Map> entriesByTableIndex = new LinkedHashMap<>();

    public SubscriberEntry getLastEntry(final int tableIndex) {
        final List collection = entriesByTableIndex.get(tableIndex);
        if (collection == null) {
            return null;
        }
        assert !collection.isEmpty();
        return collection.get(collection.size() - 1);
    }

    public void add(final SubscriberEntry entry) {
        List collection = entriesByTableIndex.get(entry.subscriptionId);
        if (collection == null) {
            collection = new ArrayList<>();
            entriesByTableIndex.put(entry.subscriptionId, collection);
        }
        collection.add(entry);
    }

    public Map> getEntriesByTableIndex() {
        return entriesByTableIndex;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy