List of usage examples for com.google.common.collect ImmutableMap.Builder put
public final V put(K k, V v)
From source file:com.mengge.MobileCommand.java
/** * @param param is a parameter name.//from w w w . j a va 2 s .co m * @param value is the parameter value. * @return built {@link ImmutableMap}. */ protected static ImmutableMap<String, Object> prepareArguments(String param, Object value) { ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder(); builder.put(param, value); return builder.build(); }
From source file:com.spectralogic.ds3client.helpers.strategy.StrategyUtils.java
public static ImmutableMap<UUID, JobNode> buildNodeMap(final Iterable<JobNode> nodes) { final ImmutableMap.Builder<UUID, JobNode> nodeMap = ImmutableMap.builder(); for (final JobNode node : nodes) { nodeMap.put(node.getId(), node); }// w ww . j ava 2 s . c om return nodeMap.build(); }
From source file:org.sonar.server.computation.task.projectanalysis.api.posttask.ScannerContextImpl.java
static ScannerContextImpl from(CloseableIterator<ScannerReport.ContextProperty> it) { try {// ww w . j a va2 s . c om ImmutableMap.Builder<String, String> mapBuilder = ImmutableMap.builder(); while (it.hasNext()) { ScannerReport.ContextProperty prop = it.next(); mapBuilder.put(prop.getKey(), prop.getValue()); } return new ScannerContextImpl(mapBuilder.build()); } finally { it.close(); } }
From source file:com.google.devtools.common.options.OptionFilterDescriptions.java
public static ImmutableMap<OptionMetadataTag, String> getOptionMetadataTagDescription(String productName) { ImmutableMap.Builder<OptionMetadataTag, String> effectTagDescriptionBuilder = ImmutableMap.builder(); effectTagDescriptionBuilder .put(OptionMetadataTag.EXPERIMENTAL, "This option triggers an experimental feature with no guarantees of functionality.") .put(OptionMetadataTag.INCOMPATIBLE_CHANGE, "This option triggers a breaking change. Use this option to test your migration " + "readiness or get early access to the new feature") .put(OptionMetadataTag.DEPRECATED, "This option is deprecated. It might be that the feature it affects is deprecated, " + "or that another method of supplying the information is preferred.") .put(OptionMetadataTag.HIDDEN, // Here for completeness, these options are UNDOCUMENTED. "This option should not be used by a user, and should not be logged.") .put(OptionMetadataTag.INTERNAL, // Here for completeness, these options are UNDOCUMENTED. "This option isn't even a option, and should not be logged."); return effectTagDescriptionBuilder.build(); }
From source file:com.spectralogic.ds3autogen.docspec.DocSpecConverter.java
/** * Converts a list of ParamDescriptors into a param documentation map * @return Map of parameter names (key) and descriptions (value) *//*from ww w .jav a2 s. com*/ protected static ImmutableMap<String, String> toParamDocs(final List<ParamDescriptor> paramDescriptors) { if (isEmpty(paramDescriptors)) { return ImmutableMap.of(); } final ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); for (final ParamDescriptor pd : paramDescriptors) { builder.put(pd.getName(), pd.getDescription()); } return builder.build(); }
From source file:org.tensorics.core.tensor.operations.TensorInternals.java
/** * Returns a map representing the content of the given tensor. The concrete instance of the map might differ * depending on the implementation of the passed in tensor: Tensor implementations can offer a more efficient way to * retrieve a map from them, by implementing the {@link Mappable} interface. If this interface is present, then its * {@link Mappable#asMap()} method will be called. Otherwise, as a fallback, a new immutable map will be created * from information from the shape of the passed in tensor and its values. * /*from w w w .jav a 2 s .c om*/ * @param tensor the tensor from which a map should be returned * @return a map representing the content of the tensor * @throws NullPointerException in case the passed in tensor is {@code null} */ public static <V> Map<Position, V> mapFrom(Tensor<V> tensor) { requireNonNull(tensor, "tensor must not be null"); if (tensor instanceof Mappable) { @SuppressWarnings("unchecked") Mappable<V> mappable = (Mappable<V>) tensor; return mappable.asMap(); } ImmutableMap.Builder<Position, V> builder = ImmutableMap.builder(); for (Position position : tensor.shape().positionSet()) { builder.put(position, tensor.get(position)); } return builder.build(); }
From source file:com.facebook.buck.jvm.java.JavaPackageFinderSerializer.java
public static ImmutableMap<String, Object> serialize(JavaPackageFinder packageFinder) { ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder(); if (packageFinder instanceof DefaultJavaPackageFinder) { builder.put(TYPE, TYPE_DEFAULT); builder.put(PATH_ELEMENTS, ((DefaultJavaPackageFinder) packageFinder).getPathElements().asList()); builder.put(PATHS_FROM_ROOT, ((DefaultJavaPackageFinder) packageFinder).getPathsFromRoot().asList()); } else if (packageFinder instanceof ResourcesRootPackageFinder) { builder.put(TYPE, TYPE_RESOURCE_ROOT); builder.put(RESOURCES_ROOT, ((ResourcesRootPackageFinder) packageFinder).getResourcesRoot().toString()); builder.put(FALLBACK_FINDER,//w w w .j av a 2 s . c o m serialize(((ResourcesRootPackageFinder) packageFinder).getFallbackFinder())); } else { throw new RuntimeException( String.format("Cannot serialize JavaPackageFinder with class: %s", packageFinder.getClass())); } return builder.build(); }
From source file:com.facebook.buck.command.config.AbstractConfigIgnoredByDaemon.java
private static ImmutableMap<String, ImmutableSet<String>> getIgnoreFieldsForDaemonRestart() { ImmutableMap.Builder<String, ImmutableSet<String>> ignoreFieldsForDaemonRestartBuilder = ImmutableMap .builder();/*from w ww . jav a 2 s .co m*/ ignoreFieldsForDaemonRestartBuilder.put("apple", ImmutableSet.of("generate_header_symlink_tree_only")); ignoreFieldsForDaemonRestartBuilder.put("build", ImmutableSet.of("threads")); ignoreFieldsForDaemonRestartBuilder.put("cache", ImmutableSet.of("dir", "dir_mode", "http_mode", "http_url", "mode", "slb_server_pool")); ignoreFieldsForDaemonRestartBuilder.put("client", ImmutableSet.of("id", "skip-action-graph-cache")); ignoreFieldsForDaemonRestartBuilder.put("intellij", ImmutableSet.of("multi_cell_module_support")); ignoreFieldsForDaemonRestartBuilder.put("log", ImmutableSet.of("chrome_trace_generation", "compress_traces", "max_traces", "public_announcements", "log_build_id_to_console_enabled", "build_details_template")); ignoreFieldsForDaemonRestartBuilder.put("project", ImmutableSet.of("ide_prompt", "ide_force_kill")); ignoreFieldsForDaemonRestartBuilder.put("ui", ImmutableSet.of("superconsole", "thread_line_limit", "thread_line_output_max_columns", "warn_on_config_file_overrides", "warn_on_config_file_overrides_ignored_files")); ignoreFieldsForDaemonRestartBuilder.put("color", ImmutableSet.of("ui")); ignoreFieldsForDaemonRestartBuilder.put("version_control", ImmutableSet.of("generate_statistics")); return ignoreFieldsForDaemonRestartBuilder.build(); }
From source file:com.jgaap.backend.DistanceFunctions.java
private static ImmutableMap<String, DistanceFunction> loadDistanceFunctionsMap() { // Load the distance functions dynamically ImmutableMap.Builder<String, DistanceFunction> builder = ImmutableMap.builder(); for (DistanceFunction distanceFunction : DISTANCE_FUNCTIONS) { builder.put(distanceFunction.displayName().toLowerCase().trim(), distanceFunction); }//from w ww . j a v a 2 s . c om return builder.build(); }
From source file:com.google.googlejavaformat.java.EclipseJavadocFormatter.java
private static String formatJavadocInternal(String input, int indent, JavaFormatterOptions options) { ImmutableMap.Builder<String, String> optionBuilder = ImmutableMap.<String, String>builder(); optionBuilder.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT, "true"); optionBuilder.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); optionBuilder.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, Integer.toString(options.indentationMultiplier())); optionBuilder.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, Integer.toString(options.maxLineLength() - indent)); optionBuilder.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, Integer.toString(options.maxLineLength())); optionBuilder.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_PARAMETER_DESCRIPTION, DefaultCodeFormatterConstants.FALSE); optionBuilder.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_INSERT_NEW_LINE_FOR_PARAMETER, JavaCore.DO_NOT_INSERT);//from w ww . j a v a 2 s .c om optionBuilder.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT, DefaultCodeFormatterConstants.FALSE); optionBuilder.put(DefaultCodeFormatterConstants.FORMATTER_JOIN_LINES_IN_COMMENTS, DefaultCodeFormatterConstants.TRUE); optionBuilder.put(DefaultCodeFormatterConstants.FORMATTER_JOIN_WRAPPED_LINES, DefaultCodeFormatterConstants.TRUE); // Disable indenting root tags for now since it indents more than 4 spaces optionBuilder.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_ROOT_TAGS, DefaultCodeFormatterConstants.FALSE); optionBuilder.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_SOURCE, DefaultCodeFormatterConstants.FALSE); optionBuilder.put(JavaCore.COMPILER_COMPLIANCE, "1.8"); optionBuilder.put(JavaCore.COMPILER_SOURCE, "1.8"); optionBuilder.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, "1.8"); DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter( new DefaultCodeFormatterOptions(optionBuilder.build())); TextEdit edit = codeFormatter.format(CodeFormatter.K_JAVA_DOC, input, /*offset*/ 0, input.length(), // eclipse doesn't indent comments reliably, so always request no indent and fix it // up later in JavaCommentsHelper /*indent*/ 0, /*lineSeparator*/ null); if (edit == null) { throw new RuntimeException("error formatting javadoc"); } Document document = new Document(input); try { edit.apply(document); } catch (BadLocationException e) { throw new RuntimeException("error formatting javadoc", e); } return document.get(); }