List of usage examples for com.google.common.collect ImmutableMap.Builder put
public final V put(K k, V v)
From source file:com.isotrol.impe3.core.support.IdentifiableMaps.java
/** * Creates a builder for a new hierarchy of identifiable objects. * @param <V> Value type.//from w w w . ja v a 2s. c om * @return A new builder. */ public static <V extends Identifiable> ImmutableMap<UUID, V> immutableOf(Iterable<? extends V> values) { final ImmutableMap.Builder<UUID, V> builder = ImmutableMap.builder(); for (V value : values) { builder.put(value.getId(), value); } return builder.build(); }
From source file:org.apache.beam.runners.direct.RootProviderRegistry.java
public static RootProviderRegistry defaultRegistry(EvaluationContext context) { ImmutableMap.Builder<String, RootInputProvider<?, ?, ?>> defaultProviders = ImmutableMap.builder(); defaultProviders.put(PTransformTranslation.READ_TRANSFORM_URN, ReadEvaluatorFactory.inputProvider(context)) .put(DIRECT_TEST_STREAM_URN, new TestStreamEvaluatorFactory.InputProvider(context)) .put(FLATTEN_TRANSFORM_URN, new EmptyInputProvider()); return new RootProviderRegistry(defaultProviders.build()); }
From source file:org.codice.ddf.admin.application.service.migratable.JsonSupport.java
public static Map<String, Object> toImmutableMap(Object... keysAndValues) { final ImmutableMap.Builder builder = ImmutableMap.builder(); for (int i = 0; i < keysAndValues.length; i += 2) { builder.put(keysAndValues[i], keysAndValues[i + 1]); }//from w w w. j a v a 2 s . c om return builder.build(); }
From source file:de.maxikg.messenger.publisher.AmqpPublisher.java
private static Map<String, Object> headers(String type) { ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder(); if (type != null) builder.put(AmqpUtils.HEADER_TYPE, LongStringHelper.asLongString(type)); return builder.build(); }
From source file:com.helion3.keys.commands.KeysCommands.java
/** * Build a complete command hierarchy/*from w ww . ja v a 2 s. c o m*/ * @return */ public static CommandSpec getCommand() { ImmutableMap.Builder<List<String>, CommandCallable> builder = ImmutableMap.builder(); builder.put(ImmutableList.of("add"), AddKeyCommand.getCommand()); builder.put(ImmutableList.of("remove", "del", "delete"), RemoveKeyCommand.getCommand()); builder.put(ImmutableList.of("reload"), ReloadCommand.getCommand()); builder.put(ImmutableList.of("?", "help"), HelpCommand.getCommand()); return CommandSpec.builder().permission("keys.use").executor(new CommandExecutor() { @Override public CommandResult execute(CommandSource src, CommandContext args) throws CommandException { src.sendMessage(Text.of(Format.heading(TextColors.GRAY, "By ", TextColors.GOLD, "viveleroi.\n"), TextColors.GRAY, "IRC: ", TextColors.WHITE, "irc.esper.net #helion3\n")); return CommandResult.empty(); } }).children(builder.build()).build(); }
From source file:com.spectralogic.ds3contractcomparator.print.utils.PrinterUtils.java
/** * Converts an {@link ImmutableList} of {@link Ds3Param} into an {@link ImmutableMap} of * parameter names and {@link Ds3Param}/*from w w w. ja v a 2s . co m*/ */ public static ImmutableMap<String, Ds3Param> toParamMap(final ImmutableList<Ds3Param> params) { if (isEmpty(params)) { return ImmutableMap.of(); } final ImmutableMap.Builder<String, Ds3Param> builder = ImmutableMap.builder(); params.forEach(param -> builder.put(param.getName(), param)); return builder.build(); }
From source file:google.registry.rdap.RdapTestHelper.java
static void addNonDomainBoilerplateRemarks(ImmutableMap.Builder<String, Object> builder) { builder.put("remarks", ImmutableList.of(ImmutableMap.of("description", ImmutableList//from w ww. j av a 2s .c o m .of("This response conforms to the RDAP Operational Profile for gTLD Registries and" + " Registrars version 1.0")))); }
From source file:com.helion3.prism.commands.PrismCommands.java
/** * Build a complete command hierarchy/* www. j a va 2 s. c o m*/ * @return */ public static CommandSpec getCommand() { // Build child commands ImmutableMap.Builder<List<String>, CommandCallable> builder = ImmutableMap.builder(); builder.put(ImmutableList.of("i", "wand"), new InspectCommand()); builder.put(ImmutableList.of("l", "lookup"), LookupCommand.getCommand()); builder.put(ImmutableList.of("near"), NearCommand.getCommand()); builder.put(ImmutableList.of("rb", "rollback"), ApplierCommand.getCommand(ApplierCommand.ApplierMode.ROLLBACK)); builder.put(ImmutableList.of("rs", "restore"), ApplierCommand.getCommand(ApplierCommand.ApplierMode.RESTORE)); builder.put(ImmutableList.of("undo"), UndoCommand.getCommand()); builder.put(ImmutableList.of("ext"), ExtinguishCommand.getCommand()); builder.put(ImmutableList.of("?", "help"), HelpCommand.getCommand()); return CommandSpec.builder().executor((source, args) -> { source.sendMessage(Text.of(Format.heading(TextColors.GRAY, "By ", TextColors.GOLD, "viveleroi.\n"), TextColors.DARK_AQUA, "Tracking so good the NSA stole our name.\n", TextColors.GRAY, "Help: ", TextColors.WHITE, "/pr ?\n", TextColors.GRAY, "IRC: ", TextColors.WHITE, "irc.esper.net #prism\n", TextColors.GRAY, "Site: ", TextColors.WHITE, "http://discover-prism.com")); return CommandResult.empty(); }).children(builder.build()).build(); }
From source file:org.jclouds.openstack.nova.v1_1.util.NovaUtils.java
/** * The traditional way to represent a graph in Java is Map<V, Set<V>>, which is awkward in a * number of ways. Guava's Multimap framework makes it easy to handle a mapping from keys to * multiple values.//w w w .j a v a 2 s.c om * <p/> * Until we write or discover a gson Multimap deserializer, we may be stuck with this. * * TODO: ask on stackoverflow and/or jesse wilson */ @Deprecated public static <K, V> Map<K, Set<V>> toOldSchool(Multimap<K, V> in) { ImmutableMap.Builder<K, Set<V>> out = ImmutableMap.<K, Set<V>>builder(); for (K type : in.keySet()) out.put(type, ImmutableSet.copyOf(in.get(type))); return out.build(); }
From source file:se.kth.climate.fast.netcdf.aligner.VariableFit.java
public static VariableFit fromDataDescriptors(ImmutableList<DataDescriptor> dds) { DataDescriptor firstDD = dds.get(0); // use first descriptor for records as that one has the largest number of records per variable ImmutableMap.Builder<String, Long> rfvb = ImmutableMap.builder(); for (String varName : firstDD.vars) { rfvb.put(varName, firstDD.variableSize(varName)); }/*from w w w . ja v a2 s .c o m*/ return new VariableFit(rfvb.build(), dds.size(), dds); }