List of usage examples for com.google.common.collect Maps filterValues
@CheckReturnValue public static <K, V> BiMap<K, V> filterValues(BiMap<K, V> unfiltered, final Predicate<? super V> valuePredicate)
From source file:ninja.leaping.permissionsex.backend.memory.MemorySubjectData.java
@Override public Map<Set<Entry<String, String>>, List<Entry<String, String>>> getAllParents() { return Maps.filterValues( Maps.transformValues(contexts, dataEntry -> dataEntry == null ? null : dataEntry.parents == null ? null : Lists.transform(dataEntry.parents, Util::subjectFromString)), v -> v != null);//from w ww. j a v a 2 s . c om }
From source file:org.eclipse.sirius.diagram.ui.tools.internal.format.semantic.SiriusFormatDataManagerForSemanticElements.java
/** * {@inheritDoc}//from w w w.ja v a 2 s . com */ public Map<? extends NodeFormatDataKey, Map<String, NodeFormatData>> getRootFormatData( final Map<SemanticNodeFormatDataKey, Map<String, NodeFormatData>> theNodeFormatDataMap) { Map<NodeFormatDataKey, Map<String, NodeFormatData>> resultValues = new HashMap<NodeFormatDataKey, Map<String, NodeFormatData>>(); Set<Entry<SemanticNodeFormatDataKey, Map<String, NodeFormatData>>> allEntries = theNodeFormatDataMap .entrySet(); for (Entry<SemanticNodeFormatDataKey, Map<String, NodeFormatData>> entry : allEntries) { Map<String, NodeFormatData> value = entry.getValue(); Map<String, NodeFormatData> filterValues = Maps.filterValues(value, ROOT_PREDICATE); if (filterValues.size() > 0) { resultValues.put(entry.getKey(), filterValues); } } return resultValues; }
From source file:io.atomix.protocols.gossip.map.AntiEntropyMapDelegate.java
@Override public int size() { checkState(!closed, destroyedMessage); // TODO: Maintain a separate counter for tracking live elements in map. return Maps.filterValues(items, MapValue::isAlive).size(); }
From source file:org.onosproject.store.ecmap.EventuallyConsistentMapImpl.java
@Override public int size() { checkState(!destroyed, destroyedMessage); // TODO: Maintain a separate counter for tracking live elements in map. return Maps.filterValues(items, MapValue::isAlive).size(); }
From source file:org.cinchapi.concourse.server.storage.temp.Limbo.java
/** * Calculate the description for {@code record} using prior {@code context} * as if it were also a part of the Buffer. * /*from w ww . ja v a2s . c om*/ * @param record * @param timestamp * @param context * @return a possibly empty Set of keys */ public Set<String> describe(long record, long timestamp, Map<String, Set<TObject>> context) { Iterator<Write> it = iterator(); while (it.hasNext()) { Write write = it.next(); if (write.getRecord().longValue() == record && write.getVersion() <= timestamp) { Set<TObject> values; values = context.get(write.getKey().toString()); if (values == null) { values = Sets.newHashSet(); context.put(write.getKey().toString(), values); } if (write.getType() == Action.ADD) { values.add(write.getValue().getTObject()); } else { values.remove(write.getValue().getTObject()); } } else if (write.getVersion() > timestamp) { break; } else { continue; } } return newLinkedHashMap(Maps.filterValues(context, emptySetFilter)).keySet(); }
From source file:ninja.leaping.permissionsex.backend.sql.SqlSubjectData.java
@Override public Map<Set<Entry<String, String>>, Integer> getAllDefaultValues() { return Maps.filterValues(Maps.transformValues(segments, dataEntry -> dataEntry == null ? null : dataEntry.getPermissionDefault()), v -> v != null); }
From source file:com.isotrol.impe3.web20.impl.MembersServiceImpl.java
private MemberEntity fill(MemberEntity entity, MemberDTO dto) { final Calendar date = Calendar.getInstance(); date.setTime(dto.getDate());//from w w w.ja va 2 s. com entity.setDate(date); entity.setDisplayName(dto.getDisplayName()); entity.setEmail(dto.getEmail()); entity.setMemberCode(dto.getCode()); entity.setName(dto.getName()); entity.setBlocked(dto.isBlocked()); // final Set<FavoriteEntity> favorites = entity.getFavorites(); // TODO no se contemplan en el dto. final Set<String> profiles = entity.getProfiles(); profiles.clear(); final Set<String> dtopf = dto.getProfiles(); if (dtopf != null) { profiles.addAll(Sets.filter(dtopf, notNull())); } final Map<String, String> properties = entity.getProperties(); properties.clear(); final Map<String, String> dtopr = dto.getProperties(); if (dtopr != null) { properties.putAll(Maps.filterKeys(Maps.filterValues(dtopr, notNull()), notNull())); } return entity; }
From source file:com.b2international.snowowl.snomed.datastore.request.DescriptionRequestHelper.java
public static Map<String, SnomedDescription> indexBestPreferredByConceptId( Iterable<SnomedDescription> descriptions, List<ExtendedLocale> orderedLocales) { List<String> languageRefSetIds = SnomedDescriptionSearchRequestBuilder.getLanguageRefSetIds(orderedLocales); ExplicitFirstOrdering<String> languageRefSetOrdering = ExplicitFirstOrdering.create(languageRefSetIds); return extractBest(indexByConceptId(descriptions), languageRefSetIds, description -> { Set<String> preferredLanguageRefSetIds = Maps .filterValues(description.getAcceptabilityMap(), Predicates.equalTo(Acceptability.PREFERRED)) .keySet();//from w ww.ja va2s. c o m // the explicit first ordering will put the VIP / anticipated / first priority languages codes to the min end. return languageRefSetOrdering.min(preferredLanguageRefSetIds); }); }
From source file:org.onosproject.store.primitives.resources.impl.AtomixLeaderElectorService.java
/** * Applies an {@link AtomixLeaderElectorOperations.Evict} commit. * @param commit evict commit// w w w . j a v a 2s . c o m */ public void evict(Commit<? extends Evict> commit) { try { List<Change<Leadership>> changes = Lists.newArrayList(); NodeId nodeId = commit.value().nodeId(); Set<String> topics = Maps.filterValues(elections, e -> e.candidates().contains(nodeId)).keySet(); topics.forEach(topic -> { Leadership oldLeadership = leadership(topic); elections.compute(topic, (k, v) -> v.evict(nodeId, termCounter(topic)::incrementAndGet)); Leadership newLeadership = leadership(topic); if (!Objects.equal(oldLeadership, newLeadership)) { changes.add(new Change<>(oldLeadership, newLeadership)); } }); notifyLeadershipChanges(changes); } catch (Exception e) { logger().error("State machine operation failed", e); throw new IllegalStateException(e); } }
From source file:com.cinchapi.concourse.server.storage.temp.Limbo.java
/** * Calculate the description for {@code record} using prior {@code context} * as if it were also a part of the Buffer. * // w w w . j av a2s.co m * @param record * @param timestamp * @param context * @return a possibly empty Set of keys */ public Set<String> describe(long record, long timestamp, Map<String, Set<TObject>> context) { if (timestamp >= getOldestWriteTimestamp()) { for (Iterator<Write> it = iterator(); it.hasNext();) { Write write = it.next(); if (write.getRecord().longValue() == record && write.getVersion() <= timestamp) { Set<TObject> values; values = context.get(write.getKey().toString()); if (values == null) { values = Sets.newHashSet(); context.put(write.getKey().toString(), values); } if (write.getType() == Action.ADD) { values.add(write.getValue().getTObject()); } else { values.remove(write.getValue().getTObject()); } } else if (write.getVersion() > timestamp) { break; } else { continue; } } } return newLinkedHashMap(Maps.filterValues(context, emptySetFilter)).keySet(); }