List of usage examples for com.google.common.collect ImmutableMap builder
public static <K, V> Builder<K, V> builder()
From source file:com.google.idea.blaze.base.lang.projectview.language.ProjectViewKeywords.java
private static ImmutableMap<String, ItemType> getItemTypes() { ImmutableMap.Builder<String, ItemType> builder = ImmutableMap.builder(); for (SectionParser parser : Sections.getParsers()) { builder.put(parser.getName(), parser.getItemType()); }//from www . j a v a 2 s . c o m return builder.build(); }
From source file:me.lucko.luckperms.sponge.timings.LPTimings.java
public LPTimings(LPSpongePlugin plugin) { ImmutableMap.Builder<LPTiming, Timing> map = ImmutableMap.builder(); for (LPTiming t : LPTiming.values()) { map.put(t, Timings.of(plugin, t.getId())); }/* w w w. ja v a 2 s . co m*/ timings = map.build(); }
From source file:com.publictransitanalytics.scoregenerator.distance.EstimatingDistanceClient.java
@Override public Map<PointLocation, WalkingCosts> getDistances(final PointLocation point, final Set<PointLocation> consideredPoints) throws DistanceClientException, InterruptedException { final GeoPoint location = point.getLocation(); final ImmutableMap.Builder<PointLocation, WalkingCosts> builder = ImmutableMap.builder(); for (final PointLocation otherPoint : consideredPoints) { final GeoPoint otherLocation = otherPoint.getLocation(); final double distanceMeters = location.getDistanceMeters(otherLocation); final Duration time = Duration.ofSeconds((long) Math.floor(distanceMeters / walkingMetersPerSecond)); final WalkingCosts costs = new WalkingCosts(time, distanceMeters); builder.put(otherPoint, costs);//w w w. j ava2 s.c om } return builder.build(); }
From source file:com.google.cloud.bigquery.FieldList.java
private FieldList(Iterable<Field> fields) { this.fields = ImmutableList.copyOf(fields); ImmutableMap.Builder<String, Integer> nameIndexBuilder = ImmutableMap.builder(); int index = 0; for (Field field : fields) { nameIndexBuilder.put(field.getName(), index); index++;// w ww . j a v a2 s . co m } this.nameIndex = nameIndexBuilder.build(); }
From source file:com.nearinfinity.honeycomb.mysql.generators.RowGenerator.java
public RowGenerator(TableSchema schema) { super();/*from ww w .j a v a2 s .c o m*/ ImmutableMap.Builder<String, Generator<ByteBuffer>> recordGenerators = ImmutableMap.builder(); for (ColumnSchema column : schema.getColumns()) { recordGenerators.put(column.getColumnName(), new FieldGenerator(column)); } this.recordGenerators = recordGenerators.build(); }
From source file:io.appium.java_client.imagecomparison.BaseComparisonOptions.java
/** * Builds a map, which is ready to be passed to the subordinated * Appium API.// ww w .ja v a 2 s . com * * @return comparison options mapping. */ public Map<String, Object> build() { final ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder(); ofNullable(visualize).map(x -> builder.put("visualize", x)); return builder.build(); }
From source file:info.gehrels.voting.singleTransferableVote.CandidateStates.java
CandidateStates(ImmutableSet<CANDIDATE_TYPE> candidates) { Builder<CANDIDATE_TYPE, CandidateState<CANDIDATE_TYPE>> candidateStatesBuilder = ImmutableMap.builder(); for (CANDIDATE_TYPE candidate : candidates) { candidateStatesBuilder.put(candidate, new CandidateState<>(candidate)); }//from w w w .j a v a 2 s .c o m candidateStates = candidateStatesBuilder.build(); }
From source file:org.jclouds.trmk.vcloud_0_8.options.AddInternetServiceOptions.java
@Override public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) { ImmutableMap.Builder<String, Object> copy = ImmutableMap.builder(); copy.putAll(postParams);//from www .j av a2 s. co m if (description != null) copy.put("description", description); copy.put("enabled", enabled); if (monitorEnabled != null) copy.put("monitor", monitorEnabled.toString()); return super.bindToRequest(request, copy.build()); }
From source file:org.onos.yangtools.yang.data.impl.schema.tree.ChoiceModificationStrategy.java
ChoiceModificationStrategy(final ChoiceSchemaNode schemaNode, final TreeType treeType) { super(ChoiceNode.class, treeType); final ImmutableMap.Builder<YangInstanceIdentifier.PathArgument, ModificationApplyOperation> child = ImmutableMap .builder();// ww w. j a v a 2 s. c om for (final ChoiceCaseNode caze : schemaNode.getCases()) { if (SchemaAwareApplyOperation.belongsToTree(treeType, caze)) { for (final DataSchemaNode cazeChild : caze.getChildNodes()) { if (SchemaAwareApplyOperation.belongsToTree(treeType, cazeChild)) { final SchemaAwareApplyOperation childNode = SchemaAwareApplyOperation.from(cazeChild, treeType); child.put(new YangInstanceIdentifier.NodeIdentifier(cazeChild.getQName()), childNode); } } } } childNodes = child.build(); }
From source file:org.jclouds.cloudsigma.functions.ServerToMap.java
@Override public Map<String, String> apply(Server from) { checkNotNull(from, "server"); ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); builder.put("name", from.getName()); builder.put("cpu", from.getCpu() + ""); if (from.getSmp() != null) builder.put("smp", from.getSmp() + ""); else//www . j a v a 2 s . c o m builder.put("smp", "auto"); builder.put("mem", from.getMem() + ""); builder.put("persistent", from.isPersistent() + ""); if (from.getBootDeviceIds().size() != 0) builder.put("boot", Joiner.on(' ').join(from.getBootDeviceIds())); for (Entry<String, ? extends Device> entry : from.getDevices().entrySet()) { builder.put(entry.getKey(), entry.getValue().getDriveUuid()); builder.put(entry.getKey() + ":media", entry.getValue().getMediaType().toString()); } int nicId = 0; for (NIC nic : from.getNics()) { builder.put("nic:" + nicId + ":model", nic.getModel().toString()); if (nic.getDhcp() != null) builder.put("nic:" + nicId + ":dhcp", nic.getDhcp()); if (nic.getVlan() != null) builder.put("nic:" + nicId + ":vlan", nic.getVlan()); if (nic.getMac() != null) builder.put("nic:" + nicId + ":mac", nic.getMac()); nicId++; } builder.put("vnc:ip", from.getVnc().getIp() == null ? "auto" : from.getVnc().getIp()); if (from.getVnc().getPassword() != null) builder.put("vnc:password", from.getVnc().getPassword()); if (from.getVnc().isTls()) builder.put("vnc:tls", "on"); if (from.getUse().size() != 0) builder.put("use", Joiner.on(' ').join(from.getUse())); return builder.build(); }