List of usage examples for com.google.common.collect ImmutableMap builder
public static <K, V> Builder<K, V> builder()
From source file:com.google.idea.blaze.base.sync.GenericSourceFolderProvider.java
@Override public ImmutableMap<VirtualFile, SourceFolder> initializeSourceFolders(ContentEntry contentEntry) { ImmutableMap.Builder<VirtualFile, SourceFolder> output = ImmutableMap.builder(); VirtualFile file = contentEntry.getFile(); if (file != null) { output.put(file, contentEntry.addSourceFolder(file, false)); }/*from w w w . j a va 2 s . co m*/ return output.build(); }
From source file:ru.org.linux.spring.SectionStore.java
public SectionStore() throws SQLException { Connection db = LorDataSource.getConnection(); try {//from w ww . java2 s. c o m ImmutableMap.Builder<Integer, Section> sections = ImmutableMap.builder(); ImmutableList.Builder<Section> sectionsList = ImmutableList.builder(); Statement st = db.createStatement(); ResultSet rs = st.executeQuery("SELECT id, name, imagepost, vote, moderate FROM sections ORDER BY id"); while (rs.next()) { Section section = new Section(rs); sections.put(section.getId(), section); sectionsList.add(section); } this.sections = sections.build(); this.sectionsList = sectionsList.build(); } finally { db.close(); } }
From source file:com.facebook.buck.rules.macros.MacroHandler.java
private static ImmutableMap<String, MacroExpander> addOutputToFileExpanders( ImmutableMap<String, MacroExpander> source) { ImmutableMap.Builder<String, MacroExpander> builder = ImmutableMap.builder(); for (Map.Entry<String, MacroExpander> entry : source.entrySet()) { builder.put(entry.getKey(), entry.getValue()); builder.put("@" + entry.getKey(), new OutputToFileExpander(entry.getValue())); }/*from w ww . ja v a2s . c o m*/ return builder.build(); }
From source file:kr.co.bitnine.octopus.schema.metamodel.OctopusMetaModelSchema.java
public OctopusMetaModelSchema(MetaSchema metaSchema, OctopusMetaModelDataSource dataSource) { super(metaSchema, dataSource); LOG.debug("create OctopusMetaModelSchema. schemaName: " + metaSchema.getName()); ImmutableMap.Builder<String, Table> builder = ImmutableMap.builder(); for (MetaTable metaTable : metaSchema.getTables()) builder.put(metaTable.getName(), new OctopusMetaModelTable(metaTable, this)); setTableMap(builder.build());//from w w w . java 2 s . co m }
From source file:org.trancecode.collection.TcMaps.java
public static <K, V> Map<K, V> copyAndPut(final Map<K, V> map, final K key, final V value) { Preconditions.checkNotNull(map);//from w w w . ja v a2s . c om Preconditions.checkNotNull(key); if (map instanceof ImmutableMap && TcObjects.equals(map.get(key), value)) { return map; } final Builder<K, V> builder = ImmutableMap.builder(); final Map<K, V> mapWithoutKey = Maps.filterKeys(map, Predicates.not(Predicates.equalTo(key))); return builder.putAll(mapWithoutKey).put(key, value).build(); }
From source file:com.spotify.heroic.grammar.DefaultScope.java
private Map<String, Function<Context, Expression>> buildScope(final long now) { final ImmutableMap.Builder<String, Function<Context, Expression>> scope = ImmutableMap.builder(); scope.put(Expression.NOW, c -> new IntegerExpression(c, now)); return scope.build(); }
From source file:org.jclouds.openstack.nova.v2_0.parse.ParseServerDiagnostics.java
@Override public Optional<Map<String, String>> expected() { return Optional.<Map<String, String>>of(new ImmutableMap.Builder<String, String>() .put("vnet0_tx_errors", "0").put("vda_read", "77364736").put("vda_write", "415446016") .put("vnet0_tx_packets", "9701").put("vda_write_req", "47278").put("cpu0_time", "143150000000") .put("vnet0_tx", "1691221").put("vnet0_rx_drop", "0").put("vda_errors", "-1") .put("vnet0_rx_errors", "0").put("memory", "524288").put("vnet0_rx_packets", "11271") .put("vda_read_req", "9551").put("vnet0_rx", "1805288").put("vnet0_tx_drop", "0").build()); }
From source file:io.druid.collections.CountingMap.java
public Map<K, Long> snapshot() { final ImmutableMap.Builder<K, Long> builder = ImmutableMap.builder(); for (Map.Entry<K, AtomicLong> entry : entrySet()) { builder.put(entry.getKey(), entry.getValue().get()); }//from w w w .j a v a 2 s.c om return builder.build(); }
From source file:ch.ledcom.jpreseed.distro.DistroService.java
public DistroService(List<Distribution> distributions) { ImmutableMap.Builder<String, Distribution> byNameBuilder = ImmutableMap.builder(); ImmutableList.Builder<DistroAndVersion> flattenedBuilder = ImmutableList.builder(); for (Distribution distro : distributions) { byNameBuilder.put(distro.getName(), distro); for (DistroVersion version : distro.getVersions()) { flattenedBuilder.add(new DistroAndVersion(distro, version)); }/*from w ww .j a va 2 s .c om*/ } this.distributionsByName = byNameBuilder.build(); this.flattenedVersions = flattenedBuilder.build(); }
From source file:com.stormpath.sample.impl.converters.DefaultMapValueRetriever.java
public DefaultMapValueRetriever() { converterMap = new ImmutableMap.Builder<Class<?>, Converter<String, ?>>().build(); }