Example usage for com.google.common.collect Multimap asMap

List of usage examples for com.google.common.collect Multimap asMap

Introduction

In this page you can find the example usage for com.google.common.collect Multimap asMap.

Prototype

Map<K, Collection<V>> asMap();

Source Link

Document

Returns a view of this multimap as a Map from each distinct key to the nonempty collection of that key's associated values.

Usage

From source file:org.apache.brooklyn.rest.util.json.MultimapSerializer.java

private void writeEntries(Multimap<?, ?> value, JsonGenerator jgen, SerializerProvider provider)
        throws IOException {
    for (Map.Entry<?, ? extends Collection<?>> entry : value.asMap().entrySet()) {
        provider.findKeySerializer(provider.constructType(String.class), null).serialize(entry.getKey(), jgen,
                provider);/*w ww  . j a  v  a2 s.co  m*/
        provider.defaultSerializeValue(Lists.newArrayList(entry.getValue()), jgen);
    }
}

From source file:org.apache.brooklyn.util.core.json.MultimapSerializer.java

private void writeEntries(Multimap<?, ?> value, JsonGenerator jgen, SerializerProvider provider)
        throws IOException {
    for (Map.Entry<?, ? extends Collection<?>> entry : value.asMap().entrySet()) {
        provider.findKeySerializer(provider.constructType(Object.class), null).serialize(entry.getKey(), jgen,
                provider);// www  .  j a  v  a2s  .  co m
        provider.defaultSerializeValue(Lists.newArrayList(entry.getValue()), jgen);
    }
}

From source file:es.usc.citius.composit.cli.command.GraphCommand.java

private Graph buildGraph() throws IOException {
    // Open dataset
    WSCTest.Dataset dataset = test.dataset();
    ServiceProvider<Concept> provider = new MemoryIndexServiceProvider<Concept>(dataset.getServiceProvider());
    SetMatchFunction<Concept, Boolean> matcher = dataset.getMatchGraph();
    Multimap<Operation<Concept>, Operation<Concept>> mmap = buildOperationGraph(provider, matcher);
    return BlueprintsUtils.mapToGraph(mmap.asMap());
}

From source file:org.eclipse.xtext.xbase.typesystem.util.MultimapJoiner.java

/**
 * Appends the string representation of each entry of {@code map}, using the previously configured separator and
 * key-value separator, to {@code appendable}.
 *//* w  ww.  ja  va 2 s .c  o  m*/
public <A extends Appendable> A appendTo(A appendable, Multimap<?, ?> map) throws IOException {
    return appendTo(appendable, map.asMap().entrySet());
}

From source file:org.sonar.plugins.core.issue.notification.NewFalsePositiveNotificationDispatcher.java

private void notify(String author, Context context,
        Multimap<String, NotificationChannel> subscribedRecipients) {
    for (Map.Entry<String, Collection<NotificationChannel>> channelsByRecipients : subscribedRecipients.asMap()
            .entrySet()) {//w w w.j a  va2 s.  co m
        String login = channelsByRecipients.getKey();
        // Do not notify the person that resolved the issue
        if (!Objects.equal(author, login)) {
            for (NotificationChannel channel : channelsByRecipients.getValue()) {
                context.addUser(login, channel);
            }
        }
    }
}

From source file:org.gradle.plugins.ide.idea.model.internal.IdeaDependenciesOptimizer.java

private void optimizeScopes(Multimap<Object, GeneratedIdeaScope> scopesByDependencyKey) {
    for (Map.Entry<Object, Collection<GeneratedIdeaScope>> entry : scopesByDependencyKey.asMap().entrySet()) {
        optimizeScopes(entry.getValue());
    }/*from w ww  .ja va  2 s . com*/
}

From source file:org.javersion.json.web.VersionMetadata.java

public VersionMetadata(String _id, Set<Revision> _revs,
        Multimap<PropertyPath, VersionProperty<Object>> conflicts) {
    this._id = _id;
    this._revs = _revs.isEmpty() ? null : new ArrayList<>(_revs);
    this._conflicts = conflicts.isEmpty() ? null : conflicts.asMap();
}

From source file:org.cejug.hurraa.validation.CejugErrorMap.java

public CejugErrorMap(List<Message> messages) {
    Multimap<String, String> out = ArrayListMultimap.create();
    for (Message message : messages) {
        out.put(message.getCategory(), message.getMessage());
    }/*ww  w .  java  2 s.c  om*/
    this.delegate = out.asMap();
    this.messages = messages;

}

From source file:com.github.cbismuth.fdupes.report.DuplicatesLogReporter.java

public Path report(final Multimap<PathElement, PathElement> duplicates) throws IOException {
    final Path output = Paths.get(System.getProperty("user.dir"), "duplicates.log");

    final String content = duplicates.asMap().entrySet().stream().map(Map.Entry::getValue)
            .flatMap(Collection::stream).map(PathElement::getPath).map(Path::toString).map(pathEscapeFunction)
            .collect(joining(System.getProperty("line.separator")));

    Files.write(output, content.getBytes(UTF_8));

    return output;
}

From source file:com.metamx.http.client.Request.java

public Request setHeaderValues(Multimap<String, String> inHeaders) {
    for (Map.Entry<String, Collection<String>> entry : inHeaders.asMap().entrySet()) {
        this.setHeaderValues(entry.getKey(), entry.getValue());
    }//  w w w.j av a  2  s  . com
    return this;
}