List of usage examples for com.google.common.collect ImmutableMap.Builder put
public final V put(K k, V v)
From source file:com.yahoo.yqlplus.engine.internal.plan.types.Conversions.java
private static void registerSeq(ImmutableMap.Builder<String, BytecodeSequence> m, Class<?> fromType, Class<?> type, Class<?> ownerType, String methodName) { m.put(key(fromType, ownerType), new BoxCall(type, methodName, ownerType)); }
From source file:org.prebake.service.Main.java
private static Map<String, String> getSystemPropertyMap() { ImmutableMap.Builder<String, String> sysProps = ImmutableMap.builder(); for (Map.Entry<?, ?> e : System.getProperties().entrySet()) { sysProps.put((String) e.getKey(), (String) e.getValue()); }//from ww w . j a v a 2 s . c o m return sysProps.build(); }
From source file:ninja.leaping.permissionsex.sponge.PEXSubjectData.java
private static <T> Map<Set<Context>, T> tKeys(Map<Set<Map.Entry<String, String>>, T> input) { final ImmutableMap.Builder<Set<Context>, T> ret = ImmutableMap.builder(); for (Map.Entry<Set<Map.Entry<String, String>>, T> ent : input.entrySet()) { ret.put(ent.getKey().stream() .map(ctx -> ctx instanceof Context ? (Context) ctx : new Context(ctx.getKey(), ctx.getValue())) .collect(GuavaCollectors.toImmutableSet()), ent.getValue()); }/*from w w w .j a va 2s . c om*/ return ret.build(); }
From source file:edmtools.Metrics.java
public static Map<Integer, Metric> getBitToMetricMap(MetadataUtil metadataUtil) { int versionSelector = getVersionSelector(metadataUtil); ImmutableMap.Builder<Integer, Metric> builder = ImmutableMap.builder(); for (Metric metric : METRICS) { if ((metric.getVersionMask() & versionSelector) > 0) { builder.put(metric.getLowByteBit(), metric); if (metric.getHighByteBit().isPresent()) { builder.put(metric.getHighByteBit().get(), metric); }// w w w .j ava 2 s . c o m } } return builder.build(); }
From source file:com.google.caliper.runner.ParameterSet.java
public static ParameterSet create(Class<?> theClass, Class<? extends Annotation> annotationClass) throws InvalidBenchmarkException { // deterministic order, not reflection order ImmutableMap.Builder<String, Parameter> parametersBuilder = ImmutableSortedMap.naturalOrder(); for (Field field : theClass.getDeclaredFields()) { if (field.isAnnotationPresent(annotationClass)) { Parameter parameter = Parameter.create(field); parametersBuilder.put(field.getName(), parameter); }/*from w w w.j a v a2 s .c o m*/ } return new ParameterSet(parametersBuilder.build()); }
From source file:com.uber.rave.compiler.CompilerUtils.java
private static void init() { ImmutableMap.Builder<String, Class<? extends Annotation>> annotationBuilder = ImmutableMap.builder(); for (Class<? extends Annotation> cls : SUPPORTED_ANNOTATIONS) { annotationBuilder.put(cls.getCanonicalName(), cls); }//from w ww .java 2s. c om sAnnotationMap = annotationBuilder.build(); Map<Class<? extends Annotation>, ImmutableSet.Builder<Class<? extends Annotation>>> mapBuilder = new HashMap<>(); for (Pair<Class<? extends Annotation>, Class<? extends Annotation>> pair : CONFLICTING_ANNOTATIONS) { build(mapBuilder, pair.first, pair.second); build(mapBuilder, pair.second, pair.first); } ImmutableMap.Builder<Class<? extends Annotation>, Set<Class<? extends Annotation>>> builder = ImmutableMap .builder(); for (Class<? extends Annotation> annotation : SUPPORTED_ANNOTATIONS) { ImmutableSet.Builder<Class<? extends Annotation>> conflicting = mapBuilder.get(annotation); if (conflicting == null) { conflicting = new ImmutableSet.Builder<>(); } builder.put(annotation, conflicting.build()); } sConflictingAnnotations = builder.build(); }
From source file:ninja.leaping.permissionsex.sponge.PEXOptionSubjectData.java
private static <T> Map<Set<Context>, T> tKeys(Map<Set<Map.Entry<String, String>>, T> input) { final ImmutableMap.Builder<Set<Context>, T> ret = ImmutableMap.builder(); for (Map.Entry<Set<Map.Entry<String, String>>, T> ent : input.entrySet()) { ret.put(ImmutableSet.copyOf(Iterables.transform(ent.getKey(), ctx -> ctx instanceof Context ? (Context) ctx : new Context(ctx.getKey(), ctx.getValue()))), ent.getValue());/*ww w . jav a2 s . c o m*/ } return ret.build(); }
From source file:com.yahoo.yqlplus.engine.internal.plan.types.base.BaseTypeAdapter.java
private static TypeWidget registerJavaType(YQLType type, ImmutableMap.Builder<String, TypeWidget> m, TypeWidget btw) {//from ww w. j a v a 2 s . c o m m.put(btw.getJVMType().getDescriptor(), NullableTypeWidget.create(btw)); return btw; }
From source file:com.google.devtools.moe.client.translation.editors.RenamingEditor.java
/** Preprocesses the mappings from the given {@link EditorConfig}. */ private static Map<Pattern, String> mappingsFromConfig(Gson gson, EditorConfig config) { Map<String, String> mappings = gson.fromJson(config.mappings(), MAP_TYPE); ImmutableMap.Builder<Pattern, String> regexMappingsBuilder = ImmutableMap.builder(); for (String mapping : mappings.keySet()) { regexMappingsBuilder.put(Pattern.compile(config.useRegex() ? mapping : Pattern.quote(mapping)), mappings.get(mapping));//from w ww .j a v a 2 s. c om } return regexMappingsBuilder.build(); }
From source file:eu.thebluemountain.customers.dctm.brownbag.badcontentslister.db.DCReader.java
/** * The method returns the function which, given a format's name, * returns the format's extension.//from w ww .jav a 2 s .co m * @param jdbc provides access to the source * @return the function which, given a format name, returns the matching * extension if any. */ private static Function<String, String> makeExtensions(JDBCConnection jdbc) { String sql = "SELECT name, dos_extension " + "FROM dm_format_s WHERE " + "(dos_extension IS NOT NULL AND dos_extension <> ' ')"; try { try (Statement stmt = jdbc.connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet rs = stmt.executeQuery(sql)) { ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); while (rs.next()) { String name = rs.getString(1); String ext = "." + rs.getString(2); builder.put(name, ext); } return Functions.forMap(builder.build(), null); } } catch (SQLException e) { throw new IllegalStateException(e); } }