javacutil.src.org.checkerframework.javacutil.CollectionUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of checker Show documentation
Show all versions of checker Show documentation
The Checker Framework enhances Java’s type system to
make it more powerful and useful. This lets software developers
detect and prevent errors in their Java programs.
The Checker Framework includes compiler plug-ins ("checkers")
that find bugs or verify their absence. It also permits you to
write your own compiler plug-ins.
package org.checkerframework.javacutil;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Utility methods related to Java Collections
*/
public class CollectionUtils {
/**
* A Utility method for creating LRU cache
* @param size size of the cache
* @return a new cache with the provided size
*/
public static Map createLRUCache(final int size) {
return new LinkedHashMap() {
private static final long serialVersionUID = 5261489276168775084L;
@Override
protected boolean removeEldestEntry(Map.Entry entry) {
return size() > size;
}
};
}
}