Skip to content

Commit

Permalink
Merge pull request #220 from amiton/master
Browse files Browse the repository at this point in the history
Per romix's request regarding issue #218 here is the changed code via pull request
  • Loading branch information
romix committed May 22, 2014
2 parents 7fa98c6 + 3bac35c commit b82531a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/com/esotericsoftware/kryo/Kryo.java
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,8 @@ public void addDefaultSerializer (Class type, Class<? extends Serializer> serial
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);
}
final Serializer serializerForAnnotation = getDefaultSerializerForAnnotatedType(type);
if (serializerForAnnotation!=null) return serializerForAnnotation;

for (int i = 0, n = defaultSerializers.size(); i < n; i++) {
DefaultSerializerEntry entry = defaultSerializers.get(i);
Expand All @@ -359,6 +357,16 @@ public Serializer getDefaultSerializer (Class type) {
return newDefaultSerializer(type);
}

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;
}

/** Called by {@link #getDefaultSerializer(Class)} when no default serializers matched the type. Subclasses can override this
* method to customize behavior. The default implementation calls {@link SerializerFactory#makeSerializer(Kryo, Class)} using
* the {@link #setDefaultSerializer(Class) default serializer}. */
Expand Down

0 comments on commit b82531a

Please sign in to comment.