Class SerializerFactory.ReflectionSerializerFactory

java.lang.Object
com.esotericsoftware.kryo.SerializerFactory.ReflectionSerializerFactory
All Implemented Interfaces:
SerializerFactory
Enclosing interface:
SerializerFactory

public static class SerializerFactory.ReflectionSerializerFactory extends Object implements SerializerFactory
This factory instantiates new serializers of a given class via reflection. The constructors of the given serializerClass must either take an instance of Kryo and an instance of Class as its parameter, take only a Kryo or Class as its only argument or take no arguments. If several of the described constructors are found, the first found constructor is used, in the order as they were just described.
  • Field Details

    • serializerClass

      private final Class<? extends Serializer> serializerClass
  • Constructor Details

    • ReflectionSerializerFactory

      public ReflectionSerializerFactory(Class<? extends Serializer> serializerClass)
  • Method Details

    • newSerializer

      public Serializer newSerializer(Kryo kryo, Class<?> type)
      Description copied from interface: SerializerFactory
      Creates a new serializer
      Specified by:
      newSerializer in interface SerializerFactory
      Parameters:
      kryo - The serializer instance requesting the new serializer.
      type - The type of the object that is to be serialized.
      Returns:
      An implementation of a serializer that is able to serialize an object of type type.
    • newSerializer

      public static Serializer newSerializer(Kryo kryo, Class<? extends Serializer> serializerClass, Class<?> type)
      Creates a new instance of the specified serializer for serializing the specified class. Serializers must have a zero argument constructor or one that takes (Kryo), (Class), or (Kryo, Class).