List of usage examples for com.google.common.collect Maps transformValues
@GwtIncompatible("NavigableMap") public static <K, V1, V2> NavigableMap<K, V2> transformValues(NavigableMap<K, V1> fromMap, Function<? super V1, V2> function)
From source file:com.google.devtools.build.lib.query2.BlazeQueryEnvironment.java
@Override protected void preloadOrThrow(QueryExpression caller, Collection<String> patterns) throws TargetParsingException, InterruptedException { if (!resolvedTargetPatterns.keySet().containsAll(patterns)) { // Note that this may throw a RuntimeException if deps are missing in Skyframe and this is // being called from within a SkyFunction. resolvedTargetPatterns.putAll(Maps.transformValues( targetPatternEvaluator.preloadTargetPatterns(eventHandler, patterns, keepGoing), RESOLVED_TARGETS_TO_TARGETS)); }/*from w w w .j a va 2 s .c o m*/ }
From source file:com.facebook.buck.json.PythonDslProjectBuildFileParser.java
@SuppressWarnings("unchecked") private BuildFileManifest toBuildFileManifest(ImmutableList<Map<String, Object>> values) { return BuildFileManifest.builder().setTargets(values.subList(0, values.size() - 3)) .setIncludes(ImmutableSortedSet.copyOf(Preconditions .checkNotNull((List<String>) values.get(values.size() - 3).get("__includes")))) .setConfigs(Preconditions//from w ww .j a v a 2s . c o m .checkNotNull((Map<String, Object>) values.get(values.size() - 2).get("__configs"))) .setEnv(ImmutableMap.copyOf(Maps.transformValues( Preconditions .checkNotNull((Map<String, String>) values.get(values.size() - 1).get("__env")), Optional::ofNullable))) .build(); }
From source file:com.twitter.aurora.scheduler.state.CronJobManager.java
public Map<IJobKey, String> getScheduledJobs() { synchronized (scheduledJobs) { return ImmutableMap.copyOf(Maps.transformValues(scheduledJobs, keyToSchedule)); }//from w w w .ja va 2s .c om }
From source file:com.facebook.buck.cxx.toolchain.CxxBuckConfig.java
public ImmutableMap<String, Flavor> getDefaultFlavorsForRuleType(RuleType type) { return ImmutableMap.copyOf(Maps.transformValues(delegate.getEntriesForSection("defaults." + type.getName()), InternalFlavor::of));// w w w. j a v a 2 s. c om }
From source file:io.prestosql.orc.OrcRecordReader.java
public Map<String, Slice> getUserMetadata() { return ImmutableMap.copyOf(Maps.transformValues(userMetadata, Slices::copyOf)); }
From source file:org.eclipse.sirius.diagram.sequence.business.internal.layout.horizontal.SequenceHorizontalLayout.java
/** * Compute and store the new bounds of the instance roles, the x location * will be the only modified value. Return the next minimum x. */// w w w. j a v a 2s . com private int computeLocation(final int currentX, final InstanceRole instanceRole, boolean pack, Map<LostMessageEnd, Integer> lostEndsDelta, final Map<InstanceRole, Rectangle> computedMoves) { final Rectangle oldBounds = instanceRole.getProperLogicalBounds(); final Option<Lifeline> lifeline = instanceRole.getLifeline(); int newMinX = currentX; int rightComputedGap = 0; if (lifeline.some()) { int maxFrameDepth = getMaxFrameDepth(lifeline.get()); int foundMessagesGap = getLifelineLeftGap(lifeline.get(), null, oldBounds.width, lostEndsDelta); int frameGap = maxFrameDepth * LayoutConstants.BORDER_FRAME_MARGIN; int rightGap = getLifelineRightGap(lifeline.get(), null, oldBounds.width, lostEndsDelta); // Make space for frame and found messages. newMinX += frameGap + foundMessagesGap; // Update computed gap rightComputedGap = frameGap + rightGap; } Rectangle newBounds = oldBounds.getCopy(); if (pack) { newBounds.x = newMinX; } else { // shift the current instancerole to the right ? // don't reduce previous delta with known/flagged predecessor int deltaStablePosition = getDeltaStablePosition(newMinX, instanceRole, Maps.transformValues(computedMoves, RECT_TO_X)); newBounds.x = Math.max(newMinX, Math.max(newBounds.x, deltaStablePosition)); } // Store computed move computedMoves.put(instanceRole, newBounds); // Return the next minX : right of the current instance role + minimum // gap + place for frames and found messages return newBounds.right() + getMinInstanceRoleGap() + rightComputedGap; }
From source file:com.tysanclan.site.projectewok.util.FinancialTimeline.java
public IModel<List<BaseSeries<String, BigDecimal>>> getParticipation(DateTime start, DateTime end) { BaseSeries<String, BigDecimal> series = new BaseSeries<String, BigDecimal>(); Multimap<String, BigDecimal> amounts = HashMultimap.create(); for (Entry<DateTime, Contribution> e : contributionsByDate.entries()) { if (!e.getKey().isBefore(start) && !e.getKey().isAfter(end)) { amounts.put(e.getValue().getUser() != null ? e.getValue().getUser().getUsername() : "Anonymous", e.getValue().getAmount()); }// ww w . j ava2 s . com } Map<String, BigDecimal> sums = Maps.transformValues(amounts.asMap(), SumFunction.INSTANCE); for (Entry<String, BigDecimal> e : sums.entrySet()) { series.addEntry(e.getKey(), e.getValue()); } return listOf(series); }
From source file:edu.harvard.med.screensaver.service.libraries.PlateUpdater.java
private void updatePrimaryPlateLocation(Copy copy) { Set<Entry<PlateLocation, Integer>> plateLocationCounts = Maps .transformValues(Multimaps// w ww . jav a 2s . com .index(Iterables.filter(copy.getPlates().values(), Predicates.compose(Predicates.notNull(), Plate.ToLocation)), Plate.ToLocation) .asMap(), CollectionSize) .entrySet(); if (plateLocationCounts.isEmpty()) { copy.setPrimaryPlateLocation(null); } else { PlateLocation primaryPlateLocation = Collections .max(plateLocationCounts, plateLocationFrequencyComparator).getKey(); copy.setPrimaryPlateLocation(primaryPlateLocation); copy.setPlateLocationsCount(plateLocationCounts.size()); } }
From source file:com.palantir.atlasdb.transaction.impl.SerializableTransaction.java
private void verifyRanges(Transaction ro) { // verify each set of reads to ensure they are the same. for (String table : rangeEndByTable.keySet()) { for (Entry<RangeRequest, byte[]> e : rangeEndByTable.get(table).entrySet()) { RangeRequest range = e.getKey(); byte[] rangeEnd = e.getValue(); if (rangeEnd.length != 0 && !RangeRequests.isTerminalRow(range.isReverse(), rangeEnd)) { range = range.getBuilder() .endRowExclusive(RangeRequests.getNextStartRow(range.isReverse(), rangeEnd)).build(); }/*from w w w . j a v a2 s . co m*/ final ConcurrentNavigableMap<Cell, byte[]> writes = writesByTable.get(table); BatchingVisitableView<RowResult<byte[]>> bv = BatchingVisitableView.of(ro.getRange(table, range)); NavigableMap<Cell, ByteBuffer> readsInRange = Maps.transformValues(getReadsInRange(table, e, range), new Function<byte[], ByteBuffer>() { @Override public ByteBuffer apply(byte[] input) { return ByteBuffer.wrap(input); } }); boolean isEqual = bv .transformBatch(new Function<List<RowResult<byte[]>>, List<Entry<Cell, ByteBuffer>>>() { @Override public List<Entry<Cell, ByteBuffer>> apply(List<RowResult<byte[]>> input) { List<Entry<Cell, ByteBuffer>> ret = Lists.newArrayList(); for (RowResult<byte[]> row : input) { for (Entry<Cell, byte[]> cell : row.getCells()) { // NB: We filter our write set out here because our normal SI checking handles this case to ensure the value hasn't changed. if (writes == null || !writes.containsKey(cell.getKey())) { ret.add(Maps.immutableEntry(cell.getKey(), ByteBuffer.wrap(cell.getValue()))); } } } return ret; } }).isEqual(readsInRange.entrySet()); if (!isEqual) { throw TransactionSerializableConflictException.create(table, getTimestamp(), System.currentTimeMillis() - timeCreated); } } } }
From source file:org.opentestsystem.authoring.testauth.service.impl.BlueprintHelper.java
private static final void populateDefaultItemSelectionParameters(final BlueprintElement blueprintElement, final String segmentId, final ItemSelectionAlgorithm itemSelectionAlgorithm) { if (itemSelectionAlgorithm != null && itemSelectionAlgorithm.getBlueprintParameters() != null) { blueprintElement.getBlueprintElementValueMap().get(segmentId) .setItemSelectionParameters(Maps.transformValues( Maps.uniqueIndex(itemSelectionAlgorithm.getBlueprintParameters(), ItemSelectionAlgorithmHelper.ISA_PARAMETER_NAME_TRANSFORMER), ItemSelectionAlgorithmHelper.ISA_PARAMETER_DEFAULT_VALUE_TRANSFORMER)); } else {/* w w w. ja v a 2s . c om*/ blueprintElement.getBlueprintElementValueMap().get(segmentId).setItemSelectionParameters(null); } }