List of usage examples for com.google.common.collect ImmutableMap builder
public static <K, V> Builder<K, V> builder()
From source file:matching.edmonds1.Matching.java
private static <T> Map<T, T> buildMatchingMap(final MutableUndirectedGraph<T> maximumMatching) { final Builder<T, T> builder = new ImmutableMap.Builder<T, T>(); final Set<T> set = Sets.newHashSet(); for (final T endPoint1 : maximumMatching) { final T endPoint2 = maximumMatching.getEndPoints(endPoint1).iterator().next(); if (!set.contains(endPoint2)) { set.add(endPoint1);// w ww . j a va2 s.c o m set.add(endPoint2); builder.put(endPoint1, endPoint2); } } return builder.build(); }
From source file:com.spectralogic.ds3client.metadata.MetadataStoreFactory.java
public MetadataStore getOsSpecificMetadataStore(final ImmutableMap.Builder<String, String> metadataMap) { if (MetaDataUtil.getOS().contains("Windows")) { return new WindowsMetadataStore(metadataMap); } else {//from ww w . j a v a2 s .co m return new PosixMetadataStore(metadataMap); } }
From source file:org.n52.youngs.impl.NamespaceContextImpl.java
public static NamespaceContext create() { return new NamespaceContextImpl(new ImmutableMap.Builder<String, String>() .put("gmd", "http://www.isotc211.org/2005/gmd").put("gco", "http://www.isotc211.org/2005/gco") .put("eum", "http://www.eumetsat.int/2008/gmi").put("gmi", "http://www.isotc211.org/2005/gmi") .put("ogc", "http://www.opengis.net/ogc").put("xlink", "http://www.w3.org/1999/xlink") .put("fn", "http://www.w3.org/TR/xpath-functions").put("str", "http://exslt.org/strings") .put("xdt", "http://www.w3.org/2005/02/xpath-datatypes") .put("xsi", "http://www.w3.org/2001/XMLSchema-instance") .put("xs", "http://www.w3.org/2001/XMLSchema").put("ows", "http://www.opengis.net/ows") .put("csw", "http://www.opengis.net/cat/csw/2.0.2").put("srv", "http://www.isotc211.org/2005/srv") .put("dc", "http://purl.org/dc/elements/1.1/").put("dct", "http://purl.org/dc/terms/") .put("inspire_ds", "http://inspire.ec.europa.eu/schemas/inspire_ds/1.0") .put("inspire_c", "http://inspire.ec.europa.eu/schemas/common/1.0").build()); }
From source file:com.isotrol.impe3.core.impl.SessionParamsFactory.java
/** * Returns a collection built from a Servlet HTTP session. * @param session Session./* w w w.j a v a2 s .c o m*/ * @return The requested collection. */ public static SessionParams of(HttpSession session) { Preconditions.checkNotNull(session, "The session cannot be null."); final ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder(); @SuppressWarnings("unchecked") final Enumeration<String> names = session.getAttributeNames(); if (names != null) { while (names.hasMoreElements()) { final String parameter = names.nextElement(); final Object value = session.getAttribute(parameter); if (value != null) { builder.put(parameter, value); } } } return new Immutable(builder.build()); }
From source file:com.facebook.presto.connector.system.SystemColumnHandle.java
public static Map<String, ColumnHandle> toSystemColumnHandles(ConnectorTableMetadata tableMetadata) { ImmutableMap.Builder<String, ColumnHandle> columnHandles = ImmutableMap.builder(); for (ColumnMetadata columnMetadata : tableMetadata.getColumns()) { columnHandles.put(columnMetadata.getName(), new SystemColumnHandle(columnMetadata.getName())); }/* w w w. java 2 s. co m*/ return columnHandles.build(); }
From source file:com.google.template.soy.shared.internal.BackendModuleUtils.java
/** * Given a backend-specific Soy function type and the set of all Soy function implementations, * finds the Soy functions that are implemented for the specific backend and returns them in the * form of a map from function name to function. * * @param backendSpecificSoyFunctionType The backend-specific Soy function type to filter for. * @param soyFunctionsSet The set of all Soy functions. * @return A map of the relevant backend-specific Soy functions (name to function). *//* w w w. j ava 2 s . com*/ public static <T extends SoyFunction> Map<String, T> buildBackendSpecificSoyFunctionsMap( Class<T> backendSpecificSoyFunctionType, Set<SoyFunction> soyFunctionsSet) { ImmutableMap.Builder<String, T> mapBuilder = ImmutableMap.builder(); Set<String> seenFnNames = Sets.newHashSetWithExpectedSize(soyFunctionsSet.size()); for (SoyFunction fn : soyFunctionsSet) { if (backendSpecificSoyFunctionType.isAssignableFrom(fn.getClass())) { String fnName = fn.getName(); if (seenFnNames.contains(fnName) || ImpureFunction.forFunctionName(fnName) != null) { throw new IllegalStateException( "Found two implementations of " + backendSpecificSoyFunctionType.getSimpleName() + " with the same function name '" + fnName + "'."); } seenFnNames.add(fnName); mapBuilder.put(fnName, backendSpecificSoyFunctionType.cast(fn)); } } return mapBuilder.build(); }
From source file:com.google.javascript.jscomp.newtypes.TypeParameters.java
static TypeParameters make(List<String> ordinaryTypeParams, Map<String, Node> ttlParams) { ImmutableMap.Builder<String, Node> builder = ImmutableMap.builder(); for (String typeParam : ordinaryTypeParams) { builder.put(typeParam, IR.empty()); }/*from www . j ava2s. c o m*/ builder.putAll(ttlParams); return new TypeParameters(builder.build()); }
From source file:io.sidecar.query.HistogramAnswer.java
public HistogramAnswer(Map<String, Integer> b) { if (b == null) { buckets = ImmutableMap.of();// w ww . j a v a2s . c o m } else { ImmutableMap.Builder<String, Integer> imb = ImmutableMap.builder(); for (Map.Entry<String, Integer> e : b.entrySet()) { imb.put(e.getKey(), e.getValue()); } buckets = imb.build(); } }
From source file:org.sonar.server.setting.SettingLoader.java
void loadAll(ImmutableMap.Builder<String, String> appendTo);
From source file:com.facebook.buck.jvm.java.DefaultClassUsageFileReader.java
private static ImmutableMap<Path, SourcePath> buildJarToAbiJarMap(ImmutableSortedSet<BuildRule> deps) { ImmutableMap.Builder<Path, SourcePath> jarAbsolutePathToAbiJarSourcePathBuilder = ImmutableMap.builder(); for (BuildRule dep : deps) { if (!(dep instanceof HasJavaAbi)) { continue; }//from w ww. j a v a2s . c o m HasJavaAbi depWithJavaAbi = (HasJavaAbi) dep; Optional<BuildTarget> depAbiJar = depWithJavaAbi.getAbiJar(); if (!depAbiJar.isPresent()) { continue; } Path jarAbsolutePath = dep.getProjectFilesystem().resolve(dep.getPathToOutput()); jarAbsolutePathToAbiJarSourcePathBuilder.put(jarAbsolutePath, new BuildTargetSourcePath(depAbiJar.get())); } return jarAbsolutePathToAbiJarSourcePathBuilder.build(); }