@Test public void test() { final Kryo kryo = new Kryo(); kryo.register(TestSingleton.class, SingletonSerializer.of("getInstance")); final Output output = new Output(1024); kryo.writeClassAndObject(output, TestSingleton.getInstance()); final Input input = new Input(output.getBuffer()); final TestSingleton deserialized = (TestSingleton) kryo.readClassAndObject(input); assertEquals(TestSingleton.getInstance(), deserialized); }
public static <T> SingletonSerializer<T> of(String methodName) { return new SingletonSerializer<>(methodName); }
SingletonSerializer extends Serializer<T> { public static <T> SingletonSerializer<T> of(String methodName) { return new SingletonSerializer<>(methodName); } }
SingletonSerializer extends Serializer<T> { public static <T> SingletonSerializer<T> of(String methodName) { return new SingletonSerializer<>(methodName); } private  SingletonSerializer(String methodName); }
SingletonSerializer extends Serializer<T> { public static <T> SingletonSerializer<T> of(String methodName) { return new SingletonSerializer<>(methodName); } private  SingletonSerializer(String methodName); static SingletonSerializer<T> of(String methodName); @Override void write(Kryo kryo, Output output, T object); @Override @SuppressWarnings("unchecked") T read(Kryo kryo, Input input, Class<T> type); }
SingletonSerializer extends Serializer<T> { public static <T> SingletonSerializer<T> of(String methodName) { return new SingletonSerializer<>(methodName); } private  SingletonSerializer(String methodName); static SingletonSerializer<T> of(String methodName); @Override void write(Kryo kryo, Output output, T object); @Override @SuppressWarnings("unchecked") T read(Kryo kryo, Input input, Class<T> type);  }