Package org.xmpp.util
Class JIDWeigher
- java.lang.Object
-
- org.xmpp.util.JIDWeigher
-
- All Implemented Interfaces:
com.github.benmanes.caffeine.cache.Weigher<String,ValueWrapper<String>>
public class JIDWeigher extends Object implements com.github.benmanes.caffeine.cache.Weigher<String,ValueWrapper<String>>
A Weigher that weights cache entries that contains JID parts. The weights that are used are byte-size based.- Author:
- Guus der Kinderen, guus.der.kinderen@gmail.com
-
-
Constructor Summary
Constructors Constructor Description JIDWeigher()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intsizeOfString(String string)Returns the size in bytes of a String.static intsizeOfValueWrapper(ValueWrapper<String> value)Returns the size in bytes of a String.@org.checkerframework.checker.index.qual.NonNegative intweigh(@NonNull String key, @NonNull ValueWrapper<String> value)Returns the weight of a cache entry.
-
-
-
Method Detail
-
weigh
public @org.checkerframework.checker.index.qual.NonNegative int weigh(@NonNull String key, @NonNull ValueWrapper<String> value)
Returns the weight of a cache entry. There is no unit for entry weights; rather they are simply relative to each other.- Specified by:
weighin interfacecom.github.benmanes.caffeine.cache.Weigher<String,ValueWrapper<String>>- Parameters:
key- the key to weighvalue- the value to weigh- Returns:
- the weight of the entry; must be non-negative
-
sizeOfString
public static int sizeOfString(String string)
Returns the size in bytes of a String.- Parameters:
string- the String to determine the size of.- Returns:
- the size of a String.
-
sizeOfValueWrapper
public static int sizeOfValueWrapper(ValueWrapper<String> value)
Returns the size in bytes of a String.- Parameters:
value- the object to determine the size of.- Returns:
- the size of the object.
-
-