Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/src/org/labkey/api/cache/BlockingCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
import org.labkey.api.test.TestWhen;
import org.labkey.api.util.DeadlockPreventingException;
import org.labkey.api.util.DebugInfoDumper;
import org.labkey.api.util.Filter;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Predicate;

/**
* This is a decorator for any Cache instance, it will provide for synchronizing object load
Expand Down Expand Up @@ -236,7 +236,7 @@ public void remove(@NotNull K key)
}

@Override
public int removeUsingFilter(Filter<K> filter)
public int removeUsingFilter(Predicate<K> filter)
{
return _cache.removeUsingFilter(filter);
}
Expand Down Expand Up @@ -296,7 +296,7 @@ public void setUp()
}
@Override public Wrapper<Integer> get(@NotNull Integer key, @Nullable Object arg, CacheLoader<Integer, Wrapper<Integer>> loader) { throw new UnsupportedOperationException(); }
@Override public void remove(@NotNull Integer key) { throw new UnsupportedOperationException(); }
@Override public int removeUsingFilter(Filter<Integer> filter) { throw new UnsupportedOperationException(); }
@Override public int removeUsingFilter(Predicate<Integer> filter) { throw new UnsupportedOperationException(); }
@Override public Set<Integer> getKeys() { throw new UnsupportedOperationException(); }
@Override public void clear() { throw new UnsupportedOperationException(); }
@Override public void close() { throw new UnsupportedOperationException(); }
Expand Down
14 changes: 4 additions & 10 deletions api/src/org/labkey/api/cache/Cache.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,9 @@

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.util.Filter;

import java.util.Set;

/**
* User: adam
* Date: Jul 8, 2010
* Time: 9:32:10 AM
*/
import java.util.function.Predicate;

public interface Cache<K, V>
{
Expand All @@ -46,9 +40,9 @@ public interface Cache<K, V>
/** Removes every element in the cache where filter.accept(K key) evaluates to true.
* Returns the number of elements that were removed.
*/
int removeUsingFilter(Filter<K> filter);
int removeUsingFilter(Predicate<K> filter);

class StringPrefixFilter implements Filter<String>
class StringPrefixFilter implements Predicate<String>
{
private final String _prefix;

Expand All @@ -58,7 +52,7 @@ public StringPrefixFilter(String prefix)
}

@Override
public boolean accept(String s)
public boolean test(String s)
{
return s.startsWith(_prefix);
}
Expand Down
10 changes: 2 additions & 8 deletions api/src/org/labkey/api/cache/CacheWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,12 @@
import org.jetbrains.annotations.Nullable;
import org.labkey.api.mbean.CacheMXBean;
import org.labkey.api.util.ContextListener;
import org.labkey.api.util.Filter;
import org.labkey.api.util.HeartBeat;

import javax.management.DynamicMBean;
import javax.management.StandardMBean;
import java.util.Set;

/**
* User: adam
* Date: Jul 8, 2010
* Time: 9:47:03 AM
*/
import java.util.function.Predicate;

// Wraps a SimpleCache to provide a full Cache implementation. Adds null markers, loaders, statistics gathering and debug name.
class CacheWrapper<K, V> implements TrackingCache<K, V>, CacheMXBean
Expand Down Expand Up @@ -150,7 +144,7 @@ public void remove(@NotNull K key)


@Override
public int removeUsingFilter(Filter<K> kFilter)
public int removeUsingFilter(Predicate<K> kFilter)
{
return trackRemoves(_cache.removeUsingFilter(kFilter));
}
Expand Down
4 changes: 2 additions & 2 deletions api/src/org/labkey/api/cache/NoopCacheProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
package org.labkey.api.cache;

import org.jetbrains.annotations.Nullable;
import org.labkey.api.util.Filter;

import java.util.Collections;
import java.util.Set;
import java.util.function.Predicate;

import static org.labkey.api.cache.CacheType.DeterministicLRU;

Expand Down Expand Up @@ -64,7 +64,7 @@ public void remove(K key)
}

@Override
public int removeUsingFilter(Filter<K> filter)
public int removeUsingFilter(Predicate<K> filter)
{
return 0;
}
Expand Down
12 changes: 3 additions & 9 deletions api/src/org/labkey/api/cache/SimpleCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,9 @@
package org.labkey.api.cache;

import org.jetbrains.annotations.Nullable;
import org.labkey.api.util.Filter;

import java.util.Set;

/**
* User: adam
* Date: 12/25/11
* Time: 8:11 PM
*/
import java.util.function.Predicate;

// Cache providers return caches that implement this interface, which presents a minimal set of cache operations,
// without support for standard LabKey features such as null markers, cache loaders, statistics, blocking, etc.
Expand All @@ -40,10 +34,10 @@ public interface SimpleCache<K, V>
void remove(K key);

/**
* Removes every element in the cache where filter.accept(K key) evaluates to true.
* Removes every element in the cache where filter.test(K key) evaluates to true.
* Returns the number of elements that were removed.
*/
int removeUsingFilter(Filter<K> filter);
int removeUsingFilter(Predicate<K> filter);

Set<K> getKeys();

Expand Down
11 changes: 3 additions & 8 deletions api/src/org/labkey/api/cache/ehcache/EhSimpleCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,12 @@
import org.jetbrains.annotations.Nullable;
import org.labkey.api.cache.CacheType;
import org.labkey.api.cache.SimpleCache;
import org.labkey.api.util.Filter;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;

/**
* User: adam
* Date: 12/25/11
* Time: 8:17 PM
*/
class EhSimpleCache<K, V> implements SimpleCache<K, V>
{
private static final Logger LOG = LogManager.getLogger(EhSimpleCache.class);
Expand Down Expand Up @@ -74,14 +69,14 @@ public void remove(@NotNull K key)
}

@Override
public int removeUsingFilter(Filter<K> filter)
public int removeUsingFilter(Predicate<K> filter)
{
int removes = 0;
List<K> keys = _cache.getKeys();

for (K key : keys)
{
if (filter.accept(key))
if (filter.test(key))
{
remove(key);
removes++;
Expand Down
10 changes: 4 additions & 6 deletions api/src/org/labkey/api/collections/SparseBitSet.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.labkey.api.collections;

/**
* copied from https://github.com/brettwooldridge/SparseBitSet
* apache license: https://github.com/brettwooldridge/SparseBitSet/blob/master/LICENSE
/*
copied from https://github.com/brettwooldridge/SparseBitSet
apache license: https://github.com/brettwooldridge/SparseBitSet/blob/master/LICENSE
*/

/*- This software is the work of Paladin Software International, Incorporated,
Expand Down Expand Up @@ -164,7 +164,6 @@ when choosing to increase the size (see resize()). The only place where
* 4 "levels". Respectively (from the least significant end), level4, the
* address within word, the address within a level3 block, the address within
* a level2 area, and the level1 address of that area within the set.
*
* LEVEL4 is the number of bits of the level4 address (number of bits need
* to address the bits in a long)
*/
Expand Down Expand Up @@ -702,9 +701,8 @@ private CopyStrategy _getCopyStrategy()
public boolean equals(Object obj)
{
/* Sanity and quick checks. */
if (!(obj instanceof SparseBitSet))
if (!(obj instanceof SparseBitSet b))
return false;
final SparseBitSet b = (SparseBitSet) obj;
if (this == b)
return true; // Identity

Expand Down
Loading