Example usage for com.google.common.collect Multimaps unmodifiableSortedSetMultimap

List of usage examples for com.google.common.collect Multimaps unmodifiableSortedSetMultimap

Introduction

In this page you can find the example usage for com.google.common.collect Multimaps unmodifiableSortedSetMultimap.

Prototype

public static <K, V> SortedSetMultimap<K, V> unmodifiableSortedSetMultimap(SortedSetMultimap<K, V> delegate) 

Source Link

Document

Returns an unmodifiable view of the specified SortedSetMultimap .

Usage

From source file:co.cask.cdap.common.zookeeper.coordination.ResourceAssignment.java

/**
 * Creates with the given assignment./* w  w  w. j  a v a 2s  .  co  m*/
 *
 * @param name Name of the resource.
 * @param assignments Set of assignments carries by this object.
 */
public ResourceAssignment(String name, Multimap<Discoverable, PartitionReplica> assignments) {
    this.name = name;

    TreeMultimap<Discoverable, PartitionReplica> multimap = TreeMultimap
            .create(DiscoverableComparator.COMPARATOR, PartitionReplica.COMPARATOR);
    multimap.putAll(assignments);
    this.assignments = Multimaps.unmodifiableSortedSetMultimap(multimap);
}

From source file:eu.interedition.collatex.util.VariantGraphRanking.java

public SortedSetMultimap<Integer, VariantGraph.Vertex> getByRank() {
    return Multimaps.unmodifiableSortedSetMultimap(byRank);
}

From source file:org.marketcetera.ors.OptionRootUnderlyingMap.java

/**
 * Loads the records from the file.//  w w w.j  ava2 s  .c o  m
 */
private void loadFromFile() {
    final String filename = mFilename;
    if (filename != null) {
        BufferedReader reader;
        Map<String, String> rootToUnderlying = null;
        SortedSetMultimap<String, String> underlyingToRoots = null;
        CloseableRegistry registry = new CloseableRegistry();
        try {
            reader = new BufferedReader(new UnicodeFileReader(filename));
            registry.register(reader);
            Set<String> includeTypes = new HashSet<String>(Arrays.asList(mIncludeTypes));
            String line, root, underlying, type;
            rootToUnderlying = new HashMap<String, String>();
            underlyingToRoots = TreeMultimap.create();
            while ((line = reader.readLine()) != null) {
                root = extract(line, ROOT_START_IDX, ROOT_END_IDX);
                underlying = extract(line, UNDERLYING_START_IDX, UNDERLYING_END_IDX);
                type = extract(line, TYPE_START_IDX, TYPE_END_IDX);
                if (root != null && underlying != null && type != null && includeTypes.contains(type)) {
                    rootToUnderlying.put(root, underlying);
                    underlyingToRoots.put(underlying, root);
                }
            }
        } catch (IOException e) {
            Messages.ORUM_LOG_ERROR_LOADING_FILE.error(this, e, filename);
        } finally {
            registry.close();
        }
        //Assign the values to volatile variables after the maps have been
        //initialized to prevent concurrency issues.
        mRootToUnderlying = rootToUnderlying == null ? null : Collections.unmodifiableMap(rootToUnderlying);
        mUnderlyingToRoots = underlyingToRoots == null ? null
                : Multimaps.unmodifiableSortedSetMultimap(underlyingToRoots).asMap();
    } else {
        Messages.ORUM_LOG_SKIP_LOAD_FILE.info(this);
    }
}