Class SerializerFactory.ReflectionSerializerFactory

  • All Implemented Interfaces:
    SerializerFactory
    Enclosing interface:
    SerializerFactory

    public static class SerializerFactory.ReflectionSerializerFactory
    extends java.lang.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 Detail

      • serializerClass

        private final java.lang.Class<? extends Serializer> serializerClass
    • Constructor Detail

      • ReflectionSerializerFactory

        public ReflectionSerializerFactory​(java.lang.Class<? extends Serializer> serializerClass)
    • Method Detail

      • newSerializer

        public Serializer newSerializer​(Kryo kryo,
                                        java.lang.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,
                                               java.lang.Class<? extends Serializer> serializerClass,
                                               java.lang.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).