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>>
@NullMarked 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(@Nullable String string)Returns the size in bytes of a String.static intsizeOfValueWrapper(@Nullable ValueWrapper<String> value)Returns the size in bytes of a String.intweigh(String key, ValueWrapper<String> value)Returns the weight of a cache entry.
-
-
-
Method Detail
-
weigh
public int weigh(String key, 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(@Nullable 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(@Nullable 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.
-
-