public Serializer<?> getSerializer(Kryo kryo) { switch (serializerDefinitionType) { case UNSPECIFIED: return null; case CLASS: return ReflectionSerializerFactory.makeSerializer(kryo, serializerClass, registeredClass); case INSTANCE: return serializableSerializerInstance.getSerializer(); default: // this should not happen; adding as a guard for the future throw new IllegalStateException( "Unrecognized Kryo registration serializer definition type: " + serializerDefinitionType); } }
/** Sets the serializer to use when no {@link #addDefaultSerializer(Class, Class) default serializers} match an object's type. * Default is {@link FieldSerializer}. * @see #newDefaultSerializer(Class) */ public void setDefaultSerializer (Class<? extends Serializer> serializer) { if (serializer == null) throw new IllegalArgumentException("serializer cannot be null."); defaultSerializer = new ReflectionSerializerFactory(serializer); }
/** Sets the serializer to use when no {@link #addDefaultSerializer(Class, Class) default serializers} match an object's type. * Default is {@link FieldSerializer}. * @see #newDefaultSerializer(Class) */ public void setDefaultSerializer (Class<? extends Serializer> serializer) { if (serializer == null) throw new IllegalArgumentException("serializer cannot be null."); defaultSerializer = new ReflectionSerializerFactory(serializer); }
@Override public Serializer makeSerializer (Kryo kryo, Class<?> type) { return makeSerializer(kryo, serializerClass, type); }
/** Sets the serializer to use when no {@link #addDefaultSerializer(Class, Class) default serializers} match an object's type. * Default is {@link FieldSerializer}. * @see #newDefaultSerializer(Class) */ public void setDefaultSerializer (Class<? extends Serializer> serializer) { if (serializer == null) throw new IllegalArgumentException("serializer cannot be null."); defaultSerializer = new ReflectionSerializerFactory(serializer); }
@Override public Serializer makeSerializer (Kryo kryo, Class<?> type) { return makeSerializer(kryo, serializerClass, type); }
/** Sets the serializer to use when no {@link #addDefaultSerializer(Class, Class) default serializers} match an object's type. * Default is {@link FieldSerializer}. * @see #newDefaultSerializer(Class) */ public void setDefaultSerializer (Class<? extends Serializer> serializer) { if (serializer == null) throw new IllegalArgumentException("serializer cannot be null."); defaultSerializer = new ReflectionSerializerFactory(serializer); }
@Override public Serializer makeSerializer (Kryo kryo, Class<?> type) { return makeSerializer(kryo, serializerClass, type); }
if (type == null) throw new IllegalArgumentException("type cannot be null."); if (serializerClass == null) throw new IllegalArgumentException("serializerClass cannot be null."); DefaultSerializerEntry entry = new DefaultSerializerEntry(type, new ReflectionSerializerFactory(serializerClass)); defaultSerializers.add(defaultSerializers.size() - lowPriorityDefaultSerializerCount, entry);
@Override public Serializer makeSerializer (Kryo kryo, Class<?> type) { return makeSerializer(kryo, serializerClass, type); }
if (type == null) throw new IllegalArgumentException("type cannot be null."); if (serializerClass == null) throw new IllegalArgumentException("serializerClass cannot be null."); DefaultSerializerEntry entry = new DefaultSerializerEntry(type, new ReflectionSerializerFactory(serializerClass)); defaultSerializers.add(defaultSerializers.size() - lowPriorityDefaultSerializerCount, entry);
protected Serializer getDefaultSerializerForAnnotatedType (Class type) { if (type.isAnnotationPresent(DefaultSerializer.class)) { DefaultSerializer defaultSerializerAnnotation = (DefaultSerializer)type.getAnnotation(DefaultSerializer.class); return ReflectionSerializerFactory.makeSerializer(this, defaultSerializerAnnotation.value(), type); } return null; }
if (type == null) throw new IllegalArgumentException("type cannot be null."); if (serializerClass == null) throw new IllegalArgumentException("serializerClass cannot be null."); DefaultSerializerEntry entry = new DefaultSerializerEntry(type, new ReflectionSerializerFactory(serializerClass)); defaultSerializers.add(defaultSerializers.size() - lowPriorityDefaultSerializerCount, entry);
protected Serializer getDefaultSerializerForAnnotatedType (Class type) { if (type.isAnnotationPresent(DefaultSerializer.class)) { DefaultSerializer defaultSerializerAnnotation = (DefaultSerializer)type.getAnnotation(DefaultSerializer.class); return ReflectionSerializerFactory.makeSerializer(this, defaultSerializerAnnotation.value(), type); } return null; }
if (type == null) throw new IllegalArgumentException("type cannot be null."); if (serializerClass == null) throw new IllegalArgumentException("serializerClass cannot be null."); DefaultSerializerEntry entry = new DefaultSerializerEntry(type, new ReflectionSerializerFactory(serializerClass)); defaultSerializers.add(defaultSerializers.size() - lowPriorityDefaultSerializerCount, entry);
public Serializer<?> getSerializer(Kryo kryo) { switch (serializerDefinitionType) { case UNSPECIFIED: return null; case CLASS: return ReflectionSerializerFactory.makeSerializer(kryo, serializerClass, registeredClass); case INSTANCE: return serializableSerializerInstance.getSerializer(); default: // this should not happen; adding as a guard for the future throw new IllegalStateException( "Unrecognized Kryo registration serializer definition type: " + serializerDefinitionType); } }
public Serializer<?> getSerializer(Kryo kryo) { switch (serializerDefinitionType) { case UNSPECIFIED: return null; case CLASS: return ReflectionSerializerFactory.makeSerializer(kryo, serializerClass, registeredClass); case INSTANCE: return serializableSerializerInstance.getSerializer(); default: // this should not happen; adding as a guard for the future throw new IllegalStateException( "Unrecognized Kryo registration serializer definition type: " + serializerDefinitionType); } }
/** Returns the best matching serializer for a class. This method can be overridden to implement custom logic to choose a * serializer. */ public Serializer getDefaultSerializer (Class type) { if (type == null) throw new IllegalArgumentException("type cannot be null."); if (type.isAnnotationPresent(DefaultSerializer.class)) { DefaultSerializer defaultSerializerAnnotation = (DefaultSerializer)type.getAnnotation(DefaultSerializer.class); return ReflectionSerializerFactory.makeSerializer(this, defaultSerializerAnnotation.value(), type); } for (int i = 0, n = defaultSerializers.size(); i < n; i++) { DefaultSerializerEntry entry = defaultSerializers.get(i); if (entry.type.isAssignableFrom(type)) { Serializer defaultSerializer = entry.serializerFactory.makeSerializer(this, type); return defaultSerializer; } } return newDefaultSerializer(type); }
/** Returns the best matching serializer for a class. This method can be overridden to implement custom logic to choose a * serializer. */ public Serializer getDefaultSerializer (Class type) { if (type == null) throw new IllegalArgumentException("type cannot be null."); if (type.isAnnotationPresent(DefaultSerializer.class)) { DefaultSerializer defaultSerializerAnnotation = (DefaultSerializer)type.getAnnotation(DefaultSerializer.class); return ReflectionSerializerFactory.makeSerializer(this, defaultSerializerAnnotation.value(), type); } for (int i = 0, n = defaultSerializers.size(); i < n; i++) { DefaultSerializerEntry entry = defaultSerializers.get(i); if (entry.type.isAssignableFrom(type)) { return entry.serializerFactory.makeSerializer(this, type); } } return newDefaultSerializer(type); }
Serializer s = ReflectionSerializerFactory.makeSerializer(fieldSerializer.getKryo(), serializerClass, field.getClass()); fields[i].setSerializer(s); if (elementSerializerClass == Serializer.class) elementSerializerClass = null; Serializer elementSerializer = (elementSerializerClass == null) ? null : ReflectionSerializerFactory.makeSerializer(fieldSerializer.getKryo(), elementSerializerClass, field.getClass()); boolean elementsCanBeNull = annotation.elementsCanBeNull(); : ReflectionSerializerFactory.makeSerializer(fieldSerializer.getKryo(), valueSerializerClass, field.getClass()); Serializer keySerializer = (keySerializerClass == null) ? null : ReflectionSerializerFactory.makeSerializer(fieldSerializer.getKryo(), keySerializerClass, field.getClass()); boolean valuesCanBeNull = annotation.valuesCanBeNull(); boolean keysCanBeNull = annotation.keysCanBeNull();