Refine search
@Override public boolean apply(Entry<V, K> input) { return forwardPredicate.apply(Maps.immutableEntry(input.getValue(), input.getKey())); } };
@Override public Entry<K, V> next() { if (!valueItr.hasNext()) { Entry<K, ? extends ImmutableCollection<V>> entry = asMapItr.next(); currentKey = entry.getKey(); valueItr = entry.getValue().iterator(); } return Maps.immutableEntry(currentKey, valueItr.next()); } };
private static <K, V> Predicate<Entry<V, K>> inversePredicate( final Predicate<? super Entry<K, V>> forwardPredicate) { return new Predicate<Entry<V, K>>() { @Override public boolean apply(Entry<V, K> input) { return forwardPredicate.apply(Maps.immutableEntry(input.getValue(), input.getKey())); } }; }
public Assignments rewrite(Function<Expression, Expression> rewrite) { return assignments.entrySet().stream() .map(entry -> Maps.immutableEntry(entry.getKey(), rewrite.apply(entry.getValue()))) .collect(toAssignments()); }
boolean removeEntriesIf(Predicate<? super Entry<K, Collection<V>>> predicate) { Iterator<Entry<K, Collection<V>>> entryIterator = unfiltered.asMap().entrySet().iterator(); boolean changed = false; while (entryIterator.hasNext()) { Entry<K, Collection<V>> entry = entryIterator.next(); K key = entry.getKey(); Collection<V> collection = filterCollection(entry.getValue(), new ValuePredicate(key)); if (!collection.isEmpty() && predicate.apply(Maps.immutableEntry(key, collection))) { if (collection.size() == entry.getValue().size()) { entryIterator.remove(); } else { collection.clear(); } changed = true; } } return changed; }
@Override public boolean apply(Entry<V, K> input) { return forwardPredicate.apply(Maps.immutableEntry(input.getValue(), input.getKey())); } };
@Override public Entry<K, V> next() { if (!valueItr.hasNext()) { Entry<K, ? extends ImmutableCollection<V>> entry = asMapItr.next(); currentKey = entry.getKey(); valueItr = entry.getValue().iterator(); } return Maps.immutableEntry(currentKey, valueItr.next()); } };
@Override public Entry<K, V> next() { if (!valueItr.hasNext()) { Entry<K, ? extends ImmutableCollection<V>> entry = asMapItr.next(); currentKey = entry.getKey(); valueItr = entry.getValue().iterator(); } return Maps.immutableEntry(currentKey, valueItr.next()); } };
public TranscodingAsyncDistributedMap( AsyncDistributedMap<K2, V2> backingMap, Function<K1, K2> keyEncoder, Function<K2, K1> keyDecoder, Function<V1, V2> valueEncoder, Function<V2, V1> valueDecoder) { super(backingMap); this.backingMap = backingMap; this.keyEncoder = k -> k == null ? null : keyEncoder.apply(k); this.keyDecoder = k -> k == null ? null : keyDecoder.apply(k); this.valueEncoder = v -> v == null ? null : valueEncoder.apply(v); this.valueDecoder = v -> v == null ? null : valueDecoder.apply(v); this.entryDecoder = e -> e == null ? null : Maps.immutableEntry(keyDecoder.apply(e.getKey()), valueDecoder.apply(e.getValue())); this.entryEncoder = e -> e == null ? null : Maps.immutableEntry(keyEncoder.apply(e.getKey()), valueEncoder.apply(e.getValue())); }
ImmutableMap<Service, Long> startupTimes() { List<Entry<Service, Long>> loadTimes; monitor.enter(); try { loadTimes = Lists.newArrayListWithCapacity(startupTimers.size()); // N.B. There will only be an entry in the map if the service has started for (Entry<Service, Stopwatch> entry : startupTimers.entrySet()) { Service service = entry.getKey(); Stopwatch stopWatch = entry.getValue(); if (!stopWatch.isRunning() && !(service instanceof NoOpService)) { loadTimes.add(Maps.immutableEntry(service, stopWatch.elapsed(MILLISECONDS))); } } } finally { monitor.leave(); } Collections.sort( loadTimes, Ordering.natural() .onResultOf( new Function<Entry<Service, Long>, Long>() { @Override public Long apply(Entry<Service, Long> input) { return input.getValue(); } })); return ImmutableMap.copyOf(loadTimes); }
boolean removeEntriesIf(Predicate<? super Entry<K, Collection<V>>> predicate) { Iterator<Entry<K, Collection<V>>> entryIterator = unfiltered.asMap().entrySet().iterator(); boolean changed = false; while (entryIterator.hasNext()) { Entry<K, Collection<V>> entry = entryIterator.next(); K key = entry.getKey(); Collection<V> collection = filterCollection(entry.getValue(), new ValuePredicate(key)); if (!collection.isEmpty() && predicate.apply(Maps.immutableEntry(key, collection))) { if (collection.size() == entry.getValue().size()) { entryIterator.remove(); } else { collection.clear(); } changed = true; } } return changed; }
FromSupertype(String type, Iterable<ValueAttribute> attribute) { this.type = type; this.hasGenerics = type.indexOf('<') > 0; Entry<String, List<String>> withArgs = SourceTypes.extract(type); this.raw = withArgs.getKey(); this.wildcard = hasGenerics ? SourceTypes.stringify(Maps.immutableEntry(withArgs.getKey(), Collections.nCopies(withArgs.getValue().size(), "?"))) : type; this.attributes = ImmutableList.copyOf(attribute); }
@Override Spliterator<Entry<K, V>> entrySpliterator() { return CollectSpliterators.flatMap( map.entrySet().spliterator(), keyToValueCollectionEntry -> { K key = keyToValueCollectionEntry.getKey(); Collection<V> valueCollection = keyToValueCollectionEntry.getValue(); return CollectSpliterators.map( valueCollection.spliterator(), (V value) -> Maps.immutableEntry(key, value)); }, Spliterator.SIZED, size()); }
private static Map<String, WsProjectResponse.FileDataByPath> buildFileDataByModuleAndPath(MultiModuleProjectRepository data) { return data.repositoriesByModule().entrySet() .stream() .map(entry -> Maps.immutableEntry(entry.getKey(), buildFileDataByPath(entry.getValue().fileData()))) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); }
private Map.Entry<K, V> convertEntry(Map.Entry<K, Versioned<V>> entry) { return entry == null ? null : Maps.immutableEntry(entry.getKey(), Versioned.valueOrNull(entry.getValue())); }
.map(entry -> Maps.immutableEntry(entry.getKey(), new HashMap<>(entry.getValue()))) .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); for (Entry<String, Map<String, String>> catalogProperties : this.unprocessedCatalogProperties.entrySet()) { String catalog = catalogProperties.getKey(); for (Entry<String, String> entry : catalogProperties.getValue().entrySet()) { connectorProperties.computeIfAbsent(catalog, id -> new HashMap<>()) .put(entry.getKey(), entry.getValue());
public TranscodingAsyncAtomicMap( AsyncAtomicMap<K2, V2> backingMap, Function<K1, K2> keyEncoder, Function<K2, K1> keyDecoder, Function<V1, V2> valueEncoder, Function<V2, V1> valueDecoder) { super(backingMap); this.backingMap = backingMap; this.keyEncoder = k -> k == null ? null : keyEncoder.apply(k); this.keyDecoder = k -> k == null ? null : keyDecoder.apply(k); this.valueEncoder = v -> v == null ? null : valueEncoder.apply(v); this.valueDecoder = v -> v == null ? null : valueDecoder.apply(v); this.versionedValueDecoder = v -> v == null ? null : v.map(valueDecoder); this.versionedValueEncoder = v -> v == null ? null : v.map(valueEncoder); this.entryDecoder = e -> e == null ? null : Maps.immutableEntry(keyDecoder.apply(e.getKey()), versionedValueDecoder.apply(e.getValue())); this.entryEncoder = e -> e == null ? null : Maps.immutableEntry(keyEncoder.apply(e.getKey()), versionedValueEncoder.apply(e.getValue())); }
@Override public Set<Map.Entry<K, Versioned<byte[]>>> entrySet() { return entries().entrySet().stream() .filter(entry -> entry.getValue().type() != MapEntryValue.Type.TOMBSTONE) .map(e -> Maps.immutableEntry(e.getKey(), toVersioned(e.getValue()))) .collect(Collectors.toSet()); }
@Override Spliterator<Entry<K, V>> entrySpliterator() { return CollectSpliterators.flatMap( asMap().entrySet().spliterator(), keyToValueCollectionEntry -> { K key = keyToValueCollectionEntry.getKey(); Collection<V> valueCollection = keyToValueCollectionEntry.getValue(); return CollectSpliterators.map( valueCollection.spliterator(), (V value) -> Maps.immutableEntry(key, value)); }, Spliterator.SIZED | (this instanceof SetMultimap ? Spliterator.DISTINCT : 0), size()); }
private Map.Entry<K, Versioned<byte[]>> toVersionedEntry( Map.Entry<K, MapEntryValue> entry) { return entry == null || valueIsNull(entry.getValue()) ? null : Maps.immutableEntry(entry.getKey(), toVersioned(entry.getValue())); }