List of usage examples for com.google.common.collect ImmutableMap.Builder put
public final V put(K k, V v)
From source file:com.verigreen.collector.buildverification.JenkinsVerifier.java
public static void triggerJob(CommitItem commitItem) { String branchName = commitItem.getMergedBranchName(); try {/*from w w w . j a va2s . c om*/ VerigreenLogger.get().log(JenkinsVerifier.class.getName(), RuntimeUtils.getCurrentMethodName(), String.format("Triggering job [%s] for branch [%s]", CollectorApi.getVerificationJobName(), branchName)); Map<String, String> commitParams = VerigreenNeededLogic.checkJenkinsMode(commitItem); commitItem.setTriggeredAttempt(true); jenkinsUpdater.register(commitItem); CollectorApi.getCommitItemContainer().save(commitItem); ImmutableMap.Builder<String, String> finalJenkinsParams = ImmutableMap.<String, String>builder() .put("token", VerigreenNeededLogic.properties.getProperty("jenkins.password")); finalJenkinsParams.put(CollectorApi.getBranchParamName(), branchName); for (String key : commitParams.keySet()) { finalJenkinsParams.put(key, commitParams.get(key)); } final ImmutableMap<String, String> params = finalJenkinsParams.build(); job2Verify.build(params); } catch (IOException e) { VerigreenLogger.get().error(JenkinsVerifier.class.getName(), RuntimeUtils.getCurrentMethodName(), String.format("Failed to trigger build for job [%s] with branch [%s]", CollectorApi.getVerificationJobName(), branchName), e); } }
From source file:com.huangyunkun.jviff.service.StepContainer.java
private static void assembleParser() { ImmutableMap.Builder<String, BaseStepParser> builder = ImmutableMap.builder(); for (Class<? extends BaseStepParser> parserClass : Constant.STEP_PARSER_LIST) { try {/*w ww . j a va 2 s. c om*/ BaseStepParser stepParser = parserClass.newInstance(); builder.put(stepParser.getActionKey(), stepParser); } catch (Exception e) { throw new RuntimeException(); } } parserImmutableMap = builder.build(); }
From source file:me.yanaga.guava.stream.MoreCollectors.java
private static <T, K, V, M extends ImmutableMap<K, V>> Collector<T, ?, M> toImmutableMap( Supplier<ImmutableMap.Builder<K, V>> supplier, Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, Collector.Characteristics... characteristics) { return Collector.of(supplier, new BiConsumer<ImmutableMap.Builder<K, V>, T>() { @Override/*from w w w . jav a2 s . c o m*/ public void accept(ImmutableMap.Builder<K, V> objectObjectBuilder, T t) { objectObjectBuilder.put(keyMapper.apply(t), valueMapper.apply(t)); } }, new BinaryOperator<ImmutableMap.Builder<K, V>>() { @Override public ImmutableMap.Builder<K, V> apply(ImmutableMap.Builder<K, V> kuBuilder, ImmutableMap.Builder<K, V> kuBuilder2) { return kuBuilder.putAll(kuBuilder2.build()); } }, new Function<ImmutableMap.Builder<K, V>, M>() { @SuppressWarnings("unchecked") @Override public M apply(ImmutableMap.Builder<K, V> kuBuilder) { return (M) kuBuilder.build(); } }, characteristics); }
From source file:org.dishevelled.bio.assembly.gfa1.Path.java
/** * Parse a path GFA 1.0 record from the specified value. * * @param value value, must not be null/* w ww . j a va 2 s . c o m*/ * @return a path GFA 1.0 record parsed from the specified value */ public static Path valueOf(final String value) { checkNotNull(value); checkArgument(value.startsWith("P"), "value must start with P"); List<String> tokens = Splitter.on("\t").splitToList(value); if (tokens.size() < 4) { throw new IllegalArgumentException("value must have at least four tokens, was " + tokens.size()); } String name = tokens.get(1); List<Reference> segments = Splitter.on(",").splitToList(tokens.get(2)).stream().map(Reference::valueOf) .collect(Collectors.toList()); List<String> overlaps = "*".equals(tokens.get(3)) ? null : ImmutableList.copyOf(Splitter.on(",").split(tokens.get(3))); ImmutableMap.Builder<String, Tag> tags = ImmutableMap.builder(); for (int i = 4; i < tokens.size(); i++) { Tag tag = Tag.valueOf(tokens.get(i)); tags.put(tag.getName(), tag); } return new Path(name, segments, overlaps, tags.build()); }
From source file:com.spectralogic.ds3cli.util.Metadata.java
public static ImmutableMap<String, String> parse(final String[] metadataArgs) { final ImmutableMap.Builder<String, String> metadataBuilder = ImmutableMap.builder(); for (final String arg : metadataArgs) { final String[] keyValue = arg.split(":"); if (keyValue.length != 2) { throw new IllegalArgumentException("Malformed metadata entry: " + arg); }/* w ww.j ava 2s .com*/ metadataBuilder.put(keyValue[0], keyValue[1]); } return metadataBuilder.build(); }
From source file:com.facebook.buck.util.config.Inis.java
private static ImmutableMap<String, ImmutableMap<String, String>> toMap(Ini 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); }/*from w w w . ja v a 2 s . c om*/ ImmutableMap<String, String> sectionToEntries = builder.build(); sectionsToEntries.put(sectionName, sectionToEntries); } return sectionsToEntries.build(); }
From source file:co.cask.cdap.logging.context.LoggingContextHelper.java
private static Map<String, String> getMetricsTagsFromSystemContext(ServiceLoggingContext context) { ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); builder.put(Constants.Metrics.Tag.NAMESPACE, Constants.SYSTEM_NAMESPACE); builder.put(Constants.Metrics.Tag.COMPONENT, context.getSystemTagsMap().get(ServiceLoggingContext.TAG_SERVICE_ID).getValue()); return builder.build(); }
From source file:com.mengge.MobileCommand.java
/** * @param params is the array with parameter names. * @param values is the array with parameter values. * @return built {@link ImmutableMap}.//from ww w . ja v a 2 s . c o m */ protected static ImmutableMap<String, Object> prepareArguments(String[] params, Object[] values) { ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder(); for (int i = 0; i < params.length; i++) { if (!StringUtils.isBlank(params[i]) && (values[i] != null)) { builder.put(params[i], values[i]); } } return builder.build(); }
From source file:com.google.gxp.compiler.parser.GxpNamespace.java
private static Map<String, ElementType> initElements() { ImmutableMap.Builder<String, ElementType> builder = ImmutableMap.builder(); for (ElementType type : ElementType.values()) { builder.put(type.name().toLowerCase().replace('_', '-'), type); }//w w w . j a v a 2s. c o m return builder.build(); }
From source file:org.apache.druid.query.groupby.GroupByQueryHelper.java
/** * Returns types for fields that will appear in the Rows output from "query". Useful for feeding them into * {@link RowBasedColumnSelectorFactory}. * * @param query groupBy query/*from w w w.j av a 2s . c o m*/ * * @return row types */ public static Map<String, ValueType> rowSignatureFor(final GroupByQuery query) { final ImmutableMap.Builder<String, ValueType> types = ImmutableMap.builder(); for (DimensionSpec dimensionSpec : query.getDimensions()) { types.put(dimensionSpec.getOutputName(), dimensionSpec.getOutputType()); } for (AggregatorFactory aggregatorFactory : query.getAggregatorSpecs()) { final String typeName = aggregatorFactory.getTypeName(); final ValueType valueType; if (typeName != null) { valueType = GuavaUtils.getEnumIfPresent(ValueType.class, StringUtils.toUpperCase(typeName)); } else { valueType = null; } if (valueType != null) { types.put(aggregatorFactory.getName(), valueType); } } // Don't include post-aggregators since we don't know what types they are. return types.build(); }