Class SizeFunctions


  • public final class SizeFunctions
    extends java.lang.Object
    Implementation of size computation for commonly used object types. The result will typically be an approximation rather than an exact amount. Speed is more important than accuracy since this utility is primarily used to adjust the number of elements in a cache.
    Version:
    2.0
    Author:
    Evren Sirin
    • Field Detail

      • STRING

        public static final SizeFunction<java.lang.String> STRING
      • NUMBER

        public static final SizeFunction<java.lang.Number> NUMBER
        WARNING: checks only for Long and Integer instances! Everything that is not a Long will be sized as if it is an Integer.
      • LONG

        public static final SizeFunction<java.lang.Long> LONG
    • Method Detail

      • constantSize

        public static <T> SizeFunction<T> constantSize​(int size)