K
- the type of keysV
- the type of values@FunctionalInterface public interface Weigher<K,V>
Modifier and Type | Method and Description |
---|---|
static <K,V> @NonNull Weigher<K,V> |
boundedWeigher(@NonNull Weigher<K,V> delegate)
Returns a weigher that enforces that the weight is non-negative.
|
static <K,V> @NonNull Weigher<K,V> |
singletonWeigher()
Returns a weigher where an entry has a weight of
1 . |
@NonNegative int |
weigh(K key,
V value)
Returns the weight of a cache entry.
|
@NonNegative int weigh(K key, V value)
key
- the key to weighvalue
- the value to weighstatic <K,V> @NonNull Weigher<K,V> singletonWeigher()
1
.K
- the type of keysV
- the type of values1
static <K,V> @NonNull Weigher<K,V> boundedWeigher(@NonNull Weigher<K,V> delegate)
K
- the type of keysV
- the type of valuesdelegate
- the weigher to weighs the entry