Package org.xmpp.util

Class 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 Detail

      • JIDWeigher

        public JIDWeigher()
    • 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:
        weigh in interface com.github.benmanes.caffeine.cache.Weigher<String,​ValueWrapper<String>>
        Parameters:
        key - the key to weigh
        value - 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.