Class ImmutableTypesMapper

java.lang.Object
com.thoughtworks.xstream.mapper.MapperWrapper
com.thoughtworks.xstream.mapper.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 Details

    • unreferenceableTypes

      private final Set unreferenceableTypes
    • immutableTypes

      private final Set immutableTypes
  • Constructor Details

    • ImmutableTypesMapper

      public ImmutableTypesMapper(Mapper wrapped)
  • Method Details

    • addImmutableType

      public void addImmutableType(Class type)
      Deprecated.
    • addImmutableType

      public void addImmutableType(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(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
    • isReferenceable

      public boolean isReferenceable(Class type)
      Description copied from interface: Mapper
      Whether this type is referenceable in a stream.
      Specified by:
      isReferenceable in interface Mapper
      Overrides:
      isReferenceable in class MapperWrapper