List of usage examples for com.google.common.collect ImmutableMap builder
public static <K, V> Builder<K, V> builder()
From source file:org.sakaiproject.nakamura.lite.jdbc.oracle.OracleSetup.java
public synchronized static JDBCStorageClientPool createClientPool(Configuration configuration) { try {/*from w ww . j a va2s . c om*/ JDBCStorageClientPool connectionPool = new JDBCStorageClientPool(); Builder<String, Object> b = ImmutableMap.builder(); b.put(JDBCStorageClientPool.CONNECTION_URL, "jdbc:oracle:thin:@127.0.0.1:1521:XE"); b.put(JDBCStorageClientPool.JDBC_DRIVER, "oracle.jdbc.driver.OracleDriver"); b.put("username", "sakai22"); b.put("password", "sakai22"); b.put("store-base-dir", "target/store"); b.put(Configuration.class.getName(), configuration); connectionPool.activate(b.build()); return connectionPool; } catch (ClassNotFoundException e) { throw new RuntimeException(e.getMessage(), e); } }
From source file:org.sakaiproject.nakamura.lite.jdbc.mysql.MysqlSetup.java
public synchronized static JDBCStorageClientPool createClientPool(Configuration configuration) { try {// www.ja va2 s .co m JDBCStorageClientPool connectionPool = new JDBCStorageClientPool(); Builder<String, Object> b = ImmutableMap.builder(); b.put(JDBCStorageClientPool.CONNECTION_URL, "jdbc:mysql://127.0.0.1:3306/sakai22?useUnicode=true&characterEncoding=UTF-8"); b.put(JDBCStorageClientPool.JDBC_DRIVER, "com.mysql.jdbc.Driver"); b.put("username", "sakai22"); b.put("password", "sakai22"); b.put("store-base-dir", "target/store"); b.put(Configuration.class.getName(), configuration); connectionPool.activate(b.build()); return connectionPool; } catch (ClassNotFoundException e) { throw new RuntimeException(e.getMessage(), e); } }
From source file:com.facebook.buck.util.MoreMaps.java
public static <K1, K2, V> ImmutableMap<K2, V> transformKeys(Map<K1, V> map, Function<? super K1, K2> transformer) { ImmutableMap.Builder<K2, V> transformedMap = ImmutableMap.builder(); for (Map.Entry<K1, V> ent : map.entrySet()) { transformedMap.put(Preconditions.checkNotNull(transformer.apply(ent.getKey())), ent.getValue()); }/* ww w. ja v a2 s .c om*/ return transformedMap.build(); }
From source file:com.google.thirdparty.publicsuffix.TrieParser.java
/** * Parses a serialized trie representation of a map of reversed public * suffixes into an immutable map of public suffixes. *//*from w ww .jav a 2 s. co m*/ static ImmutableMap<String, PublicSuffixType> parseTrie(CharSequence encoded) { ImmutableMap.Builder<String, PublicSuffixType> builder = ImmutableMap.builder(); int encodedLen = encoded.length(); int idx = 0; while (idx < encodedLen) { idx += doParseTrieToBuilder(Lists.<CharSequence>newLinkedList(), encoded.subSequence(idx, encodedLen), builder); } return builder.build(); }
From source file:com.google.caliper.XmlUtils.java
public static ImmutableMap<String, String> attributesOf(Element element) { NamedNodeMap map = element.getAttributes(); ImmutableMap.Builder<String, String> result = ImmutableMap.builder(); for (int i = 0, size = map.getLength(); i < size; i++) { Attr attr = (Attr) map.item(i); result.put(attr.getName(), attr.getValue()); }/* w ww .ja v a 2 s.c o m*/ return result.build(); }
From source file:org.sakaiproject.nakamura.lite.jdbc.postgresql.PostgreSQLSetup.java
public synchronized static JDBCStorageClientPool createClientPool(Configuration configuration) { try {/* ww w . j a v a2 s . c om*/ JDBCStorageClientPool connectionPool = new JDBCStorageClientPool(); Builder<String, Object> b = ImmutableMap.builder(); b.put(JDBCStorageClientPool.CONNECTION_URL, "jdbc:postgresql://localhost/nak"); b.put(JDBCStorageClientPool.JDBC_DRIVER, "org.postgresql.Driver"); b.put("username", "nakamura"); b.put("password", "nakamura"); b.put("store-base-dir", "target/store"); b.put(Configuration.class.getName(), configuration); connectionPool.activate(b.build()); return connectionPool; } catch (ClassNotFoundException e) { throw new RuntimeException(e.getMessage(), e); } }
From source file:com.isotrol.impe3.core.support.IdentifiableMaps.java
/** * Creates a builder for a new hierarchy of identifiable objects. * @param <V> Value type./* w w w . j ava 2 s . c o m*/ * @return A new builder. */ public static <V extends Identifiable> ImmutableMap<UUID, V> immutableOf(Iterable<? extends V> values) { final ImmutableMap.Builder<UUID, V> builder = ImmutableMap.builder(); for (V value : values) { builder.put(value.getId(), value); } return builder.build(); }
From source file:com.haulmont.bali.util.ParamsMap.java
public static Map<String, Object> of(String paramName, Object paramValue) { ImmutableMap.Builder<String, Object> b = new ImmutableMap.Builder<>(); put(b, paramName, paramValue);/*w w w. j a v a 2 s . co m*/ return b.build(); }
From source file:com.codingopus.guava.custom.collectors.ImmutableMapCollector.java
public static <T, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap( final Function<? super T, ? extends K> keyExtractor, final Function<? super T, ? extends V> valueExtractor) { return Collector.of(ImmutableMap::builder, (map, val) -> map.put(keyExtractor.apply(val), valueExtractor.apply(val)), (left, right) -> left.putAll(right.build()), ImmutableMap.Builder<K, V>::build); }
From source file:com.facebook.presto.sql.planner.DomainUtils.java
public static <T> Map<Symbol, T> columnHandleToSymbol(Map<ColumnHandle, T> columnMap, Map<Symbol, ColumnHandle> assignments) { Map<ColumnHandle, Symbol> inverseAssignments = ImmutableBiMap.copyOf(assignments).inverse(); Preconditions.checkArgument(inverseAssignments.keySet().containsAll(columnMap.keySet()), "assignments does not contain all required column handles"); ImmutableMap.Builder<Symbol, T> builder = ImmutableMap.builder(); for (Map.Entry<ColumnHandle, T> entry : columnMap.entrySet()) { builder.put(inverseAssignments.get(entry.getKey()), entry.getValue()); }//www . ja v a2 s.c o m return builder.build(); }