Skip to content

Commit

Permalink
refactoring wrt #312
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 26, 2015
1 parent 9039a9b commit f7270ed
Showing 1 changed file with 56 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public StdSubtypeResolver() { }

/*
/**********************************************************
/* Public API
/* Subtype registration
/**********************************************************
*/

Expand All @@ -46,14 +46,18 @@ public void registerSubtypes(Class<?>... classes) {
}
registerSubtypes(types);
}

/**
* @deprecated Since 2.6

/*
/**********************************************************
/* Resolution by class (serialization)
/**********************************************************
*/

@Override
public Collection<NamedType> collectAndResolveSubtypes(AnnotatedMember property,
MapperConfig<?> config, AnnotationIntrospector ai, JavaType baseType)
public Collection<NamedType> collectAndResolveSubtypesByClass(MapperConfig<?> config,
AnnotatedMember property, JavaType baseType)
{
final AnnotationIntrospector ai = config.getAnnotationIntrospector();
// for backwards compatibility, must allow null here:
Class<?> rawBase = (baseType == null) ? property.getRawType() : baseType.getRawClass();

Expand Down Expand Up @@ -88,9 +92,10 @@ public Collection<NamedType> collectAndResolveSubtypes(AnnotatedMember property,
}

@Override
public Collection<NamedType> collectAndResolveSubtypes(AnnotatedClass type,
MapperConfig<?> config, AnnotationIntrospector ai)
public Collection<NamedType> collectAndResolveSubtypesByClass(MapperConfig<?> config,
AnnotatedClass type)
{
final AnnotationIntrospector ai = config.getAnnotationIntrospector();
HashMap<NamedType, NamedType> subtypes = new HashMap<NamedType, NamedType>();
// [JACKSON-257] then consider registered subtypes (which have precedence over annotations)
if (_registeredSubtypes != null) {
Expand All @@ -109,12 +114,54 @@ public Collection<NamedType> collectAndResolveSubtypes(AnnotatedClass type,
return new ArrayList<NamedType>(subtypes.values());
}

/*
/**********************************************************
/* Resolution by class (deserialization)
/**********************************************************
*/

@Override
public Collection<NamedType> collectAndResolveSubtypesByName(MapperConfig<?> config,
AnnotatedMember property, JavaType baseType)
{
// !!! TODO: implement properly
return collectAndResolveSubtypesByClass(config, property, baseType);
}

@Override
public Collection<NamedType> collectAndResolveSubtypesByName(MapperConfig<?> config,
AnnotatedClass type)
{
// !!! TODO: implement properly
return collectAndResolveSubtypesByClass(config, type);
}

/*
/**********************************************************
/* Deprecated method overrides
/**********************************************************
*/

@Override
public Collection<NamedType> collectAndResolveSubtypes(AnnotatedMember property,
MapperConfig<?> config, AnnotationIntrospector ai, JavaType baseType)
{
return collectAndResolveSubtypesByClass(config, property, baseType);
}

@Override
public Collection<NamedType> collectAndResolveSubtypes(AnnotatedClass type,
MapperConfig<?> config, AnnotationIntrospector ai)
{
return collectAndResolveSubtypesByClass(config, type);
}

/*
/**********************************************************
/* Internal methods
/**********************************************************
*/

/**
* Method called to find subtypes for a specific type (class)
*/
Expand Down

0 comments on commit f7270ed

Please sign in to comment.