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

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

Introduction

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

Prototype

public static <K, V> Builder<K, V> builder() 

Source Link

Document

Returns a new builder.

Usage

From source file:org.jetbrains.jet.lang.resolve.java.kotlinSignature.JavaToKotlinMethodMapGenerated.java

JavaToKotlinMethodMapGenerated() {
    ImmutableMultimap.Builder<String, JavaToKotlinMethodMap.ClassData> b = ImmutableMultimap.builder();

    put(b, "java.lang.Object", "Any",
            pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
            pair("hashCode()", "fun hashCode(): kotlin.Int"),
            pair("toString()", "fun toString(): kotlin.String"));

    put(b, "java.lang.String", "String",
            pair("compareTo(java.lang.String)", "fun compareTo(other: kotlin.String): kotlin.Int"),
            pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
            pair("hashCode()", "fun hashCode(): kotlin.Int"),
            pair("toString()", "fun toString(): kotlin.String"));

    put(b, "java.lang.CharSequence", "CharSequence", pair("toString()", "fun toString(): kotlin.String"));

    put(b, "java.lang.Throwable", "Throwable", pair("getCause()", "fun getCause(): kotlin.Throwable?"),
            pair("getMessage()", "fun getMessage(): kotlin.String?"),
            pair("printStackTrace()", "fun printStackTrace(): kotlin.Unit"),
            pair("toString()", "fun toString(): kotlin.String"));

    put(b, "java.lang.Comparable", "Comparable", pair("compareTo(T)", "fun compareTo(other: T): kotlin.Int"));

    put(b, "java.lang.Enum", "Enum",
            pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
            pair("hashCode()", "fun hashCode(): kotlin.Int"), pair("name()", "fun name(): kotlin.String"),
            pair("ordinal()", "fun ordinal(): kotlin.Int"),
            pair("toString()", "fun toString(): kotlin.String"));

    put(b, "java.lang.annotation.Annotation", "Annotation",
            pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
            pair("hashCode()", "fun hashCode(): kotlin.Int"),
            pair("toString()", "fun toString(): kotlin.String"));

    put(b, "java.lang.Iterable", "Iterable", pair("iterator()", "fun iterator(): kotlin.Iterator<T>"));

    put(b, "java.lang.Iterable", "MutableIterable",
            pair("iterator()", "fun iterator(): kotlin.MutableIterator<T>"));

    put(b, "java.util.Iterator", "Iterator", pair("hasNext()", "fun hasNext(): kotlin.Boolean"),
            pair("next()", "fun next(): T"));

    put(b, "java.util.Iterator", "MutableIterator", pair("hasNext()", "fun hasNext(): kotlin.Boolean"),
            pair("next()", "fun next(): T"), pair("remove()", "fun remove(): kotlin.Unit"));

    put(b, "java.util.Collection", "Collection",
            pair("contains(java.lang.Object)", "fun contains(o: kotlin.Any?): kotlin.Boolean"),
            pair("containsAll(java.util.Collection<?>)",
                    "fun containsAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
            pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
            pair("hashCode()", "fun hashCode(): kotlin.Int"),
            pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
            pair("iterator()", "fun iterator(): kotlin.Iterator<E>"), pair("size()", "fun size(): kotlin.Int"));

    put(b, "java.util.Collection", "MutableCollection", pair("add(E)", "fun add(e: E): kotlin.Boolean"),
            pair("addAll(java.util.Collection<? extends E>)",
                    "fun addAll(c: kotlin.Collection<E>): kotlin.Boolean"),
            pair("clear()", "fun clear(): kotlin.Unit"),
            pair("contains(java.lang.Object)", "fun contains(o: kotlin.Any?): kotlin.Boolean"),
            pair("containsAll(java.util.Collection<?>)",
                    "fun containsAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
            pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
            pair("hashCode()", "fun hashCode(): kotlin.Int"),
            pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
            pair("iterator()", "fun iterator(): kotlin.MutableIterator<E>"),
            pair("remove(java.lang.Object)", "fun remove(o: kotlin.Any?): kotlin.Boolean"),
            pair("removeAll(java.util.Collection<?>)",
                    "fun removeAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
            pair("retainAll(java.util.Collection<?>)",
                    "fun retainAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
            pair("size()", "fun size(): kotlin.Int"));

    put(b, "java.util.List", "List",
            pair("contains(java.lang.Object)", "fun contains(o: kotlin.Any?): kotlin.Boolean"),
            pair("containsAll(java.util.Collection<?>)",
                    "fun containsAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
            pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
            pair("get(int)", "fun get(index: kotlin.Int): E"), pair("hashCode()", "fun hashCode(): kotlin.Int"),
            pair("indexOf(java.lang.Object)", "fun indexOf(o: kotlin.Any?): kotlin.Int"),
            pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
            pair("iterator()", "fun iterator(): kotlin.Iterator<E>"),
            pair("lastIndexOf(java.lang.Object)", "fun lastIndexOf(o: kotlin.Any?): kotlin.Int"),
            pair("listIterator()", "fun listIterator(): kotlin.ListIterator<E>"),
            pair("listIterator(int)", "fun listIterator(index: kotlin.Int): kotlin.ListIterator<E>"),
            pair("size()", "fun size(): kotlin.Int"), pair("subList(int, int)",
                    "fun subList(fromIndex: kotlin.Int, toIndex: kotlin.Int): kotlin.List<E>"));

    put(b, "java.util.List", "MutableList", pair("add(E)", "fun add(e: E): kotlin.Boolean"),
            pair("add(int, E)", "fun add(index: kotlin.Int, element: E): kotlin.Unit"),
            pair("addAll(int, java.util.Collection<? extends E>)",
                    "fun addAll(index: kotlin.Int, c: kotlin.Collection<E>): kotlin.Boolean"),
            pair("addAll(java.util.Collection<? extends E>)",
                    "fun addAll(c: kotlin.Collection<E>): kotlin.Boolean"),
            pair("clear()", "fun clear(): kotlin.Unit"),
            pair("contains(java.lang.Object)", "fun contains(o: kotlin.Any?): kotlin.Boolean"),
            pair("containsAll(java.util.Collection<?>)",
                    "fun containsAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
            pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
            pair("get(int)", "fun get(index: kotlin.Int): E"), pair("hashCode()", "fun hashCode(): kotlin.Int"),
            pair("indexOf(java.lang.Object)", "fun indexOf(o: kotlin.Any?): kotlin.Int"),
            pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
            pair("iterator()", "fun iterator(): kotlin.MutableIterator<E>"),
            pair("lastIndexOf(java.lang.Object)", "fun lastIndexOf(o: kotlin.Any?): kotlin.Int"),
            pair("listIterator()", "fun listIterator(): kotlin.MutableListIterator<E>"),
            pair("listIterator(int)", "fun listIterator(index: kotlin.Int): kotlin.MutableListIterator<E>"),
            pair("remove(int)", "fun remove(index: kotlin.Int): E"),
            pair("remove(java.lang.Object)", "fun remove(o: kotlin.Any?): kotlin.Boolean"),
            pair("removeAll(java.util.Collection<?>)",
                    "fun removeAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
            pair("retainAll(java.util.Collection<?>)",
                    "fun retainAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
            pair("set(int, E)", "fun set(index: kotlin.Int, element: E): E"),
            pair("size()", "fun size(): kotlin.Int"), pair("subList(int, int)",
                    "fun subList(fromIndex: kotlin.Int, toIndex: kotlin.Int): kotlin.MutableList<E>"));

    put(b, "java.util.Set", "Set",
            pair("contains(java.lang.Object)", "fun contains(o: kotlin.Any?): kotlin.Boolean"),
            pair("containsAll(java.util.Collection<?>)",
                    "fun containsAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
            pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
            pair("hashCode()", "fun hashCode(): kotlin.Int"),
            pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
            pair("iterator()", "fun iterator(): kotlin.Iterator<E>"), pair("size()", "fun size(): kotlin.Int"));

    put(b, "java.util.Set", "MutableSet", pair("add(E)", "fun add(e: E): kotlin.Boolean"),
            pair("addAll(java.util.Collection<? extends E>)",
                    "fun addAll(c: kotlin.Collection<E>): kotlin.Boolean"),
            pair("clear()", "fun clear(): kotlin.Unit"),
            pair("contains(java.lang.Object)", "fun contains(o: kotlin.Any?): kotlin.Boolean"),
            pair("containsAll(java.util.Collection<?>)",
                    "fun containsAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
            pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
            pair("hashCode()", "fun hashCode(): kotlin.Int"),
            pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
            pair("iterator()", "fun iterator(): kotlin.MutableIterator<E>"),
            pair("remove(java.lang.Object)", "fun remove(o: kotlin.Any?): kotlin.Boolean"),
            pair("removeAll(java.util.Collection<?>)",
                    "fun removeAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
            pair("retainAll(java.util.Collection<?>)",
                    "fun retainAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
            pair("size()", "fun size(): kotlin.Int"));

    put(b, "java.util.Map", "Map",
            pair("containsKey(java.lang.Object)", "fun containsKey(key: kotlin.Any?): kotlin.Boolean"),
            pair("containsValue(java.lang.Object)", "fun containsValue(value: kotlin.Any?): kotlin.Boolean"),
            pair("entrySet()", "fun entrySet(): kotlin.Set<kotlin.Map.Entry<K, V>>"),
            pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
            pair("get(java.lang.Object)", "fun get(key: kotlin.Any?): V?"),
            pair("hashCode()", "fun hashCode(): kotlin.Int"),
            pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"), pair("keySet()", "fun keySet(): kotlin.Set<K>"),
            pair("size()", "fun size(): kotlin.Int"), pair("values()", "fun values(): kotlin.Collection<V>"));

    put(b, "java.util.Map", "MutableMap", pair("clear()", "fun clear(): kotlin.Unit"),
            pair("containsKey(java.lang.Object)", "fun containsKey(key: kotlin.Any?): kotlin.Boolean"),
            pair("containsValue(java.lang.Object)", "fun containsValue(value: kotlin.Any?): kotlin.Boolean"),
            pair("entrySet()", "fun entrySet(): kotlin.MutableSet<kotlin.MutableMap.MutableEntry<K, V>>"),
            pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
            pair("get(java.lang.Object)", "fun get(key: kotlin.Any?): V?"),
            pair("hashCode()", "fun hashCode(): kotlin.Int"),
            pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
            pair("keySet()", "fun keySet(): kotlin.MutableSet<K>"),
            pair("put(K, V)", "fun put(key: K, value: V): V?"),
            pair("putAll(java.util.Map<? extends K,? extends V>)",
                    "fun putAll(m: kotlin.Map<out K, V>): kotlin.Unit"),
            pair("remove(java.lang.Object)", "fun remove(key: kotlin.Any?): V?"),
            pair("size()", "fun size(): kotlin.Int"),
            pair("values()", "fun values(): kotlin.MutableCollection<V>"));

    put(b, "java.util.Map.Entry", "Map.Entry",
            pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
            pair("getKey()", "fun getKey(): K"), pair("getValue()", "fun getValue(): V"),
            pair("hashCode()", "fun hashCode(): kotlin.Int"));

    put(b, "java.util.Map.Entry", "MutableMap.MutableEntry",
            pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
            pair("getKey()", "fun getKey(): K"), pair("getValue()", "fun getValue(): V"),
            pair("hashCode()", "fun hashCode(): kotlin.Int"), pair("setValue(V)", "fun setValue(value: V): V"));

    put(b, "java.util.ListIterator", "ListIterator", pair("hasNext()", "fun hasNext(): kotlin.Boolean"),
            pair("hasPrevious()", "fun hasPrevious(): kotlin.Boolean"), pair("next()", "fun next(): T"),
            pair("nextIndex()", "fun nextIndex(): kotlin.Int"), pair("previous()", "fun previous(): T"),
            pair("previousIndex()", "fun previousIndex(): kotlin.Int"));

    put(b, "java.util.ListIterator", "MutableListIterator", pair("add(E)", "fun add(e: T): kotlin.Unit"),
            pair("hasNext()", "fun hasNext(): kotlin.Boolean"),
            pair("hasPrevious()", "fun hasPrevious(): kotlin.Boolean"), pair("next()", "fun next(): T"),
            pair("nextIndex()", "fun nextIndex(): kotlin.Int"), pair("previous()", "fun previous(): T"),
            pair("previousIndex()", "fun previousIndex(): kotlin.Int"),
            pair("remove()", "fun remove(): kotlin.Unit"), pair("set(E)", "fun set(e: T): kotlin.Unit"));

    map = b.build();//from  www.ja  v  a  2  s.c o m
}

From source file:org.jclouds.sqs.binders.BindAttributeNamesToIndexedFormParams.java

@SuppressWarnings("unchecked")
@Override/*w w w .  j a v a2 s  .c  o  m*/
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
    Iterable<?> values = Iterable.class.cast(checkNotNull(input, "attributeNames"));
    Builder<String, String> builder = ImmutableMultimap.builder();
    int i = 0;
    for (Object o : values) {
        builder.put("AttributeName." + (i++ + 1), o.toString());
    }
    ImmutableMultimap<String, String> forms = builder.build();
    return (R) (forms.size() == 0 ? request : request.toBuilder().replaceFormParams(forms).build());
}

From source file:org.jclouds.elb.binders.BindInstanceIdsToIndexedFormParams.java

@SuppressWarnings("unchecked")
@Override/*from  w  w  w.  ja v a  2 s  . c  om*/
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
    Iterable<?> values = Iterable.class.cast(checkNotNull(input, "instanceIds"));
    Builder<String, String> builder = ImmutableMultimap.builder();
    int i = 0;
    for (Object o : values) {
        builder.put("Instances.member." + (i++ + 1) + ".InstanceId", o.toString());
    }
    ImmutableMultimap<String, String> forms = builder.build();
    return (R) (forms.size() == 0 ? request : request.toBuilder().replaceFormParams(forms).build());
}

From source file:com.nesscomputing.httpclient.response.HttpResponseContentConverter.java

private Multimap<String, String> headersFor(Map<String, List<String>> allHeaders) {
    ImmutableMultimap.Builder<String, String> builder = ImmutableMultimap.builder();
    for (Entry<String, List<String>> e : allHeaders.entrySet()) {
        builder.putAll(e.getKey(), e.getValue());
    }/*from www  .  j  av  a2 s .co  m*/

    return builder.build();
}

From source file:com.kolich.curacao.mappers.request.types.body.EncodedRequestBodyMapper.java

private static final Multimap<String, String> parse(final String body, final String encodingCharset)
        throws Exception {
    final ImmutableMultimap.Builder<String, String> result = ImmutableListMultimap.builder();
    // <https://github.com/markkolich/curacao/issues/12>
    // Only bother parsing the POST body if there's actually something there to parse.
    if (!StringUtils.isEmpty(body)) {
        final StringBuffer buffer = new StringBuffer(body);
        final Cursor cursor = new Cursor(0, buffer.length());
        while (!cursor.atEnd()) {
            final Map.Entry<String, String> entry = getNextNameValuePair(buffer, cursor);
            if (!entry.getKey().isEmpty()) {
                result.put(decode(entry.getKey(), encodingCharset), decode(entry.getValue(), encodingCharset));
            }//from w w w.  j ava 2  s .  com
        }
    }
    return result.build();
}

From source file:com.google.devtools.build.lib.worker.WorkerActionContextProvider.java

public WorkerActionContextProvider(CommandEnvironment env, BuildRequest buildRequest, WorkerPool workers) {
    int maxRetries = buildRequest.getOptions(WorkerOptions.class).workerMaxRetries;
    ImmutableMultimap.Builder<String, String> extraFlags = ImmutableMultimap.builder();
    extraFlags.putAll(buildRequest.getOptions(WorkerOptions.class).workerExtraFlags);

    WorkerSpawnStrategy workerSpawnStrategy = new WorkerSpawnStrategy(env.getDirectories(), workers,
            buildRequest.getOptions(ExecutionOptions.class).verboseFailures, maxRetries,
            buildRequest.getOptions(WorkerOptions.class).workerVerbose, extraFlags.build());
    TestActionContext workerTestStrategy = new WorkerTestStrategy(env, buildRequest, workers, maxRetries,
            extraFlags.build());/*from w w  w.  j  av  a2  s  .  c  o m*/
    this.strategies = ImmutableList.of(workerSpawnStrategy, workerTestStrategy);
}

From source file:com.google.devtools.build.lib.sandbox.SandboxActionContextConsumer.java

public SandboxActionContextConsumer(CommandEnvironment env) {
    ImmutableMultimap.Builder<Class<? extends ActionContext>, String> contexts = ImmutableMultimap.builder();
    ImmutableMap.Builder<String, String> spawnContexts = ImmutableMap.builder();

    // This makes the "sandboxed" strategy available via --spawn_strategy=sandboxed,
    // but it is not necessarily the default.
    if ((OS.getCurrent() == OS.LINUX && LinuxSandboxedStrategy.isSupported(env))
            || (OS.getCurrent() == OS.DARWIN && DarwinSandboxRunner.isSupported())) {
        contexts.put(SpawnActionContext.class, "sandboxed");

        // This makes the "sandboxed" strategy the default Spawn strategy, unless it is
        // overridden by a later BlazeModule.
        spawnContexts.put("", "sandboxed");
    }/*from  w w w.  ja  v  a 2 s .  c om*/

    this.contexts = contexts.build();
    this.spawnContexts = spawnContexts.build();
}

From source file:org.apache.beam.sdk.extensions.sql.impl.UdfImpl.java

/** Creates {@link org.apache.calcite.schema.ScalarFunction} for each method in a given class. */
public static ImmutableMultimap<String, ScalarFunction> createAll(Class<?> clazz) {
    final ImmutableMultimap.Builder<String, ScalarFunction> builder = ImmutableMultimap.builder();
    for (Method method : clazz.getMethods()) {
        if (method.getDeclaringClass() == Object.class) {
            continue;
        }/*from   w ww . jav  a2 s.c  o  m*/
        if (!Modifier.isStatic(method.getModifiers()) && !classHasPublicZeroArgsConstructor(clazz)) {
            continue;
        }
        final ScalarFunction function = create(method);
        builder.put(method.getName(), function);
    }
    return builder.build();
}

From source file:org.jclouds.ec2.binders.BindIpPermissionsToIndexedFormParams.java

@SuppressWarnings("unchecked")
@Override// w  w  w  .  ja v a 2 s . c  o  m
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
    checkArgument(checkNotNull(input, "input") instanceof Iterable,
            "this binder is only valid for Iterable<IpPermission>");
    Builder<String, String> formBuilder = ImmutableMultimap.builder();
    int index = 0;
    for (IpPermission perm : (Iterable<IpPermission>) input)
        formBuilder.putAll(IpPermissions.buildFormParametersForIndex(index++, perm));
    ImmutableMultimap<String, String> forms = formBuilder.build();
    return forms.size() == 0 ? request : (R) request.toBuilder().replaceFormParams(forms).build();
}

From source file:org.apache.beam.sdk.extensions.sql.impl.ScalarFunctionImpl.java

/** Creates {@link org.apache.calcite.schema.Function} for each method in a given class. */
public static ImmutableMultimap<String, Function> createAll(Class<?> clazz) {
    final ImmutableMultimap.Builder<String, Function> builder = ImmutableMultimap.builder();
    for (Method method : clazz.getMethods()) {
        if (method.getDeclaringClass() == Object.class) {
            continue;
        }/*from   www.  j  a  va2s.  c om*/
        if (!Modifier.isStatic(method.getModifiers()) && !classHasPublicZeroArgsConstructor(clazz)) {
            continue;
        }
        final Function function = create(method);
        builder.put(method.getName(), function);
    }
    return builder.build();
}