本文整理汇总了Java中de.javakaffee.kryoserializers.KryoReflectionFactorySupport类的典型用法代码示例。如果您正苦于以下问题:Java KryoReflectionFactorySupport类的具体用法?Java KryoReflectionFactorySupport怎么用?Java KryoReflectionFactorySupport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KryoReflectionFactorySupport类属于de.javakaffee.kryoserializers包,在下文中一共展示了KryoReflectionFactorySupport类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createKryo
import de.javakaffee.kryoserializers.KryoReflectionFactorySupport; //导入依赖的package包/类
private Kryo createKryo() {
Kryo result = new KryoReflectionFactorySupport() {
@Override
public Serializer<?> getDefaultSerializer(@SuppressWarnings("rawtypes") final Class clazz) {
if (EnumMap.class.isAssignableFrom(clazz)) {
return new EnumMapSerializer();
}
if (SubListSerializers.ArrayListSubListSerializer.canSerialize(clazz) || SubListSerializers.JavaUtilSubListSerializer.canSerialize(clazz)) {
return SubListSerializers.createFor(clazz);
}
return super.getDefaultSerializer(clazz);
}
};
result.register(Collections.singletonList("").getClass(), new ArraysAsListSerializer());
UnmodifiableCollectionsSerializer.registerSerializers(result);
return result;
}
示例2: initialValue
import de.javakaffee.kryoserializers.KryoReflectionFactorySupport; //导入依赖的package包/类
@Override
protected Kryo initialValue() {
final Kryo kryo = new KryoReflectionFactorySupport() {
@Override
public Serializer<?> getDefaultSerializer(@SuppressWarnings("rawtypes") final Class clazz) {
if (EnumSet.class.isAssignableFrom(clazz)) {
return new EnumSetSerializer();
}
if (EnumMap.class.isAssignableFrom(clazz)) {
return new EnumMapSerializer();
}
final Serializer<?> serializer = super.getDefaultSerializer(clazz);
if (serializer instanceof FieldSerializer) {
((FieldSerializer<?>) serializer).setCopyTransient(false);
}
return serializer;
}
};
return kryo;
}
示例3: createKryo
import de.javakaffee.kryoserializers.KryoReflectionFactorySupport; //导入依赖的package包/类
private Kryo createKryo() {
Kryo kryo = new KryoReflectionFactorySupport() {
@Override
public Serializer<?> getDefaultSerializer(@SuppressWarnings("rawtypes") final Class clazz) {
if (EnumMap.class.isAssignableFrom(clazz)) {
return new EnumMapSerializer();
}
if (SubListSerializers.ArrayListSubListSerializer.canSerialize(clazz) || SubListSerializers.JavaUtilSubListSerializer.canSerialize(clazz)) {
return SubListSerializers.createFor(clazz);
}
return super.getDefaultSerializer(clazz);
}
};
kryo.register(Arrays.asList("").getClass(), new ArraysAsListSerializer());
UnmodifiableCollectionsSerializer.registerSerializers(kryo);
return kryo;
}
示例4: deserializeAlgoMetric
import de.javakaffee.kryoserializers.KryoReflectionFactorySupport; //导入依赖的package包/类
public static Metric deserializeAlgoMetric(byte [] data) {
ByteArrayInputStream bais = new ByteArrayInputStream(data);
Input input = new Input(bais);
KryoReflectionFactorySupport kryoRef = getKryoRef();
return ((Metric)kryoRef.readClassAndObject(input));
}
示例5: initialValue
import de.javakaffee.kryoserializers.KryoReflectionFactorySupport; //导入依赖的package包/类
protected Kryo initialValue() {
Kryo _kryo = new KryoReflectionFactorySupport() {
@Override
@SuppressWarnings( { "rawtypes", "unchecked" } )
public Serializer<?> getDefaultSerializer( final Class type ) {
if ( EnumSet.class.isAssignableFrom( type ) ) {
return new EnumSetSerializer();
}
if ( EnumMap.class.isAssignableFrom( type ) ) {
return new EnumMapSerializer();
}
if ( Collection.class.isAssignableFrom( type ) ) {
return new CopyForIterateCollectionSerializer();
}
if ( Map.class.isAssignableFrom( type ) ) {
return new CopyForIterateMapSerializer();
}
if ( Date.class.isAssignableFrom( type ) ) {
return new DateSerializer( type );
}
return super.getDefaultSerializer( type );
}
};
_kryo.setRegistrationRequired(false);
_kryo.register( Arrays.asList( "" ).getClass(), new ArraysAsListSerializer() );
_kryo.register( Collections.EMPTY_LIST.getClass(), new CollectionsEmptyListSerializer() );
_kryo.register( Collections.EMPTY_MAP.getClass(), new CollectionsEmptyMapSerializer() );
_kryo.register( Collections.EMPTY_SET.getClass(), new CollectionsEmptySetSerializer() );
_kryo.register( Collections.singletonList( "" ).getClass(), new CollectionsSingletonListSerializer() );
_kryo.register( Collections.singleton( "" ).getClass(), new CollectionsSingletonSetSerializer() );
_kryo.register( Collections.singletonMap( "", "" ).getClass(), new CollectionsSingletonMapSerializer() );
_kryo.register( BigDecimal.class, new BigDecimalSerializer() );
_kryo.register( BigInteger.class, new BigIntegerSerializer() );
// _kryo.register( Pattern.class, new RegexSerializer() );
// _kryo.register( BitSet.class, new BitSetSerializer() );
// _kryo.register( URI.class, new URISerializer() );
// _kryo.register( UUID.class, new UUIDSerializer() );
_kryo.register( GregorianCalendar.class, new GregorianCalendarSerializer() );
_kryo.register( InvocationHandler.class, new JdkProxySerializer() );
UnmodifiableCollectionsSerializer.registerSerializers( _kryo );
SynchronizedCollectionsSerializer.registerSerializers( _kryo );
// DeflateSerializer d;
// _kryo..setDefaultSerializer(CompatibleFieldSerializer.class);
return _kryo;
}
示例6: createKryo
import de.javakaffee.kryoserializers.KryoReflectionFactorySupport; //导入依赖的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;
}