Class ArraySerializer

java.lang.Object
com.esotericsoftware.kryo.Serializer<com.badlogic.gdx.utils.Array>
com.github.tommyettinger.kryo.gdx.ArraySerializer

public class ArraySerializer extends com.esotericsoftware.kryo.Serializer<com.badlogic.gdx.utils.Array>
Serializes libGDX Array objects.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.badlogic.gdx.utils.Array
    copy(com.esotericsoftware.kryo.Kryo kryo, com.badlogic.gdx.utils.Array original)
     
    protected com.badlogic.gdx.utils.Array<?>
    create(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input, Class<? extends com.badlogic.gdx.utils.Array> type, int size)
    Used by read(Kryo, Input, Class) to create the new object.
    protected com.badlogic.gdx.utils.Array
    createCopy(com.esotericsoftware.kryo.Kryo kryo, com.badlogic.gdx.utils.Array original)
    Used by copy(Kryo, Array) to create the new object.
     
    com.esotericsoftware.kryo.Serializer
     
    com.badlogic.gdx.utils.Array
    read(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input, Class<? extends com.badlogic.gdx.utils.Array> type)
     
    void
    setElementClass(Class elementClass)
    The concrete class of the collection elements, or null if it is not known.
    void
    setElementClass(Class elementClass, com.esotericsoftware.kryo.Serializer serializer)
    void
    setElementsCanBeNull(boolean elementsCanBeNull)
     
    void
    setElementSerializer(com.esotericsoftware.kryo.Serializer elementSerializer)
    The serializer to be used for elements in collection, or null to use the serializer registered with Kryo for each element's type.
    void
    write(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output, com.badlogic.gdx.utils.Array collection)
     
    protected void
    writeHeader(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output, com.badlogic.gdx.utils.Array collection)
    Can be overidden to write data needed for create(Kryo, Input, Class, int).

    Methods inherited from class com.esotericsoftware.kryo.Serializer

    getAcceptsNull, isImmutable, setAcceptsNull, setImmutable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • setElementsCanBeNull

      public void setElementsCanBeNull(boolean elementsCanBeNull)
      Parameters:
      elementsCanBeNull - False if all elements are not null. This saves 1 byte per element if elementClass is set. True if it is not known (default).
    • setElementClass

      public void setElementClass(Class elementClass)
      The concrete class of the collection elements, or null if it is not known. This saves 1-2 bytes per element. Only set to a non-null value if the elements in the collection are known to all be instances of this class (or null).
    • getElementClass

    • setElementClass

      public void setElementClass(Class elementClass, com.esotericsoftware.kryo.Serializer serializer)
    • setElementSerializer

      public void setElementSerializer(com.esotericsoftware.kryo.Serializer elementSerializer)
      The serializer to be used for elements in collection, or null to use the serializer registered with Kryo for each element's type. Default is null.
    • getElementSerializer

      public com.esotericsoftware.kryo.Serializer getElementSerializer()
    • write

      public void write(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output, com.badlogic.gdx.utils.Array collection)
      Specified by:
      write in class com.esotericsoftware.kryo.Serializer<com.badlogic.gdx.utils.Array>
    • writeHeader

      protected void writeHeader(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output, com.badlogic.gdx.utils.Array collection)
      Can be overidden to write data needed for create(Kryo, Input, Class, int). The default implementation does nothing.
    • create

      protected com.badlogic.gdx.utils.Array<?> create(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input, Class<? extends com.badlogic.gdx.utils.Array> type, int size)
      Used by read(Kryo, Input, Class) to create the new object. This can be overridden to customize object creation (eg to call a constructor with arguments), optionally reading bytes written in writeHeader(Kryo, Output, Array). The default implementation uses Kryo.newInstance(Class) with special cases for ArrayList and HashSet.
    • read

      public com.badlogic.gdx.utils.Array read(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input, Class<? extends com.badlogic.gdx.utils.Array> type)
      Specified by:
      read in class com.esotericsoftware.kryo.Serializer<com.badlogic.gdx.utils.Array>
    • createCopy

      protected com.badlogic.gdx.utils.Array createCopy(com.esotericsoftware.kryo.Kryo kryo, com.badlogic.gdx.utils.Array original)
      Used by copy(Kryo, Array) to create the new object. This can be overridden to customize object creation, eg to call a constructor with arguments. The default implementation uses Kryo.newInstance(Class).
    • copy

      public com.badlogic.gdx.utils.Array copy(com.esotericsoftware.kryo.Kryo kryo, com.badlogic.gdx.utils.Array original)
      Overrides:
      copy in class com.esotericsoftware.kryo.Serializer<com.badlogic.gdx.utils.Array>