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 -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.
-
Constructor Details
-
JIDWeigher
public JIDWeigher()
-
-
Method Details
-
weigh
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
Returns the size in bytes of a String.- Parameters:
string- the String to determine the size of.- Returns:
- the size of a String.
-
sizeOfValueWrapper
Returns the size in bytes of a String.- Parameters:
value- the object to determine the size of.- Returns:
- the size of the object.
-