List of usage examples for com.google.common.collect ImmutableMap.Builder put
public final V put(K k, V v)
From source file:com.sun.tools.hat.internal.lang.openjdk6.JavaConcHash.java
public static JavaConcHash make(JavaObject chm) { List<JavaObject> segments = Models.getFieldObjectArray(chm, "segments", JavaObject.class); if (segments == null) return null; final ImmutableMap.Builder<JavaThing, JavaThing> builder = ImmutableMap.builder(); HashCommon.KeyValueVisitor visitor = new HashCommon.KeyValueVisitor() { @Override//from ww w. ja va 2 s . c o m public void visit(JavaThing key, JavaThing value) { builder.put(key, value); } }; for (JavaObject segment : segments) { List<JavaObject> table = Models.getFieldObjectArray(segment, "table", JavaObject.class); if (table != null) HashCommon.walkHashTable(table, "key", "value", "next", visitor); } return new JavaConcHash(builder.build()); }
From source file:com.facebook.buck.util.Inis.java
public static ImmutableMap<String, ImmutableMap<String, String>> read(Reader reader) throws IOException { Ini ini = new Ini(); ini.load(reader);//from www. j ava 2 s .co m validateIni(ini); ImmutableMap.Builder<String, ImmutableMap<String, String>> sectionsToEntries = ImmutableMap.builder(); for (String sectionName : ini.keySet()) { ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); Profile.Section section = ini.get(sectionName); for (String propertyName : section.keySet()) { String propertyValue = section.get(propertyName); builder.put(propertyName, propertyValue); } ImmutableMap<String, String> sectionToEntries = builder.build(); sectionsToEntries.put(sectionName, sectionToEntries); } return sectionsToEntries.build(); }
From source file:org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.container.ContainerStateProvider.java
private static Map<String, Integer> buildEventNames(IKernelAnalysisEventLayout layout) { ImmutableMap.Builder<String, Integer> builder = ImmutableMap.builder(); builder.put(layout.eventSchedProcessFork(), SCHED_PROCESS_FORK); builder.put(layout.eventSchedProcessFree(), SCHED_PROCESS_FREE); builder.put(layout.eventSchedSwitch(), SCHED_SWITCH); builder.put(layout.eventStatedumpProcessState(), STATEDUMP_PROCESS); return checkNotNull(builder.build()); }
From source file:com.google.idea.blaze.java.sync.projectstructure.JavaSourceFolderProvider.java
private static ImmutableMap<File, BlazeContentEntry> blazeContentEntries(@Nullable BlazeJavaSyncData syncData) { if (syncData == null) { return ImmutableMap.of(); }//w w w. j a va 2 s . c om ImmutableMap.Builder<File, BlazeContentEntry> builder = ImmutableMap.builder(); for (BlazeContentEntry blazeContentEntry : syncData.importResult.contentEntries) { builder.put(blazeContentEntry.contentRoot, blazeContentEntry); } return builder.build(); }
From source file:org.graylog2.indexer.gson.GsonUtils.java
@Nullable public static Map<String, JsonElement> entrySetAsMap(JsonObject jsonObject) { if (jsonObject == null) { return null; } else {/*from w ww . j a va 2s . c o m*/ final ImmutableMap.Builder<String, JsonElement> mapBuilder = ImmutableMap.builder(); final Set<Map.Entry<String, JsonElement>> entrySet = jsonObject.entrySet(); for (Map.Entry<String, JsonElement> entry : entrySet) { mapBuilder.put(entry.getKey(), entry.getValue()); } return mapBuilder.build(); } }
From source file:com.squareup.wire.schema.Schema.java
private static ImmutableMap<String, Service> buildServicesIndex(Iterable<ProtoFile> protoFiles) { ImmutableMap.Builder<String, Service> result = ImmutableMap.builder(); for (ProtoFile protoFile : protoFiles) { for (Service service : protoFile.services()) { result.put(service.type().toString(), service); }// w w w . ja va 2 s .co m } return result.build(); }
From source file:org.dishevelled.bio.assembly.gfa1.Link.java
/** * Parse a link GFA 1.0 record from the specified value. * * @param value value, must not be null/*from w w w . j av a2 s . c om*/ * @return a link GFA 1.0 record parsed from the specified value */ public static Link valueOf(final String value) { checkNotNull(value); checkArgument(value.startsWith("L"), "value must start with L"); List<String> tokens = Splitter.on("\t").splitToList(value); if (tokens.size() < 6) { throw new IllegalArgumentException("value must have at least six tokens, was " + tokens.size()); } Reference source = Reference.splitValueOf(tokens.get(1), tokens.get(2)); Reference target = Reference.splitValueOf(tokens.get(3), tokens.get(4)); String overlap = "*".equals(tokens.get(5)) ? null : tokens.get(5); ImmutableMap.Builder<String, Tag> tags = ImmutableMap.builder(); for (int i = 6; i < tokens.size(); i++) { Tag tag = Tag.valueOf(tokens.get(i)); tags.put(tag.getName(), tag); } return new Link(source, target, overlap, tags.build()); }
From source file:com.haulmont.bali.util.ParamsMap.java
private static void put(ImmutableMap.Builder<String, Object> builder, String key, Object value) { if (key == null) { throw new IllegalArgumentException("key should not be null"); }/*from w w w .j a va2 s.c o m*/ if (value != null) { builder.put(key, value); } }
From source file:com.sun.tools.hat.internal.lang.openjdk6.JavaHash.java
public static JavaHash make(JavaObject hash) { List<JavaObject> table = Models.getFieldObjectArray(hash, "table", JavaObject.class); if (table == null) return null; final ImmutableMap.Builder<JavaThing, JavaThing> builder = ImmutableMap.builder(); HashCommon.walkHashTable(table, "key", "value", "next", new HashCommon.KeyValueVisitor() { @Override//w w w . j av a 2s . c om public void visit(JavaThing key, JavaThing value) { builder.put(key, value); } }); return new JavaHash(builder.build()); }
From source file:com.continuuity.loom.scheduler.task.TaskConfig.java
/** * Create a task config from the given input. * * @param cluster Cluster the task is operating on. * @param node Node the task should take place on. * @param service Service the task is operating on. * May be null for tasks that are on the node itself but not on a service. * @param clusterConfig Cluster config with expanded macros. * @param action Action to perform.//from ww w .j a va2 s. c o m * @param clusterNodes Collection of all nodes in the cluster. * @return Task config created from the given input. */ public static TaskConfig from(Cluster cluster, Node node, Service service, JsonObject clusterConfig, ProvisionerAction action, Collection<Node> clusterNodes) { Provider provider = cluster.getProvider(); // will be null if the config is for a node action like create, confirm, bootstrap, delete TaskServiceAction taskServiceAction = service == null ? null : new TaskServiceAction(service.getName(), service.getProvisionerActions().get(action)); ImmutableMap.Builder builder = ImmutableMap.<String, NodeProperties>builder(); if (clusterNodes != null) { for (Node clusterNode : clusterNodes) { builder.put(clusterNode.getId(), clusterNode.getProperties()); } } JsonObject provisionerResults = node.getProvisionerResults(); return new TaskConfig(node.getProperties(), provider, builder.build(), taskServiceAction, clusterConfig, provisionerResults); }