Package com.complexible.common.base

# Class SizeFunctions

java.lang.Object
com.complexible.common.base.SizeFunctions

public final class SizeFunctions extends 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 Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `ARRAY_OVERHEAD`
  `static final SizeFunction<Long>`
  `LONG`
  `static final SizeFunction<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.
  `static final int`
  `OBJECT_OVERHEAD`
  `static final int`
  `REF_OVERHEAD`
  `static final SizeFunction<String>`
  `STRING`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static <T> SizeFunction<T>`
  `constantSize(int size)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### OBJECT_OVERHEAD

    public static final int OBJECT_OVERHEAD
    See Also:
      - Constant Field Values

  - ### REF_OVERHEAD

    public static final int REF_OVERHEAD
    See Also:
      - Constant Field Values

  - ### ARRAY_OVERHEAD

    public static final int ARRAY_OVERHEAD
    See Also:
      - Constant Field Values

  - ### STRING

    public static final SizeFunction<String> STRING

  - ### NUMBER

    public static final SizeFunction<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<Long> LONG

- ## Method Details

  - ### constantSize

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