Class ImmutableTypesMapper

  • All Implemented Interfaces:
    Mapper

    public class ImmutableTypesMapper
    extends MapperWrapper
    Mapper that specifies which types are basic immutable types. Types that are marked as immutable will be written multiple times in the serialization stream without using references.

    Note, that an already persisted stream might still contain references for immutable types. They can be dereferenced at deserialization time, unless the type is explicitly declared as unreferenceable. However, this is only possible at the expense of memory book-keeping all instances.

    • Field Detail

      • unreferenceableTypes

        private final java.util.Set unreferenceableTypes
      • immutableTypes

        private final java.util.Set immutableTypes
    • Constructor Detail

      • ImmutableTypesMapper

        public ImmutableTypesMapper​(Mapper wrapped)
    • Method Detail

      • addImmutableType

        public void addImmutableType​(java.lang.Class type,
                                     boolean isReferenceable)
        Declare a type as immutable.
        Parameters:
        type - the immutable type
        isReferenceable - flag for possible references
        Since:
        1.4.9
      • isImmutableValueType

        public boolean isImmutableValueType​(java.lang.Class type)
        Description copied from interface: Mapper
        Whether this type is a simple immutable value (int, boolean, String, URL, etc). Immutable types will be repeatedly written in the serialized stream, instead of using object references.
        Specified by:
        isImmutableValueType in interface Mapper
        Overrides:
        isImmutableValueType in class MapperWrapper