Example usage for com.google.common.collect ImmutableMultimap of

List of usage examples for com.google.common.collect ImmutableMultimap of

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableMultimap of.

Prototype

public static <K, V> ImmutableMultimap<K, V> of() 

Source Link

Document

Returns an empty multimap.

Usage

From source file:org.opendaylight.controller.sal.binding.impl.ListenerMapGeneration.java

ListenerMapGeneration() {
    typeToListeners = ImmutableMultimap.of();
}

From source file:org.gradle.internal.execution.history.impl.FileCollectionFingerprintSerializer.java

private ImmutableMultimap<String, HashCode> readRootHashes(Decoder decoder) throws IOException {
    int numberOfRoots = decoder.readSmallInt();
    if (numberOfRoots == 0) {
        return ImmutableMultimap.of();
    }/*from   w  ww.j a v  a  2 s.  c  o  m*/
    ImmutableMultimap.Builder<String, HashCode> builder = ImmutableMultimap.builder();
    for (int i = 0; i < numberOfRoots; i++) {
        String absolutePath = stringInterner.intern(decoder.readString());
        HashCode rootHash = hashCodeSerializer.read(decoder);
        builder.put(absolutePath, rootHash);
    }
    return builder.build();
}

From source file:org.apache.aurora.scheduler.http.Maintenance.java

private Multimap<String, String> getTasksByHosts(StoreProvider provider, Iterable<String> hosts) {
    if (Iterables.isEmpty(hosts)) {
        return ImmutableMultimap.of();
    }/* ww w .  j a v a 2  s .  com*/

    ImmutableSet.Builder<IScheduledTask> drainingTasks = ImmutableSet.builder();
    drainingTasks.addAll(
            provider.getTaskStore().fetchTasks(Query.slaveScoped(hosts).byStatus(Tasks.SLAVE_ASSIGNED_STATES)));
    return Multimaps.transformValues(Multimaps.index(drainingTasks.build(), Tasks::scheduledToSlaveHost),
            Tasks::id);
}

From source file:com.spotify.heroic.ExtraParameters.java

public static ExtraParameters empty() {
    return new ExtraParameters(ImmutableList.of(), ImmutableMultimap.of());
}

From source file:io.prestosql.sql.planner.optimizations.joins.JoinGraph.java

public JoinGraph(PlanNode node) {
    this(ImmutableList.of(node), ImmutableMultimap.of(), node.getId(), ImmutableList.of(), Optional.empty());
}

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

/**
 * @see com.isotrol.impe3.api.component.RenderContext#getAbsolutePageURI(com.isotrol.impe3.api.Pagination, int)
 *//*from   www  .j av a 2 s. c om*/
public URI getAbsolutePageURI(Pagination pagination, int page) {
    Multimap<String, Object> parameters = ImmutableMultimap.of();
    Set<String> remove = ImmutableSet.of();
    if (pagination != null && page >= 1) {
        final String param = pagination.getParameter();
        parameters = ImmutableMultimap.<String, Object>of(param, page);
        remove = ImmutableSet.of(param);
    }
    return getSamePageURI(remove, parameters);
}

From source file:net.hydromatic.optiq.impl.AbstractSchema.java

/**
 * Returns a multi-map of table-functions in this schema by name.
 * It is a multi-map because functions are overloaded; there may be more than
 * one function in a schema with a given name (as long as they have different
 * parameter lists)./*w w w.  ja va 2s.c  o  m*/
 *
 * <p>The implementations of {@link #getTableFunctionNames()}
 * and {@link #getTableFunctions(String)} depend on this map.
 * The default implementation of this method returns the empty multi-map.
 * Override this method to change their behavior.</p>
 */
protected Multimap<String, TableFunction> getTableFunctionMultimap() {
    return ImmutableMultimap.of();
}

From source file:io.blobkeeper.index.domain.IndexElt.java

@NotNull
@SuppressWarnings("unchecked")
public Multimap<String, String> getHeaders() {
    Multimap<String, String> headers = (Multimap<String, String>) metadata.get(HEADERS);
    if (null != headers) {
        return headers;
    } else {//from   www  . jav a 2 s  .c  o  m
        return ImmutableMultimap.of();
    }
}

From source file:com.google.caliper.runner.EnvironmentGetter.java

/**
 * Returns the key/value pairs from the specified properties-file like file.
 * Unlike standard Java properties files, {@code reader} is allowed to list
 * the same property multiple times. Comments etc. are unsupported.
 *
 * <p>If there's any problem reading the file's contents, we'll return an
 * empty Multimap./*ww  w  .j  ava 2  s. co m*/
 */
private static Multimap<String, String> propertiesFromLinuxFile(String file) {
    try {
        List<String> lines = Files.readLines(new File(file), Charset.defaultCharset());
        ImmutableMultimap.Builder<String, String> result = ImmutableMultimap.builder();
        for (String line : lines) {
            // TODO(schmoe): replace with Splitter (in Guava release 10)
            String[] parts = line.split("\\s*\\:\\s*", 2);
            if (parts.length == 2) {
                result.put(parts[0], parts[1]);
            }
        }
        return result.build();
    } catch (IOException e) {
        // If there's any problem reading the file, just return an empty multimap.
        return ImmutableMultimap.of();
    }
}

From source file:net.minecrell.quartz.launch.mappings.Mappings.java

protected Mappings(List<ClassNode> mappingClasses) {
    requireNonNull(mappingClasses, "mappingClasses");
    if (mappingClasses.isEmpty()) {
        this.classes = ImmutableBiMap.of();
        this.methods = ImmutableTable.of();
        this.fields = ImmutableTable.of();
        this.constructors = ImmutableMultimap.of();
        this.accessMappings = ImmutableTable.of();
        return;//w  w  w . j  a v  a  2s .com
    }

    ImmutableBiMap.Builder<String, String> classes = ImmutableBiMap.builder();

    for (ClassNode classNode : mappingClasses) {
        ParsedAnnotation annotation = MappingsParser.getAnnotation(classNode, MAPPING);
        checkState(annotation != null, "Class %s is missing the @Mapping annotation", classNode.name);
        String mapping = annotation.getString("value", "");
        if (!mapping.isEmpty()) {
            classes.put(mapping, classNode.name);
        }
    }

    this.classes = classes.build();

    // We need to remap the descriptors of the fields and methods, use ASM for convenience
    Remapper remapper = new Remapper() {

        @Override
        public String map(String className) {
            return unmap(className);
        }
    };

    // Load field, method and access mappings
    ImmutableTable.Builder<String, String, String> methods = ImmutableTable.builder();
    ImmutableTable.Builder<String, String, String> fields = ImmutableTable.builder();
    ImmutableMultimap.Builder<String, MethodNode> constructors = ImmutableMultimap.builder();
    ImmutableTable.Builder<String, String, AccessMapping> accessMappings = ImmutableTable.builder();

    for (ClassNode classNode : mappingClasses) {
        String className = classNode.name.replace('/', '.');
        String internalName = unmap(classNode.name);

        ParsedAnnotation annotation = MappingsParser.getAnnotation(classNode, ACCESSIBLE);
        if (annotation != null) {
            accessMappings.put(className, "", AccessMapping.of(classNode));
        }

        for (MethodNode methodNode : classNode.methods) {
            Map<String, ParsedAnnotation> annotations = MappingsParser.getAnnotations(methodNode);

            annotation = annotations.get(CONSTRUCTOR);
            if (annotation != null) {
                // Generate constructor call code
                Methods.visitConstructor(methodNode, classNode.name);
                constructors.put(className, methodNode);
                continue;
            }

            // TODO: Validation
            annotation = annotations.get(MAPPING);
            if (annotation != null) {
                String mapping = annotation.getString("value", "");
                if (!mapping.isEmpty()) {
                    methods.put(internalName, mapping + remapper.mapMethodDesc(methodNode.desc),
                            methodNode.name);
                }
            }

            annotation = annotations.get(ACCESSIBLE);
            if (annotation != null) {
                accessMappings.put(className, methodNode.name + methodNode.desc, AccessMapping.of(methodNode));
            }
        }

        for (FieldNode fieldNode : classNode.fields) {
            Map<String, ParsedAnnotation> annotations = MappingsParser.getAnnotations(fieldNode);

            // TODO: Validation
            annotation = annotations.get(MAPPING);
            if (annotation != null) {
                String mapping = annotation.getString("value", "");
                if (!mapping.isEmpty()) {
                    fields.put(internalName, mapping + ':' + remapper.mapDesc(fieldNode.desc), fieldNode.name);
                }
            }

            annotation = annotations.get(ACCESSIBLE);
            if (annotation != null) {
                accessMappings.put(className, fieldNode.name, AccessMapping.of(fieldNode));
            }
        }
    }

    this.methods = methods.build();
    this.fields = fields.build();
    this.constructors = constructors.build();
    this.accessMappings = accessMappings.build();
}