Skip to content

Commit f7270ed

Browse files
committed
refactoring wrt #312
1 parent 9039a9b commit f7270ed

File tree

1 file changed

+56
-9
lines changed

1 file changed

+56
-9
lines changed

src/main/java/com/fasterxml/jackson/databind/jsontype/impl/StdSubtypeResolver.java

+56-9
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public StdSubtypeResolver() { }
2424

2525
/*
2626
/**********************************************************
27-
/* Public API
27+
/* Subtype registration
2828
/**********************************************************
2929
*/
3030

@@ -46,14 +46,18 @@ public void registerSubtypes(Class<?>... classes) {
4646
}
4747
registerSubtypes(types);
4848
}
49-
50-
/**
51-
* @deprecated Since 2.6
49+
50+
/*
51+
/**********************************************************
52+
/* Resolution by class (serialization)
53+
/**********************************************************
5254
*/
55+
5356
@Override
54-
public Collection<NamedType> collectAndResolveSubtypes(AnnotatedMember property,
55-
MapperConfig<?> config, AnnotationIntrospector ai, JavaType baseType)
57+
public Collection<NamedType> collectAndResolveSubtypesByClass(MapperConfig<?> config,
58+
AnnotatedMember property, JavaType baseType)
5659
{
60+
final AnnotationIntrospector ai = config.getAnnotationIntrospector();
5761
// for backwards compatibility, must allow null here:
5862
Class<?> rawBase = (baseType == null) ? property.getRawType() : baseType.getRawClass();
5963

@@ -88,9 +92,10 @@ public Collection<NamedType> collectAndResolveSubtypes(AnnotatedMember property,
8892
}
8993

9094
@Override
91-
public Collection<NamedType> collectAndResolveSubtypes(AnnotatedClass type,
92-
MapperConfig<?> config, AnnotationIntrospector ai)
95+
public Collection<NamedType> collectAndResolveSubtypesByClass(MapperConfig<?> config,
96+
AnnotatedClass type)
9397
{
98+
final AnnotationIntrospector ai = config.getAnnotationIntrospector();
9499
HashMap<NamedType, NamedType> subtypes = new HashMap<NamedType, NamedType>();
95100
// [JACKSON-257] then consider registered subtypes (which have precedence over annotations)
96101
if (_registeredSubtypes != null) {
@@ -109,12 +114,54 @@ public Collection<NamedType> collectAndResolveSubtypes(AnnotatedClass type,
109114
return new ArrayList<NamedType>(subtypes.values());
110115
}
111116

117+
/*
118+
/**********************************************************
119+
/* Resolution by class (deserialization)
120+
/**********************************************************
121+
*/
122+
123+
@Override
124+
public Collection<NamedType> collectAndResolveSubtypesByName(MapperConfig<?> config,
125+
AnnotatedMember property, JavaType baseType)
126+
{
127+
// !!! TODO: implement properly
128+
return collectAndResolveSubtypesByClass(config, property, baseType);
129+
}
130+
131+
@Override
132+
public Collection<NamedType> collectAndResolveSubtypesByName(MapperConfig<?> config,
133+
AnnotatedClass type)
134+
{
135+
// !!! TODO: implement properly
136+
return collectAndResolveSubtypesByClass(config, type);
137+
}
138+
139+
/*
140+
/**********************************************************
141+
/* Deprecated method overrides
142+
/**********************************************************
143+
*/
144+
145+
@Override
146+
public Collection<NamedType> collectAndResolveSubtypes(AnnotatedMember property,
147+
MapperConfig<?> config, AnnotationIntrospector ai, JavaType baseType)
148+
{
149+
return collectAndResolveSubtypesByClass(config, property, baseType);
150+
}
151+
152+
@Override
153+
public Collection<NamedType> collectAndResolveSubtypes(AnnotatedClass type,
154+
MapperConfig<?> config, AnnotationIntrospector ai)
155+
{
156+
return collectAndResolveSubtypesByClass(config, type);
157+
}
158+
112159
/*
113160
/**********************************************************
114161
/* Internal methods
115162
/**********************************************************
116163
*/
117-
164+
118165
/**
119166
* Method called to find subtypes for a specific type (class)
120167
*/

0 commit comments

Comments
 (0)