@Override public void notifyCheckpointComplete(long completedCheckpointId) { synchronized (materializedSstFiles) { if (completedCheckpointId > lastCompletedCheckpointId) { materializedSstFiles.keySet().removeIf(checkpointId -> checkpointId < completedCheckpointId); lastCompletedCheckpointId = completedCheckpointId; } } }
/** * Clear the merged bean definition cache, removing entries for beans * which are not considered eligible for full metadata caching yet. * <p>Typically triggered after changes to the original bean definitions, * e.g. after applying a {@code BeanFactoryPostProcessor}. Note that metadata * for beans which have already been created at this point will be kept around. * @since 4.2 */ public void clearMetadataCache() { this.mergedBeanDefinitions.keySet().removeIf(bean -> !isBeanEligibleForMetadataCaching(bean)); }
void purgeExpiredRegistries() { long now = System.currentTimeMillis(); this.remoteRegistries.entrySet().removeIf(entry -> entry.getValue().isExpired(now)); }
/** * Clear the introspection cache for the given ClassLoader, removing the * introspection results for all classes underneath that ClassLoader, and * removing the ClassLoader (and its children) from the acceptance list. * @param classLoader the ClassLoader to clear the cache for */ public static void clearClassLoader(@Nullable ClassLoader classLoader) { acceptedClassLoaders.removeIf(registeredLoader -> isUnderneathClassLoader(registeredLoader, classLoader)); strongClassCache.keySet().removeIf(beanClass -> isUnderneathClassLoader(beanClass.getClassLoader(), classLoader)); softClassCache.keySet().removeIf(beanClass -> isUnderneathClassLoader(beanClass.getClassLoader(), classLoader)); }
@Override public boolean remove(Predicate<Cookie> predicate) { return cookieJar.entrySet().removeIf(v -> predicate.test(v.getValue().cookie)); }
synchronized void retainTopics(Collection<String> topics) { metadataByPartition.entrySet().removeIf(entry -> !topics.contains(entry.getKey().topic())); unauthorizedTopics.retainAll(topics); invalidTopics.retainAll(topics); computeClusterView(); }
/** * Deregisters a cache entry listener based on the supplied configuration. * * @param configuration the listener's configuration. */ public void deregister(CacheEntryListenerConfiguration<K, V> configuration) { requireNonNull(configuration); dispatchQueues.keySet().removeIf(registration -> configuration.equals(registration.getConfiguration())); }
/** * Removes all keys whose count is 0. After incrementing and decrementing * counts or adding and subtracting Counters, there may be keys left whose * count is 0, though normally this is undesirable. This method cleans up * the map. * <p> * Maybe in the future we should try to do this more on-the-fly, though it's * not clear whether a distinction should be made between "never seen" (i.e. * null count) and "seen with 0 count". Certainly there's no distinction in * getCount() but there is in containsKey(). */ public void removeZeroCounts() { map.keySet().removeIf(e -> getCount(e) == 0); }
/** * Clear the merged bean definition cache, removing entries for beans * which are not considered eligible for full metadata caching yet. * <p>Typically triggered after changes to the original bean definitions, * e.g. after applying a {@code BeanFactoryPostProcessor}. Note that metadata * for beans which have already been created at this point will be kept around. * @since 4.2 */ public void clearMetadataCache() { this.mergedBeanDefinitions.keySet().removeIf(bean -> !isBeanEligibleForMetadataCaching(bean)); }
@Override public void close(String namespace) { if (config.isEvictOnClose()) { cache.asMap().keySet().removeIf(key -> key.namespace.equals(namespace)); } }
private void cleanupMonitorListeners( Object monitorListener, Method key ) { methodMonitorListeners.computeIfPresent( key, ( method1, handlers ) -> { handlers.removeIf( handler -> monitorListener.equals( handler.getMonitorListener() ) ); return handlers.isEmpty() ? null : handlers; } ); }
private void markSeen( Class<? extends AnyValue> typeToCheck, Set<Class<? extends AnyValue>> seen ) { seen.removeIf( t -> t.isAssignableFrom( typeToCheck ) ); }
result.removeIf(expression -> !expression.match(contentType)); return (!result.isEmpty() ? new ConsumesRequestCondition(result) : null);
/** * Checks if any of the contained media type expressions match the given * request 'Content-Type' header and returns an instance that is guaranteed * to contain matching expressions only. The match is performed via * {@link MediaType#includes(MediaType)}. * @param exchange the current exchange * @return the same instance if the condition contains no expressions; * or a new condition with matching expressions only; * or {@code null} if no expressions match. */ @Override public ConsumesRequestCondition getMatchingCondition(ServerWebExchange exchange) { if (CorsUtils.isPreFlightRequest(exchange.getRequest())) { return PRE_FLIGHT_MATCH; } if (isEmpty()) { return this; } Set<ConsumeMediaTypeExpression> result = new LinkedHashSet<>(this.expressions); result.removeIf(expression -> !expression.match(exchange)); return (!result.isEmpty() ? new ConsumesRequestCondition(result) : null); }
private static boolean fileContains( File file, String... expectedStrings ) throws IOException { Set<String> expectedStringSet = asSet( expectedStrings ); try ( Stream<String> lines = Files.lines( file.toPath() ) ) { lines.forEach( line -> expectedStringSet.removeIf( line::contains ) ); } return expectedStringSet.isEmpty(); }
@Override public synchronized void dropPartition(String databaseName, String tableName, List<String> parts, boolean deleteData) { partitions.entrySet().removeIf(entry -> entry.getKey().matches(databaseName, tableName) && entry.getValue().getValues().equals(parts)); }
@CacheSpec @CheckNoStats @Test(dataProvider = "caches") public void entrySet_removeIf(Map<Integer, Integer> map, CacheContext context) { Predicate<Entry<Integer, Integer>> isEven = entry -> (entry.getValue() % 2) == 0; boolean hasEven = map.entrySet().stream().anyMatch(isEven); boolean removedIfEven = map.entrySet().removeIf(isEven); assertThat(map.entrySet().stream().anyMatch(isEven), is(false)); assertThat(removedIfEven, is(hasEven)); if (removedIfEven) { assertThat(map.size(), is(lessThan(context.original().size()))); } }
@CacheSpec @CheckNoStats @Test(dataProvider = "caches", expectedExceptions = NullPointerException.class) public void entrySet_removeIf_null(Map<Integer, Integer> map, CacheContext context) { map.entrySet().removeIf(null); }
public void testRemoveIfWithConcurrentRemoval() { LocalCache<Integer, Integer> map = makeLocalCache(createCacheBuilder().concurrencyLevel(1).initialCapacity(1)); map.put(0, 1); map.put(1, 1); map.put(2, 1); map.entrySet() .removeIf( entry -> { assertThat(entry.getValue()).isNotNull(); map.remove((entry.getKey() + 1) % 3); return false; }); assertEquals(1, map.size()); }
public void testRemoveIfWithConcurrentModification() { LocalCache<Integer, Integer> map = makeLocalCache(createCacheBuilder().concurrencyLevel(1).initialCapacity(1)); map.put(1, 1); map.put(2, 1); map.put(3, 1); map.entrySet() .removeIf( entry -> { if (entry.getValue().equals(1)) { map.put(entry.getKey(), 2); return true; } else { return false; } }); assertEquals(3, map.size()); assertFalse(map.containsValue(1)); }