List of usage examples for com.google.common.collect ImmutableMap.Builder put
public final V put(K k, V v)
From source file:com.google.devtools.build.lib.runtime.commands.InfoCommand.java
static Map<String, InfoItem> getHardwiredInfoItemMap(OptionsProvider commandOptions, String productName) { List<InfoItem> hardwiredInfoItems = ImmutableList.<InfoItem>of(new InfoItem.WorkspaceInfoItem(), new InfoItem.InstallBaseInfoItem(), new InfoItem.OutputBaseInfoItem(productName), new InfoItem.ExecutionRootInfoItem(), new InfoItem.OutputPathInfoItem(), new InfoItem.ClientEnv(), new InfoItem.BlazeBinInfoItem(productName), new InfoItem.BlazeGenfilesInfoItem(productName), new InfoItem.BlazeTestlogsInfoItem(productName), new InfoItem.CommandLogInfoItem(), new InfoItem.MessageLogInfoItem(), new InfoItem.ReleaseInfoItem(productName), new InfoItem.ServerPidInfoItem(productName), new InfoItem.PackagePathInfoItem(commandOptions), new InfoItem.UsedHeapSizeInfoItem(), new InfoItem.UsedHeapSizeAfterGcInfoItem(), new InfoItem.CommitedHeapSizeInfoItem(), new InfoItem.MaxHeapSizeInfoItem(), new InfoItem.GcTimeInfoItem(), new InfoItem.GcCountInfoItem(), new InfoItem.DefaultsPackageInfoItem(), new InfoItem.BuildLanguageInfoItem(), new InfoItem.DefaultPackagePathInfoItem(commandOptions)); ImmutableMap.Builder<String, InfoItem> result = new ImmutableMap.Builder<>(); for (InfoItem item : hardwiredInfoItems) { result.put(item.getName(), item); }//from w w w .jav a 2 s . c om return result.build(); }
From source file:com.b2international.snowowl.snomed.api.rest.SnomedMergingRestRequests.java
public static ValidatableResponse createMerge(IBranchPath source, IBranchPath target, String commitComment, String reviewId) {//from w w w . j av a 2 s. c om ImmutableMap.Builder<String, Object> requestBuilder = ImmutableMap.<String, Object>builder() .put("source", source.getPath()).put("target", target.getPath()) .put("commitComment", commitComment); if (null != reviewId) { requestBuilder.put("reviewId", reviewId); } return givenAuthenticatedRequest(SCT_API).contentType(ContentType.JSON).body(requestBuilder.build()) .post("/merges").then(); }
From source file:org.apache.beam.runners.flink.translation.functions.FlinkBatchSideInputHandlerFactory.java
/** * Creates a new state handler for the given stage. Note that this requires a traversal of the * stage itself, so this should only be called once per stage rather than once per bundle. *///from www. j a v a 2 s . c om static FlinkBatchSideInputHandlerFactory forStage(ExecutableStage stage, RuntimeContext runtimeContext) { ImmutableMap.Builder<SideInputId, PCollectionNode> sideInputBuilder = ImmutableMap.builder(); for (SideInputReference sideInput : stage.getSideInputs()) { sideInputBuilder.put(SideInputId.newBuilder().setTransformId(sideInput.transform().getId()) .setLocalName(sideInput.localName()).build(), sideInput.collection()); } return new FlinkBatchSideInputHandlerFactory(sideInputBuilder.build(), runtimeContext); }
From source file:com.google.caliper.runner.FullCartesianExperimentSelector.java
protected static <K, V> ImmutableMap<K, V> zip(Set<K> keys, Collection<V> values) { ImmutableMap.Builder<K, V> builder = ImmutableMap.builder(); Iterator<K> keyIterator = keys.iterator(); Iterator<V> valueIterator = values.iterator(); while (keyIterator.hasNext() && valueIterator.hasNext()) { builder.put(keyIterator.next(), valueIterator.next()); }/*from w w w . j a va 2 s. c om*/ if (keyIterator.hasNext() || valueIterator.hasNext()) { throw new AssertionError(); // I really screwed up, then. } return builder.build(); }
From source file:com.opengamma.strata.collect.io.IniFile.java
/** * Parses the specified source as an INI file. * <p>/* w ww . ja v a 2 s.c o m*/ * This parses the specified character source expecting an INI file format. * The resulting instance can be queried for each section in the file. * * @param source the INI file resource * @return the INI file * @throws UncheckedIOException if an IO exception occurs * @throws IllegalArgumentException if the file cannot be parsed */ public static IniFile of(CharSource source) { ArgChecker.notNull(source, "source"); ImmutableList<String> lines = Unchecked.wrap(() -> source.readLines()); Map<String, Multimap<String, String>> parsedIni = parse(lines); ImmutableMap.Builder<String, PropertySet> builder = ImmutableMap.builder(); parsedIni.forEach((sectionName, sectionData) -> builder.put(sectionName, PropertySet.of(sectionData))); return new IniFile(builder.build()); }
From source file:com.facebook.buck.apple.toolchain.impl.ProvisioningProfileMetadataFactory.java
public static ProvisioningProfileMetadata fromProvisioningProfilePath(ProcessExecutor executor, ImmutableList<String> readCommand, Path profilePath) throws IOException, InterruptedException { Set<Option> options = EnumSet.of(Option.EXPECTING_STD_OUT); // Extract the XML from its signed message wrapper. ProcessExecutorParams processExecutorParams = ProcessExecutorParams.builder().addAllCommand(readCommand) .addCommand(profilePath.toString()).build(); ProcessExecutor.Result result; result = executor.launchAndExecute(processExecutorParams, options, /* stdin */ Optional.empty(), /* timeOutMs */ Optional.empty(), /* timeOutHandler */ Optional.empty()); if (result.getExitCode() != 0) { throw new IOException(result.getMessageForResult("Invalid provisioning profile: " + profilePath)); }// w w w. ja va2s . c o m try { NSDictionary plist = (NSDictionary) PropertyListParser.parse(result.getStdout().get().getBytes()); Date expirationDate = ((NSDate) plist.get("ExpirationDate")).getDate(); String uuid = ((NSString) plist.get("UUID")).getContent(); ImmutableSet.Builder<HashCode> certificateFingerprints = ImmutableSet.builder(); NSArray certificates = (NSArray) plist.get("DeveloperCertificates"); HashFunction hasher = Hashing.sha1(); if (certificates != null) { for (NSObject item : certificates.getArray()) { certificateFingerprints.add(hasher.hashBytes(((NSData) item).bytes())); } } ImmutableMap.Builder<String, NSObject> builder = ImmutableMap.builder(); NSDictionary entitlements = ((NSDictionary) plist.get("Entitlements")); for (String key : entitlements.keySet()) { builder = builder.put(key, entitlements.objectForKey(key)); } String appID = entitlements.get("application-identifier").toString(); ProvisioningProfileMetadata.Builder provisioningProfileMetadata = ProvisioningProfileMetadata.builder(); if (plist.get("Platform") != null) { for (Object platform : (Object[]) plist.get("Platform").toJavaObject()) { provisioningProfileMetadata.addPlatforms((String) platform); } } return provisioningProfileMetadata.setAppID(ProvisioningProfileMetadata.splitAppID(appID)) .setExpirationDate(expirationDate).setUUID(uuid).setProfilePath(profilePath) .setEntitlements(builder.build()) .setDeveloperCertificateFingerprints(certificateFingerprints.build()).build(); } catch (Exception e) { throw new IllegalArgumentException("Malformed embedded plist: " + e); } }
From source file:org.dishevelled.bio.assembly.gfa1.Containment.java
/** * Parse a containment GFA 1.0 record from the specified value. * * @param value value, must not be null// ww w .ja va2 s.c om * @return a containment GFA 1.0 record parsed from the specified value */ public static Containment valueOf(final String value) { checkNotNull(value); checkArgument(value.startsWith("C"), "value must start with C"); List<String> tokens = Splitter.on("\t").splitToList(value); if (tokens.size() < 7) { throw new IllegalArgumentException("value must have at least seven tokens, was " + tokens.size()); } Reference container = Reference.splitValueOf(tokens.get(1), tokens.get(2)); Reference contained = Reference.splitValueOf(tokens.get(3), tokens.get(4)); int position = Integer.parseInt(tokens.get(5)); String overlap = "*".equals(tokens.get(6)) ? null : tokens.get(6); ImmutableMap.Builder<String, Tag> tags = ImmutableMap.builder(); for (int i = 7; i < tokens.size(); i++) { Tag tag = Tag.valueOf(tokens.get(i)); tags.put(tag.getName(), tag); } return new Containment(container, contained, position, overlap, tags.build()); }
From source file:com.google.devtools.build.lib.rules.objc.IosDeviceProvider.java
private static Map<String, Object> getSkylarkFields(Builder builder) { ImmutableMap.Builder<String, Object> skylarkFields = new ImmutableMap.Builder<String, Object>() .put("type", builder.type).put("ios_version", builder.iosVersion.toString()); if (builder.xcodeVersion != null) { skylarkFields.put("xcode_version", builder.xcodeVersion.toString()); }//from w w w. j a va 2 s.com return skylarkFields.build(); }
From source file:com.spectralogic.ds3contractcomparator.print.htmlprinter.generators.row.ModifiedHtmlRowGenerator.java
/** * Creates a map between the specified property in string form, and the object containing the property. *//*from w w w. j a v a 2 s .c om*/ static <T> ImmutableMap<String, T> toPropertyMap(final ImmutableList<T> objects, final String property) { if (isEmpty(objects)) { return ImmutableMap.of(); } final ImmutableMap.Builder<String, T> builder = ImmutableMap.builder(); objects.forEach(o -> { try { builder.put(BeanUtils.getProperty(o, property), o); } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { LOG.warn("Cannot create property map of object from class " + o.getClass().toString() + " using property " + property + ": " + e.getMessage(), e); } }); return builder.build(); }
From source file:com.facebook.buck.distributed.DistBuildState.java
private static Config createConfig(BuildJobStateBuckConfig remoteBuckConfig) { ImmutableMap<String, ImmutableMap<String, String>> rawConfig = ImmutableMap .copyOf(Maps.transformValues(remoteBuckConfig.getRawBuckConfig(), input -> { ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); for (OrderedStringMapEntry entry : input) { builder.put(entry.getKey(), entry.getValue()); }//from w w w . java 2 s . c o m return builder.build(); })); return new Config(RawConfig.of(rawConfig)); }