Example usage for com.google.common.collect ArrayListMultimap create

List of usage examples for com.google.common.collect ArrayListMultimap create

Introduction

In this page you can find the example usage for com.google.common.collect ArrayListMultimap create.

Prototype

public static <K, V> ArrayListMultimap<K, V> create(Multimap<? extends K, ? extends V> multimap) 

Source Link

Document

Constructs an ArrayListMultimap with the same mappings as the specified multimap.

Usage

From source file:eu.esdihumboldt.hale.common.align.model.functions.merge.MergeMigrator.java

@Override
public MutableCell updateCell(Cell originalCell, AlignmentMigration migration, MigrationOptions options,
        SimpleLog log) {//from w w  w .java 2 s  .c  o  m
    MutableCell result = super.updateCell(originalCell, migration, options, log);
    SimpleLog cellLog = SimpleLog.all(log, new CellLog(result, CELL_LOG_CATEGORY));

    if (options.updateSource() && originalCell.getSource() != null) {
        Entity sourceType = CellUtil.getFirstEntity(originalCell.getSource());
        if (sourceType != null) {
            TypeDefinition sourceDef = sourceType.getDefinition().getType();

            ListMultimap<String, ParameterValue> modParams = ArrayListMultimap
                    .create(result.getTransformationParameters());

            for (String property : PROPERTY_PATH_PARAMETERS) {
                updateProperties(modParams, migration, sourceDef, property, cellLog);
            }

            result.setTransformationParameters(modParams);
        }
    }

    return result;
}

From source file:fr.ens.biologie.genomique.eoulsan.data.protocols.DataProtocolService.java

@Override
public ListMultimap<String, String> getServiceClasses() {

    final ListMultimap<String, String> result = ArrayListMultimap.create(super.getServiceClasses());

    result.put(this.defaultProtocolName, this.defaultProtocol.getClass().getName());

    return Multimaps.unmodifiableListMultimap(result);
}

From source file:com.google.copybara.transform.TemplateTokens.java

TemplateTokens(Location location, String template, Map<String, Pattern> regexGroups, boolean repeatedGroups)
        throws EvalException {
    this.location = location;
    this.template = Preconditions.checkNotNull(template);

    Builder builder = new Builder();
    builder.location = location;//from   w  w  w.  j a v  a  2  s .  c  o  m
    builder.parse(template);
    this.before = builder.buildBefore(regexGroups, repeatedGroups);
    this.groupIndexes = ArrayListMultimap.create(builder.groupIndexes);
    this.tokens = ImmutableList.copyOf(builder.tokens);
    this.unusedGroups = Sets.difference(regexGroups.keySet(), groupIndexes.keySet());
}

From source file:com.isotrol.impe3.core.engine.ImmutableRenderContext.java

public URI getSamePageURI(Set<String> remove, Multimap<String, ?> parameters) {
    final UriBuilder b = UriBuilder.fromUri("");
    if (remove == null || remove.isEmpty()) {
        return getSamePageURI(parameters);
    }//  ww w  . j  a  v a2s  .  c o m
    final Multimap<String, ?> qp = ArrayListMultimap.create(query);
    for (String r : remove) {
        qp.removeAll(r);
    }
    URIs.queryParameters(b, qp);
    URIs.queryParameters(b, parameters);
    return b.build();
}

From source file:com.continuuity.loom.scheduler.dag.TaskDag.java

/**
 * Linearize the DAG into a list of stages, where each stage is a set of tasks that can be executed in parallel, and
 * where each task in a stage can only be executed once all the tasks in the previous stage have successfully
 * completed./*  ww  w  .j  a v a  2 s  .c om*/
 *
 * @return a list of set of actions that can be performed in order satisfying the dependencies.
 * The actions in each set can be run in parallel.
 */
public List<Set<TaskNode>> linearize() {
    LOG.trace("Initial graph - {}", edges);

    List<Set<TaskNode>> linearizedNodes = Lists.newArrayList();
    ArrayListMultimap<TaskNode, TaskNode> copyEdges = ArrayListMultimap.create(edges);

    // nodes that have no edges are sources.  The initial set is actual nodes - edges.values(), but removal of
    // edges.values() happens right away in the loop so just setting it to nodes right here.
    Set<TaskNode> sources = Sets.newHashSet(nodes);
    Set<TaskNode> sinkNodes = Sets.newHashSet();
    do {
        sources.addAll(copyEdges.keySet());
        sources.removeAll(copyEdges.values());

        LOG.trace("SinkNodes - {}", sinkNodes);
        LOG.trace("Sources - {}", sources);
        if (sources.isEmpty()) {
            throw new IllegalStateException("No source nodes found, DAG not serializable");
        }

        Set<TaskNode> stageNodes = Sets.newHashSet(Iterables.concat(sinkNodes, sources));
        LOG.trace("Stage Nodes - {}", stageNodes);
        linearizedNodes.add(stageNodes);

        // Determine sink nodes if any
        sinkNodes.clear();
        Set<TaskNode> toNodes = Sets.newHashSet();
        for (TaskNode fromNode : sources) {
            toNodes.addAll(copyEdges.removeAll(fromNode));
        }

        // If the node is not a source, or a destination of any other source then they are sink nodes.
        toNodes.removeAll(copyEdges.keySet());
        toNodes.removeAll(copyEdges.values());
        if (!toNodes.isEmpty()) {
            sinkNodes.addAll(toNodes);
        }
        sources.clear();
    } while (!copyEdges.isEmpty());

    // Add final nodes
    LOG.trace("Final nodes - {}", sinkNodes);
    if (!sinkNodes.isEmpty()) {
        linearizedNodes.add(sinkNodes);
    }

    return linearizedNodes;
}

From source file:eu.esdihumboldt.hale.adv.merge.AdVMeasurementMigrator.java

@Override
protected void mergeSource(MutableCell cell, String sourceName, EntityDefinition source, Cell match,
        Cell originalCell, SimpleLog log, Void context, AlignmentMigration migration, MergeIndex mergeIndex) {

    if (AssignFunction.ID_BOUND.equals(match.getTransformationIdentifier())) {
        // get value used in bound assign
        String value = CellUtil.getFirstParameter(match, AssignFunction.PARAMETER_VALUE).as(String.class);

        // convert value according to custom function
        value = convertCode(value, log);

        // configure cell
        cell.setTransformationIdentifier(AssignFunction.ID_BOUND);
        cell.setSource(ArrayListMultimap.create(match.getSource()));
        ListMultimap<String, ParameterValue> params = ArrayListMultimap.create();
        params.put(AssignFunction.PARAMETER_VALUE, new ParameterValue(value));
        cell.setTransformationParameters(params);

        return;/*w  ww  .  j a  v a  2s  . c o  m*/
    }

    super.mergeSource(cell, sourceName, source, match, originalCell, log, context, migration, mergeIndex);
}

From source file:net.pterodactylus.sonitus.data.Pipeline.java

/**
 * Creates a new pipeline./*from   ww  w  .j  ava  2  s  . c  o  m*/
 *
 * @param source
 *       The source of the audio stream
 * @param filters
 *       The filters for each source
 */
private Pipeline(Filter source, Multimap<Filter, Filter> filters) {
    this.source = Preconditions.checkNotNull(source, "source must not be null");
    this.filters = ArrayListMultimap.create(Preconditions.checkNotNull(filters, "filters must not be null"));
}

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

/**
 * Parse the specified value into a VCF ALT header line.
 *
 * @param value value, must not be null/* w  ww . ja v a  2 s . co  m*/
 * @return the specified value parsed into a VCF ALT header line
 */
public static VcfAltHeaderLine valueOf(final String value) {
    checkNotNull(value);
    checkArgument(value.startsWith("##ALT="));
    ListMultimap<String, String> entries = VcfHeaderLineParser.parseEntries(value.replace("##ALT=", ""));

    String id = VcfHeaderLineParser.requiredString("ID", entries);
    String description = VcfHeaderLineParser.requiredString("Description", entries);

    ListMultimap<String, String> attributes = ArrayListMultimap.create(entries);
    attributes.removeAll("ID");
    attributes.removeAll("Description");

    return new VcfAltHeaderLine(id, description, attributes);
}

From source file:io.helixservice.core.feature.AbstractFeature.java

/**
 * Returns a map of registered components owned by this feature
 *
 * @return The map of components, where key is the component type name.
 *///from w  ww. j ava  2  s . co  m
public Multimap<String, Component> getComponentMap() {
    return ArrayListMultimap.create(componentsMap);
}

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

/**
 * Parse the specified value into a VCF FILTER header line.
 *
 * @param value value, must not be null//from   w  w w. j a va2s  .  c o m
 * @return the specified value parsed into a VCF FILTER header line
 */
public static VcfFilterHeaderLine valueOf(final String value) {
    checkNotNull(value);
    checkArgument(value.startsWith("##FILTER="));
    ListMultimap<String, String> entries = VcfHeaderLineParser.parseEntries(value.replace("##FILTER=", ""));

    String id = VcfHeaderLineParser.requiredString("ID", entries);
    String description = VcfHeaderLineParser.requiredString("Description", entries);

    ListMultimap<String, String> attributes = ArrayListMultimap.create(entries);
    attributes.removeAll("ID");
    attributes.removeAll("Description");

    return new VcfFilterHeaderLine(id, description, attributes);
}