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:com.cinchapi.concourse.server.storage.temp.Buffer.java
@Override public Map<TObject, Set<Long>> browse(String key, long timestamp, Map<TObject, Set<Long>> context) { for (Iterator<Write> it = iterator(key, timestamp); it.hasNext();) { Write write = it.next();/*from w w w . j av a2 s . c o m*/ Set<Long> records = context.get(write.getValue().getTObject()); if (records == null) { records = Sets.newLinkedHashSet(); context.put(write.getValue().getTObject(), records); } if (write.getType() == Action.ADD) { records.add(write.getRecord().longValue()); } else { records.remove(write.getRecord().longValue()); } } return Maps.newTreeMap((SortedMap<TObject, Set<Long>>) Maps.filterValues(context, emptySetFilter)); }
From source file:org.tzi.use.uml.mm.MModel.java
/** * @return collection of class invariants from the use file loaded *///from w w w .ja v a 2 s .com public Collection<MClassInvariant> modelClassInvariants() { return Maps.filterValues(fClassInvariants, new Predicate<MClassInvariant>() { @Override public boolean apply(MClassInvariant inv) { return !inv.isLoaded(); } }).values(); }
From source file:org.cinchapi.concourse.server.storage.temp.Limbo.java
@Override public Set<Long> search(String key, String query) { Map<Long, Set<Value>> rtv = Maps.newHashMap(); Iterator<Write> it = iterator(); while (it.hasNext()) { Write write = it.next();//from w w w . ja v a2 s.c o m Value value = write.getValue(); long record = write.getRecord().longValue(); if (write.getKey().toString().equals(key) && value.getType() == Type.STRING) { /* * NOTE: It is not enough to merely check if the stored text * contains the query because the Database does infix * indexing/searching, which has some subtleties: * 1. Stop words are removed from the both stored indices and * the search query * 2. A query and document are considered to match if the * document contains a sequence of terms where each term or a * substring of the term matches the term in the same relative * position of the query. */ // CON-10: compare lowercase for case insensitive search String stored = TStrings.stripStopWords(((String) (value.getObject())).toLowerCase()); query = TStrings.stripStopWords(query.toLowerCase()); if (!Strings.isNullOrEmpty(stored) && !Strings.isNullOrEmpty(query) && TStrings.isInfixSearchMatch(query, stored)) { Set<Value> values = rtv.get(record); if (values == null) { values = Sets.newHashSet(); rtv.put(record, values); } if (values.contains(value)) { values.remove(value); } else { values.add(value); } } } } // FIXME sort search results based on frequency (see // SearchRecord#search()) return newLinkedHashMap(Maps.filterValues(rtv, emptySetFilter)).keySet(); }
From source file:com.b2international.snowowl.snomed.datastore.id.cis.CisSnomedIdentifierService.java
@Override public void publish(final Set<String> componentIds) { LOGGER.debug("Publishing {} component IDs.", componentIds.size()); final Map<String, SctId> sctIds = getSctIds(componentIds); final Map<String, SctId> problemSctIds = ImmutableMap.copyOf(Maps.filterValues(sctIds, Predicates.<SctId>not(Predicates.or(SctId::isAssigned, SctId::isPublished)))); HttpPut deprecateRequest = null;/*from w w w .j a v a 2 s. c o m*/ String currentNamespace = null; try { final Map<String, SctId> assignedSctIds = ImmutableMap .copyOf(Maps.filterValues(sctIds, SctId::isAssigned)); if (!assignedSctIds.isEmpty()) { if (assignedSctIds.size() > 1) { final Multimap<String, String> componentIdsByNamespace = toNamespaceMultimap( assignedSctIds.keySet()); for (final Entry<String, Collection<String>> entry : componentIdsByNamespace.asMap() .entrySet()) { currentNamespace = entry.getKey(); for (final Collection<String> bulkIds : Iterables.partition(entry.getValue(), BULK_LIMIT)) { LOGGER.debug( String.format("Sending bulk publication request for namespace %s with size %d.", currentNamespace, bulkIds.size())); deprecateRequest = httpPut(String.format("sct/bulk/publish?token=%s", getToken()), createBulkPublishData(currentNamespace, bulkIds)); execute(deprecateRequest); } } } else { final String componentId = Iterables.getOnlyElement(assignedSctIds.keySet()); currentNamespace = SnomedIdentifiers.getNamespace(componentId); deprecateRequest = httpPut(String.format("sct/publish?token=%s", getToken()), createPublishData(componentId)); execute(deprecateRequest); } } if (!problemSctIds.isEmpty()) { throw new SctIdStatusException( "Cannot publish %s component IDs because they are not assigned or already published.", problemSctIds); } } catch (IOException e) { throw new SnowowlRuntimeException( String.format("Exception while publishing IDs for namespace %s.", currentNamespace), e); } finally { release(deprecateRequest); } }
From source file:com.android.build.gradle.internal.api.AppVariantOutputContext.java
public File getAwbPackageOutputFile(AwbBundle awbBundle) { // File soFolder = this.getVariantData().ndkCompileTask.getSoFolder(); Map<File, Format> jniFoldersMap = outputScope.getVariantScope().getTransformManager() .getPipelineOutput(StreamFilter.NATIVE_LIBS); Set<File> jniFolders = Maps.filterValues(jniFoldersMap, new Predicate<Format>() { @Override// ww w . j ava 2s . c o m public boolean apply(@Nullable Format format) { return format == Format.DIRECTORY; } }).keySet(); if (jniFolders.size() <= 0) { throw new StopExecutionException("No jniFolders found!"); } File jniFolder = jniFolders.iterator().next(); if (!jniFolder.isDirectory()) { throw new StopExecutionException("No jniFolders found! ," + " you should compile atlas first"); } String awbOutputName = awbBundle.getAwbSoName(); File file = new File(jniFolder, "lib/armeabi" + File.separator + awbOutputName); awbBundle.outputBundleFile = file; return file; }
From source file:io.atomix.protocols.gossip.map.AntiEntropyMapDelegate.java
@Override public void clear() { checkState(!closed, destroyedMessage); Maps.filterValues(items, MapValue::isAlive).forEach((k, v) -> remove(decodeKey(k))); }
From source file:io.atomix.protocols.gossip.map.AntiEntropyMapDelegate.java
@Override public Set<K> keySet() { checkState(!closed, destroyedMessage); return Maps.filterValues(items, MapValue::isAlive).keySet().stream().map(this::decodeKey) .collect(Collectors.toSet()); }
From source file:io.atomix.protocols.gossip.map.AntiEntropyMapDelegate.java
@Override public Collection<V> values() { checkState(!closed, destroyedMessage); return Collections2.transform(Maps.filterValues(items, MapValue::isAlive).values(), value -> value.get(this::decodeValue)); }
From source file:com.aionemu.gameserver.services.SiegeService.java
public Map<Integer, ArtifactLocation> getStandaloneArtifacts() { return Maps.filterValues(artifacts, new Predicate<ArtifactLocation>() { @Override//from w w w . j a v a 2 s . c o m public boolean apply(@Nullable ArtifactLocation input) { return input != null && input.isStandAlone(); } }); }
From source file:io.atomix.protocols.gossip.map.AntiEntropyMapDelegate.java
@Override public Set<Map.Entry<K, V>> entrySet() { checkState(!closed, destroyedMessage); return Maps.filterValues(items, MapValue::isAlive).entrySet().stream() .map(e -> Pair.of(decodeKey(e.getKey()), decodeValue(e.getValue().get()))) .collect(Collectors.toSet()); }