List of usage examples for com.google.common.collect ImmutableMultimap builder
public static <K, V> Builder<K, V> builder()
From source file:pt.ua.tm.neji.core.parser.ParserSupport.java
private static void generateOpenNLPMap() { ImmutableMultimap.Builder<ParserLanguage, ParserLevel> builder = ImmutableMultimap.builder(); builder.put(ParserLanguage.DANISH, ParserLevel.TOKENIZATION); builder.put(ParserLanguage.DANISH, ParserLevel.POS); builder.put(ParserLanguage.DUTCH, ParserLevel.TOKENIZATION); builder.put(ParserLanguage.DUTCH, ParserLevel.POS); builder.put(ParserLanguage.ENGLISH, ParserLevel.TOKENIZATION); builder.put(ParserLanguage.ENGLISH, ParserLevel.POS); builder.put(ParserLanguage.ENGLISH, ParserLevel.CHUNKING); builder.put(ParserLanguage.FRENCH, ParserLevel.TOKENIZATION); builder.put(ParserLanguage.FRENCH, ParserLevel.POS); builder.put(ParserLanguage.FRENCH, ParserLevel.CHUNKING); builder.put(ParserLanguage.GERMAN, ParserLevel.TOKENIZATION); builder.put(ParserLanguage.GERMAN, ParserLevel.POS); builder.put(ParserLanguage.PORTUGUESE, ParserLevel.TOKENIZATION); builder.put(ParserLanguage.PORTUGUESE, ParserLevel.POS); builder.put(ParserLanguage.SWEDISH, ParserLevel.TOKENIZATION); builder.put(ParserLanguage.SWEDISH, ParserLevel.POS); supportMaps.put(ParserTool.OPENNLP, builder.build()); }
From source file:com.isotrol.impe3.core.impl.HeadersFactory.java
/** * Adds the parameters from a servlet request. * @param request Servlet request./*w w w. j a v a 2 s . c o m*/ * @return The request parameters. */ public static Headers of(HttpServletRequest request) { Preconditions.checkNotNull(request, "The request cannot be null."); final ImmutableMultimap.Builder<CaseIgnoringString, String> builder = ImmutableMultimap.builder(); @SuppressWarnings("unchecked") final Enumeration<String> names = request.getHeaderNames(); if (names != null) { while (names.hasMoreElements()) { final String header = names.nextElement(); @SuppressWarnings("unchecked") final Enumeration<String> values = request.getHeaders(header); if (values != null && values.hasMoreElements()) { final CaseIgnoringString cih = CaseIgnoringString.valueOf(header); while (values.hasMoreElements()) { builder.put(cih, values.nextElement()); } } } } return new Immutable(builder.build()); }
From source file:co.freeside.betamax.message.httpclient.HttpMessageAdapter.java
@Override public final Map<String, String> getHeaders() { ImmutableMultimap.Builder<String, String> builder = ImmutableMultimap.builder(); for (Header header : getDelegate().getAllHeaders()) { builder.put(header.getName(), header.getValue()); }// w w w .ja va 2s.co m return MultimapUtils.flatten(builder.build(), ", "); }
From source file:com.isotrol.impe3.core.impl.RequestParamsFactory.java
/** * Adds the parameters from a servlet request. * @param request Servlet request./*ww w . ja va 2 s . c o m*/ * @return The request parameters. */ public static RequestParams of(ServletRequest request) { Preconditions.checkNotNull(request, "The request cannot be null."); final ImmutableMultimap.Builder<CaseIgnoringString, String> builder = ImmutableMultimap.builder(); @SuppressWarnings("unchecked") final Enumeration<String> names = request.getParameterNames(); if (names != null) { while (names.hasMoreElements()) { final String parameter = names.nextElement(); final String[] values = request.getParameterValues(parameter); if (values != null && values.length > 0) { builder.putAll(CaseIgnoringString.valueOf(parameter), Arrays.asList(values)); } } } return new Immutable(builder.build()); }
From source file:io.blobkeeper.server.util.MetadataParser.java
public static Multimap<String, String> getHeaders(@NotNull HttpRequest request) { checkNotNull(request, "request is required!"); Iterable<Map.Entry<String, String>> filtered = from(request.headers()) .filter(elt -> elt.getKey().startsWith("X-Metadata")); ImmutableMultimap.Builder<String, String> valueBuilder = ImmutableMultimap.builder(); for (Map.Entry<String, String> elt : filtered) { if (elt.getKey().equals(AUTH_TOKEN_HEADER)) { for (String accessToken : from(on(",").split(elt.getValue()))) { valueBuilder.put(elt.getKey(), accessToken); }//ww w . j a v a 2 s.co m } else { valueBuilder.put(elt.getKey(), elt.getValue()); } } return valueBuilder.build(); }
From source file:com.imaginarycode.minecraft.hubmagic.HubCommandConfiguration.java
HubCommandConfiguration(Configuration configuration) { permissionRequired = configuration.getBoolean("hub-command.requires-permission", false); ImmutableMultimap.Builder<String, String> builder = ImmutableMultimap.builder(); Configuration configuration1 = configuration.getSection("hub-command.forwarding"); List<String> global = configuration1.getStringList("global"); for (String alias : configuration.getStringList("hub-command.aliases")) { for (String s : configuration1.getStringList(alias)) { builder.put(alias, s);/*from w w w. j ava 2 s .c om*/ } builder.putAll(alias, global); } skippingPatterns = builder.build(); Object msgs = configuration.get("hub-command.messages"); if (msgs != null && msgs instanceof Map) { Map<?, ?> msgMap = (Map) msgs; for (Map.Entry<?, ?> entry : msgMap.entrySet()) { messages.put(entry.getKey().toString(), ChatColor.translateAlternateColorCodes('&', entry.getValue().toString())); } } }
From source file:edu.ku.brc.specify.plugins.sgr.Workbench2SGR.java
public Workbench2SGR(Workbench workbench) { final ImmutableMultimap.Builder<String, Short> mb = new ImmutableMultimap.Builder<String, Short>(); for (WorkbenchTemplateMappingItem item : workbench.getWorkbenchTemplate() .getWorkbenchTemplateMappingItems()) { mb.put(item.getFieldName(), item.getViewOrder()); }//from w ww. j a v a 2s .c o m fieldName2Index = mb.build(); }
From source file:org.jetbrains.jet.lang.resolve.java.JavaToKotlinMethodMapGenerated.java
JavaToKotlinMethodMapGenerated() { ImmutableMultimap.Builder<String, JavaToKotlinMethodMap.ClassData> b = ImmutableMultimap.builder(); put(b, "java.lang.String", "String", pair("compareTo(java.lang.String)", "fun compareTo(that: jet.String): jet.Int"), pair("equals(java.lang.Object)", "fun equals(other: jet.Any?): jet.Boolean"), pair("toString()", "fun toString(): jet.String")); put(b, "java.lang.CharSequence", "CharSequence", pair("toString()", "fun toString(): jet.String")); put(b, "java.lang.Throwable", "Throwable", pair("getCause()", "fun getCause(): jet.Throwable?"), pair("getMessage()", "fun getMessage(): jet.String?"), pair("printStackTrace()", "fun printStackTrace(): jet.Unit")); put(b, "java.lang.Comparable", "Comparable", pair("compareTo(T)", "fun compareTo(other: T): jet.Int")); put(b, "java.lang.Enum", "Enum", pair("name()", "fun name(): jet.String"), pair("ordinal()", "fun ordinal(): jet.Int")); put(b, "java.lang.Iterable", "Iterable", pair("iterator()", "fun iterator(): jet.Iterator<T>")); put(b, "java.lang.Iterable", "MutableIterable", pair("iterator()", "fun iterator(): jet.MutableIterator<T>")); put(b, "java.util.Iterator", "Iterator", pair("hasNext()", "fun hasNext(): jet.Boolean"), pair("next()", "fun next(): T")); put(b, "java.util.Iterator", "MutableIterator", pair("hasNext()", "fun hasNext(): jet.Boolean"), pair("next()", "fun next(): T"), pair("remove()", "fun remove(): jet.Unit")); put(b, "java.util.Collection", "Collection", pair("contains(java.lang.Object)", "fun contains(o: jet.Any?): jet.Boolean"), pair("containsAll(java.util.Collection<?>)", "fun containsAll(c: jet.Collection<jet.Any?>): jet.Boolean"), pair("equals(java.lang.Object)", "fun equals(other: jet.Any?): jet.Boolean"), pair("hashCode()", "fun hashCode(): jet.Int"), pair("isEmpty()", "fun isEmpty(): jet.Boolean"), pair("iterator()", "fun iterator(): jet.Iterator<E>"), pair("size()", "fun size(): jet.Int"), pair("toArray()", "fun toArray(): jet.Array<jet.Any?>"), pair("toArray(T[])", "fun <T> toArray(a: jet.Array<out T>): jet.Array<T>")); put(b, "java.util.Collection", "MutableCollection", pair("add(E)", "fun add(e: E): jet.Boolean"), pair("addAll(java.util.Collection<? extends E>)", "fun addAll(c: jet.Collection<E>): jet.Boolean"), pair("clear()", "fun clear(): jet.Unit"), pair("contains(java.lang.Object)", "fun contains(o: jet.Any?): jet.Boolean"), pair("containsAll(java.util.Collection<?>)", "fun containsAll(c: jet.Collection<jet.Any?>): jet.Boolean"), pair("equals(java.lang.Object)", "fun equals(other: jet.Any?): jet.Boolean"), pair("hashCode()", "fun hashCode(): jet.Int"), pair("isEmpty()", "fun isEmpty(): jet.Boolean"), pair("iterator()", "fun iterator(): jet.MutableIterator<E>"), pair("remove(java.lang.Object)", "fun remove(o: jet.Any?): jet.Boolean"), pair("removeAll(java.util.Collection<?>)", "fun removeAll(c: jet.Collection<jet.Any?>): jet.Boolean"), pair("retainAll(java.util.Collection<?>)", "fun retainAll(c: jet.Collection<jet.Any?>): jet.Boolean"), pair("size()", "fun size(): jet.Int"), pair("toArray()", "fun toArray(): jet.Array<jet.Any?>"), pair("toArray(T[])", "fun <T> toArray(a: jet.Array<out T>): jet.Array<T>")); put(b, "java.util.List", "List", pair("contains(java.lang.Object)", "fun contains(o: jet.Any?): jet.Boolean"), pair("containsAll(java.util.Collection<?>)", "fun containsAll(c: jet.Collection<jet.Any?>): jet.Boolean"), pair("equals(java.lang.Object)", "fun equals(other: jet.Any?): jet.Boolean"), pair("get(int)", "fun get(index: jet.Int): E"), pair("hashCode()", "fun hashCode(): jet.Int"), pair("indexOf(java.lang.Object)", "fun indexOf(o: jet.Any?): jet.Int"), pair("isEmpty()", "fun isEmpty(): jet.Boolean"), pair("iterator()", "fun iterator(): jet.Iterator<E>"), pair("lastIndexOf(java.lang.Object)", "fun lastIndexOf(o: jet.Any?): jet.Int"), pair("listIterator()", "fun listIterator(): jet.ListIterator<E>"), pair("listIterator(int)", "fun listIterator(index: jet.Int): jet.ListIterator<E>"), pair("size()", "fun size(): jet.Int"), pair("subList(int, int)", "fun subList(fromIndex: jet.Int, toIndex: jet.Int): jet.List<E>"), pair("toArray()", "fun toArray(): jet.Array<jet.Any?>"), pair("toArray(T[])", "fun <T> toArray(a: jet.Array<out T>): jet.Array<T>")); put(b, "java.util.List", "MutableList", pair("add(E)", "fun add(e: E): jet.Boolean"), pair("add(int, E)", "fun add(index: jet.Int, element: E): jet.Unit"), pair("addAll(int, java.util.Collection<? extends E>)", "fun addAll(index: jet.Int, c: jet.Collection<E>): jet.Boolean"), pair("addAll(java.util.Collection<? extends E>)", "fun addAll(c: jet.Collection<E>): jet.Boolean"), pair("clear()", "fun clear(): jet.Unit"), pair("contains(java.lang.Object)", "fun contains(o: jet.Any?): jet.Boolean"), pair("containsAll(java.util.Collection<?>)", "fun containsAll(c: jet.Collection<jet.Any?>): jet.Boolean"), pair("equals(java.lang.Object)", "fun equals(other: jet.Any?): jet.Boolean"), pair("get(int)", "fun get(index: jet.Int): E"), pair("hashCode()", "fun hashCode(): jet.Int"), pair("indexOf(java.lang.Object)", "fun indexOf(o: jet.Any?): jet.Int"), pair("isEmpty()", "fun isEmpty(): jet.Boolean"), pair("iterator()", "fun iterator(): jet.MutableIterator<E>"), pair("lastIndexOf(java.lang.Object)", "fun lastIndexOf(o: jet.Any?): jet.Int"), pair("listIterator()", "fun listIterator(): jet.MutableListIterator<E>"), pair("listIterator(int)", "fun listIterator(index: jet.Int): jet.MutableListIterator<E>"), pair("remove(int)", "fun remove(index: jet.Int): E"), pair("remove(java.lang.Object)", "fun remove(o: jet.Any?): jet.Boolean"), pair("removeAll(java.util.Collection<?>)", "fun removeAll(c: jet.Collection<jet.Any?>): jet.Boolean"), pair("retainAll(java.util.Collection<?>)", "fun retainAll(c: jet.Collection<jet.Any?>): jet.Boolean"), pair("set(int, E)", "fun set(index: jet.Int, element: E): E"), pair("size()", "fun size(): jet.Int"), pair("subList(int, int)", "fun subList(fromIndex: jet.Int, toIndex: jet.Int): jet.MutableList<E>"), pair("toArray()", "fun toArray(): jet.Array<jet.Any?>"), pair("toArray(T[])", "fun <T> toArray(a: jet.Array<out T>): jet.Array<T>")); put(b, "java.util.Set", "Set", pair("contains(java.lang.Object)", "fun contains(o: jet.Any?): jet.Boolean"), pair("containsAll(java.util.Collection<?>)", "fun containsAll(c: jet.Collection<jet.Any?>): jet.Boolean"), pair("equals(java.lang.Object)", "fun equals(other: jet.Any?): jet.Boolean"), pair("hashCode()", "fun hashCode(): jet.Int"), pair("isEmpty()", "fun isEmpty(): jet.Boolean"), pair("iterator()", "fun iterator(): jet.Iterator<E>"), pair("size()", "fun size(): jet.Int"), pair("toArray()", "fun toArray(): jet.Array<jet.Any?>"), pair("toArray(T[])", "fun <T> toArray(a: jet.Array<out T>): jet.Array<T>")); put(b, "java.util.Set", "MutableSet", pair("add(E)", "fun add(e: E): jet.Boolean"), pair("addAll(java.util.Collection<? extends E>)", "fun addAll(c: jet.Collection<E>): jet.Boolean"), pair("clear()", "fun clear(): jet.Unit"), pair("contains(java.lang.Object)", "fun contains(o: jet.Any?): jet.Boolean"), pair("containsAll(java.util.Collection<?>)", "fun containsAll(c: jet.Collection<jet.Any?>): jet.Boolean"), pair("equals(java.lang.Object)", "fun equals(other: jet.Any?): jet.Boolean"), pair("hashCode()", "fun hashCode(): jet.Int"), pair("isEmpty()", "fun isEmpty(): jet.Boolean"), pair("iterator()", "fun iterator(): jet.MutableIterator<E>"), pair("remove(java.lang.Object)", "fun remove(o: jet.Any?): jet.Boolean"), pair("removeAll(java.util.Collection<?>)", "fun removeAll(c: jet.Collection<jet.Any?>): jet.Boolean"), pair("retainAll(java.util.Collection<?>)", "fun retainAll(c: jet.Collection<jet.Any?>): jet.Boolean"), pair("size()", "fun size(): jet.Int"), pair("toArray()", "fun toArray(): jet.Array<jet.Any?>"), pair("toArray(T[])", "fun <T> toArray(a: jet.Array<out T>): jet.Array<T>")); put(b, "java.util.Map", "Map", pair("containsKey(java.lang.Object)", "fun containsKey(key: jet.Any?): jet.Boolean"), pair("containsValue(java.lang.Object)", "fun containsValue(value: jet.Any?): jet.Boolean"), pair("entrySet()", "fun entrySet(): jet.Set<jet.Map.Entry<K, V>>"), pair("get(java.lang.Object)", "fun get(key: jet.Any?): V?"), pair("isEmpty()", "fun isEmpty(): jet.Boolean"), pair("keySet()", "fun keySet(): jet.Set<K>"), pair("size()", "fun size(): jet.Int"), pair("values()", "fun values(): jet.Collection<V>")); put(b, "java.util.Map", "MutableMap", pair("clear()", "fun clear(): jet.Unit"), pair("containsKey(java.lang.Object)", "fun containsKey(key: jet.Any?): jet.Boolean"), pair("containsValue(java.lang.Object)", "fun containsValue(value: jet.Any?): jet.Boolean"), pair("entrySet()", "fun entrySet(): jet.MutableSet<jet.MutableMap.MutableEntry<K, V>>"), pair("get(java.lang.Object)", "fun get(key: jet.Any?): V?"), pair("isEmpty()", "fun isEmpty(): jet.Boolean"), pair("keySet()", "fun keySet(): jet.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: jet.Map<out K, V>): jet.Unit"), pair("remove(java.lang.Object)", "fun remove(key: jet.Any?): V?"), pair("size()", "fun size(): jet.Int"), pair("values()", "fun values(): jet.MutableCollection<V>")); put(b, "java.util.Map.Entry", "Map.Entry", pair("equals(java.lang.Object)", "fun equals(other: jet.Any?): jet.Boolean"), pair("getKey()", "fun getKey(): K"), pair("getValue()", "fun getValue(): V"), pair("hashCode()", "fun hashCode(): jet.Int")); put(b, "java.util.Map.Entry", "MutableMap.MutableEntry", pair("equals(java.lang.Object)", "fun equals(other: jet.Any?): jet.Boolean"), pair("getKey()", "fun getKey(): K"), pair("getValue()", "fun getValue(): V"), pair("hashCode()", "fun hashCode(): jet.Int"), pair("setValue(V)", "fun setValue(value: V): V")); put(b, "java.util.ListIterator", "ListIterator", pair("hasNext()", "fun hasNext(): jet.Boolean"), pair("hasPrevious()", "fun hasPrevious(): jet.Boolean"), pair("next()", "fun next(): T"), pair("nextIndex()", "fun nextIndex(): jet.Int"), pair("previous()", "fun previous(): T"), pair("previousIndex()", "fun previousIndex(): jet.Int")); put(b, "java.util.ListIterator", "MutableListIterator", pair("add(E)", "fun add(e: T): jet.Unit"), pair("hasNext()", "fun hasNext(): jet.Boolean"), pair("hasPrevious()", "fun hasPrevious(): jet.Boolean"), pair("next()", "fun next(): T"), pair("nextIndex()", "fun nextIndex(): jet.Int"), pair("previous()", "fun previous(): T"), pair("previousIndex()", "fun previousIndex(): jet.Int"), pair("remove()", "fun remove(): jet.Unit"), pair("set(E)", "fun set(e: T): jet.Unit")); map = b.build();/*from w ww .ja v a 2 s .c om*/ }
From source file:org.jclouds.cloudwatch.binders.AlarmNamesBinder.java
@SuppressWarnings("unchecked") @Override/*from w w w . j a v a2s.co m*/ public <R extends HttpRequest> R bindToRequest(R request, Object input) { Iterable<String> alarmNames = (Iterable<String>) checkNotNull(input, "alarm names must be set"); ImmutableMultimap.Builder<String, String> formParameters = ImmutableMultimap.builder(); int alarmNameIndex = 1; for (String alarmName : alarmNames) { formParameters.put("AlarmNames.member." + alarmNameIndex, alarmName); alarmNameIndex++; } return (R) request.toBuilder().replaceFormParams(formParameters.build()).build(); }
From source file:com.google.devtools.build.lib.worker.WorkerActionContextConsumer.java
@Override public Multimap<Class<? extends ActionContext>, String> getActionContexts() { Builder<Class<? extends ActionContext>, String> contexts = ImmutableMultimap.builder(); contexts.put(SpawnActionContext.class, "standalone"); contexts.put(SpawnActionContext.class, "worker"); return contexts.build(); }