本文整理汇总了Java中com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer类的典型用法代码示例。如果您正苦于以下问题:Java CompatibleFieldSerializer类的具体用法?Java CompatibleFieldSerializer怎么用?Java CompatibleFieldSerializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompatibleFieldSerializer类属于com.esotericsoftware.kryo.serializers包,在下文中一共展示了CompatibleFieldSerializer类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createKryoInstance
import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
private Kryo createKryoInstance() {
Kryo kryo = new Kryo();
kryo.register(RakTable.class);
kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
kryo.setReferences(false);
kryo.register(Collections.singletonList("").getClass(), new ArraysAsListSerializer());
UnmodifiableCollectionsSerializer.registerSerializers(kryo);
SynchronizedCollectionsSerializer.registerSerializers(kryo);
kryo.addDefaultSerializer(new ArrayList<>().subList(0, 0).getClass(), new CollectionSerializer());
kryo.addDefaultSerializer(new LinkedList<>().subList(0, 0).getClass(), new CollectionSerializer());
kryo.register(UUID.class, new UUIDSerializer());
for (Class<?> clazz : mCustomSerializers.keySet()) {
kryo.register(clazz, mCustomSerializers.get(clazz));
}
kryo.setInstantiatorStrategy(
new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
return kryo;
}
示例2: testAddedField
import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
public void testAddedField () throws FileNotFoundException {
TestClass object1 = new TestClass();
object1.child = new TestClass();
object1.other = new AnotherClass();
object1.other.value = "meow";
CompatibleFieldSerializer serializer = new CompatibleFieldSerializer(kryo, TestClass.class);
serializer.removeField("text");
kryo.register(TestClass.class, serializer);
kryo.register(AnotherClass.class, new CompatibleFieldSerializer(kryo, AnotherClass.class));
roundTrip(74, 74, object1);
kryo.register(TestClass.class, new CompatibleFieldSerializer(kryo, TestClass.class));
Object object2 = kryo.readClassAndObject(input);
assertEquals(object1, object2);
}
示例3: createKryoInstance
import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
private Kryo createKryoInstance() {
Kryo kryo = new Kryo();
kryo.register(IronTable.class);
kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
kryo.setReferences(false);
// Serialize Arrays$ArrayList
//noinspection ArraysAsListWithZeroOrOneArgument
kryo.register(Arrays.asList("").getClass(), new ArraysAsListSerializer());
UnmodifiableCollectionsSerializer.registerSerializers(kryo);
SynchronizedCollectionsSerializer.registerSerializers(kryo);
// Serialize inner AbstractList$SubAbstractListRandomAccess
kryo.addDefaultSerializer(new ArrayList<>().subList(0, 0).getClass(),
new NoArgCollectionSerializer());
// Serialize AbstractList$SubAbstractList
kryo.addDefaultSerializer(new LinkedList<>().subList(0, 0).getClass(),
new NoArgCollectionSerializer());
// To keep backward compatibility don't change the order of serializers above
kryo.setInstantiatorStrategy(
new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
return kryo;
}
示例4: createKryoInstance
import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
private Kryo createKryoInstance(boolean compatibilityMode) {
Kryo kryo = new Kryo();
if (compatibilityMode) {
kryo.getFieldSerializerConfig().setOptimizedGenerics(true);
}
kryo.register(PaperTable.class);
kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
kryo.setReferences(false);
// Serialize Arrays$ArrayList
//noinspection ArraysAsListWithZeroOrOneArgument
kryo.register(Arrays.asList("").getClass(), new ArraysAsListSerializer());
UnmodifiableCollectionsSerializer.registerSerializers(kryo);
SynchronizedCollectionsSerializer.registerSerializers(kryo);
// Serialize inner AbstractList$SubAbstractListRandomAccess
kryo.addDefaultSerializer(new ArrayList<>().subList(0, 0).getClass(),
new NoArgCollectionSerializer());
// Serialize AbstractList$SubAbstractList
kryo.addDefaultSerializer(new LinkedList<>().subList(0, 0).getClass(),
new NoArgCollectionSerializer());
// To keep backward compatibility don't change the order of serializers above
// UUID support
kryo.register(UUID.class, new UUIDSerializer());
for (Class<?> clazz : mCustomSerializers.keySet())
kryo.register(clazz, mCustomSerializers.get(clazz));
kryo.setInstantiatorStrategy(
new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
return kryo;
}
示例5: KryoConverter
import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
public KryoConverter(Class<T> clazz) {
this.clazz = clazz;
this.kryo = new Kryo();
this.kryo.register(clazz);
this.kryo.register(Date.class, new DateSerializer());
this.kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
this.kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
//
this.input = new Input();
this.output = new Output(new ByteArrayOutputStream());
}
示例6: init
import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
public static void init () {
PROFILE_DIRECTORY.mkdirs();
kryo = new Kryo();
kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
kryo.register(ContactInfo.class);
kryo.register(ServerDescriptor.class);
kryo.register(ArrayList.class);
kryo.register(byte[].class);
kryo.register(BigInteger.class);
kryo.register(ProfileWrapper.class);
kryo.register(ProfileOptions.class);
kryo.register(Profile.class);
}
示例7: create
import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
/**
* Creates a Kryo instance.
*
* @return Kryo instance
*/
@Override
public Kryo create() {
log.trace("Creating Kryo instance for {}", this);
Kryo kryo = new Kryo();
kryo.setRegistrationRequired(registrationRequired);
// If compatible serialization is enabled, override the default serializer.
if (compatible) {
kryo.setDefaultSerializer(CompatibleFieldSerializer::new);
}
// TODO rethink whether we want to use StdInstantiatorStrategy
kryo.setInstantiatorStrategy(
new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
for (RegistrationBlock block : registeredBlocks) {
int id = block.begin();
if (id == FLOATING_ID) {
id = kryo.getNextRegistrationId();
}
for (Pair<Class<?>[], Serializer<?>> entry : block.types()) {
register(kryo, entry.getLeft(), entry.getRight(), id++);
}
}
return kryo;
}
示例8: create
import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
/**
* Creates a Kryo instance.
*
* @return Kryo instance
*/
@Override
public Kryo create() {
log.trace("Creating Kryo instance for {}", this);
Kryo kryo = new Kryo();
kryo.setRegistrationRequired(registrationRequired);
// If compatible serialization is enabled, override the default serializer.
if (compatible) {
kryo.setDefaultSerializer(CompatibleFieldSerializer::new);
}
// TODO rethink whether we want to use StdInstantiatorStrategy
kryo.setInstantiatorStrategy(
new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
for (RegistrationBlock block : registeredBlocks) {
int id = block.begin();
if (id == FLOATING_ID) {
id = kryo.getNextRegistrationId();
}
for (Pair<Class<?>[], Serializer<?>> entry : block.types()) {
register(kryo, entry.getLeft(), entry.getRight(), id++);
}
}
return kryo;
}
示例9: initialValue
import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
@Override
protected Kryo initialValue() {
final Kryo kryo = new Kryo();
kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
kryo.register(File.class, fileSerializer);
kryo.register(DateTime.class, dateTimeSerializer);
return kryo;
}
示例10: newKryo
import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
private static Kryo newKryo() {
Kryo kryo = new Kryo();
kryo.register(RpcBody.class);
kryo.register(RpcMethod.class);
kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
return kryo;
}
示例11: testCompatibleFieldSerializer
import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
public void testCompatibleFieldSerializer () throws FileNotFoundException {
TestClass object1 = new TestClass();
object1.child = new TestClass();
object1.other = new AnotherClass();
object1.other.value = "meow";
kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
kryo.register(TestClass.class);
kryo.register(AnotherClass.class);
roundTrip(100, 100, object1);
}
示例12: testRemovedField
import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
public void testRemovedField () throws FileNotFoundException {
TestClass object1 = new TestClass();
object1.child = new TestClass();
kryo.register(TestClass.class, new CompatibleFieldSerializer(kryo, TestClass.class));
roundTrip(88, 88, object1);
CompatibleFieldSerializer serializer = new CompatibleFieldSerializer(kryo, TestClass.class);
serializer.removeField("text");
kryo.register(TestClass.class, serializer);
Object object2 = kryo.readClassAndObject(input);
assertEquals(object1, object2);
}
示例13: init
import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
public static void init () {
SERVERS_DIRECTORY.mkdirs();
kryo = new Kryo();
kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
kryo.register(ServerInfo.class);
}
示例14: createKryo
import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
/**
* Override this method to change serialization rule.
*
* @return Kryo serializer instance.
*/
protected Kryo createKryo() {
Kryo kryo = new KryoReflectionFactorySupport();
kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
return kryo;
}