Example usage for com.google.common.collect ImmutableListMultimap copyOf

List of usage examples for com.google.common.collect ImmutableListMultimap copyOf

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableListMultimap copyOf.

Prototype

@Beta
public static <K, V> ImmutableListMultimap<K, V> copyOf(
        Iterable<? extends Entry<? extends K, ? extends V>> entries) 

Source Link

Document

Returns an immutable multimap containing the specified entries.

Usage

From source file:org.dishevelled.bio.variant.vcf.header.VcfContigHeaderLine.java

/**
 * Create a new VCF contig header line./*w  ww.jav  a2s.  co  m*/
 *
 * @param id header line ID, must not be null
 * @param length contig header line length, if any
 * @param md5 contig header line md5, if any
 * @param url contig header line URL, if any
 * @param attributes header line attributes, must not be null
 */
VcfContigHeaderLine(final String id, final Long length, final String md5, final String url,
        final ListMultimap<String, String> attributes) {
    checkNotNull(id);
    checkNotNull(attributes);

    this.id = id;
    this.length = length;
    this.md5 = md5;
    this.url = url;
    this.attributes = ImmutableListMultimap.copyOf(attributes);
}

From source file:me.lucko.luckperms.common.caching.type.MetaCache.java

public void loadMeta(MetaAccumulator meta) {
    lock.writeLock().lock();//w w w. j av  a  2  s  .c o  m
    try {
        this.metaMultimap = ImmutableListMultimap.copyOf(meta.getMeta());

        //noinspection unchecked
        Map<String, List<String>> metaMap = (Map) this.metaMultimap.asMap();
        ImmutableMap.Builder<String, String> metaMapBuilder = ImmutableMap.builder();

        for (Map.Entry<String, List<String>> e : metaMap.entrySet()) {
            if (e.getValue().isEmpty()) {
                continue;
            }

            // take the value which was accumulated first
            metaMapBuilder.put(e.getKey(), e.getValue().get(0));
        }
        this.meta = metaMapBuilder.build();

        this.prefixes = ImmutableSortedMap.copyOfSorted(meta.getPrefixes());
        this.suffixes = ImmutableSortedMap.copyOfSorted(meta.getSuffixes());
        this.prefixStack = meta.getPrefixStack();
        this.suffixStack = meta.getSuffixStack();
    } finally {
        lock.writeLock().unlock();
    }
}

From source file:org.dishevelled.bio.variant.vcf.header.VcfMetaHeaderLine.java

/**
 * Create a new VCF META header line.//www  .java 2 s . c  o  m
 *
 * @param id header line ID, must not be null
 * @param number META header line number, if any
 * @param type META header line type, if any
 * @param attributes header line attributes, must not be null
 */
VcfMetaHeaderLine(final String id, final VcfHeaderLineNumber number, final VcfHeaderLineType type,
        final ListMultimap<String, String> attributes) {
    checkNotNull(id);
    checkNotNull(attributes);

    this.id = id;
    this.number = number;
    this.type = type;
    this.attributes = ImmutableListMultimap.copyOf(attributes);
}

From source file:org.dishevelled.bio.variant.vcf.header.VcfFormatHeaderLine.java

/**
 * Create a new VCF FORMAT header line./*from   ww w.j a  v a2s . c o  m*/
 *
 * @param id header line ID, must not be null
 * @param number FORMAT header line number, must not be null
 * @param type FORMAT header line type, must not be null
 * @param description header line description, must not be null
 * @param attributes header line attributes, must not be null
 */
VcfFormatHeaderLine(final String id, final VcfHeaderLineNumber number, final VcfHeaderLineType type,
        final String description, final ListMultimap<String, String> attributes) {
    checkNotNull(id);
    checkNotNull(number);
    checkNotNull(type);
    checkNotNull(description);
    checkNotNull(attributes);

    this.id = id;
    this.number = number;
    this.type = type;
    this.description = description;
    this.attributes = ImmutableListMultimap.copyOf(attributes);
}

From source file:com.github.rinde.logistics.pdptw.mas.comm.AuctionTimeStatsLogger.java

/**
 * @return A multimap of {@link Bidder}s to {@link SolverTimeMeasurement}s.
 *///from  w  ww . ja v a  2s  .c  o m
public ImmutableListMultimap<Bidder<?>, SolverTimeMeasurement> getTimeMeasurements() {
    final ListMultimap<Bidder<?>, SolverTimeMeasurement> map = ArrayListMultimap.create();
    for (final Bidder<DoubleBid> b : bidders) {
        if (b instanceof Measurable) {
            map.putAll(b, ((Measurable) b).getTimeMeasurements());
        }
    }
    return ImmutableListMultimap.copyOf(map);
}

From source file:com.bethzur.gcm4j.util.CopyOnWriteArrayListMultimap.java

private CopyOnWriteArrayListMultimap(Multimap<? extends K, ? extends V> multimap) {
    map = ImmutableListMultimap.copyOf(multimap);
    lock = new ReentrantLock();
}

From source file:org.xacml4j.v30.pdp.PolicySet.java

private PolicySet(Builder b) {
    super(b);/*w w  w  . ja va 2  s. c  o  m*/
    this.reference = PolicySetIDReference.builder(id).version(b.version).build();
    this.policySetDefaults = b.policyDefaults;
    Preconditions.checkNotNull(b.combiningAlgorithm, "Policy decision combining algorithm must be specified");
    this.combiningAlgorithm = b.combiningAlgorithm;
    this.decisionRules = b.policies.build();
    ImmutableMap.Builder<String, Multimap<String, CombinerParameter>> forPolicySets = ImmutableMap.builder();
    ImmutableMap.Builder<String, Multimap<String, CombinerParameter>> forPolicies = ImmutableMap.builder();
    for (Entry<String, Multimap<String, CombinerParameter>> e : b.policySetCombinerParams.entrySet()) {
        forPolicySets.put(e.getKey(), ImmutableListMultimap.copyOf(e.getValue()));
    }
    for (Entry<String, Multimap<String, CombinerParameter>> e : b.policyCombinerParams.entrySet()) {
        forPolicies.put(e.getKey(), ImmutableListMultimap.copyOf(e.getValue()));
    }
    this.policySetCombinerParameters = forPolicySets.build();
    this.policyCombinerParameters = forPolicies.build();

}

From source file:org.grouplens.grapht.solver.RuleBasedBindingFunction.java

public RuleBasedBindingFunction(Multimap<ContextMatcher, BindRule> rules) {
    Preconditions.notNull("rules", rules);

    this.rules = ImmutableListMultimap.copyOf(rules);
}

From source file:org.xacml4j.v30.pdp.Policy.java

private Policy(Builder b) {
    super(b);/*from   ww w.  ja  va 2  s  . c om*/
    Preconditions.checkNotNull(b.combiningAlgorithm, "Rule decision combining algorithm must be specified");
    this.combiningAlgorithm = b.combiningAlgorithm;
    this.policyDefaults = b.policyDefaults;
    this.reference = PolicyIDReference.builder(b.id).version(b.version).build();
    this.rules = b.rules.build();
    this.variableDefinitions = Maps.uniqueIndex(b.variables, new Function<VariableDefinition, String>() {
        @Override
        public String apply(VariableDefinition from) {
            return from.getVariableId();
        }
    });
    this.ruleCombiningParameters = Maps.newHashMap();
    for (Entry<String, Multimap<String, CombinerParameter>> p : b.ruleCombinerParameters.entrySet()) {
        ruleCombiningParameters.put(p.getKey(), ImmutableListMultimap.copyOf(p.getValue()));
    }
}

From source file:org.seedstack.business.internal.event.EventPlugin.java

@Override
public Object nativeUnitModule() {
    return new EventModule(ImmutableListMultimap.copyOf(eventHandlersByEvent),
            ImmutableList.copyOf(eventHandlerClasses), watchRepo);
}