@@ -38,15 +38,15 @@ public class BasicPolymorphicTypeValidator
38
38
* (base type or resolved subtype)
39
39
*/
40
40
public abstract static class TypeMatcher { // note: public since 2.11
41
- public abstract boolean match (Class <?> clazz );
41
+ public abstract boolean match (MapperConfig <?> config , Class <?> clazz );
42
42
}
43
43
44
44
/**
45
45
* General matcher interface (predicate) for validating unresolved
46
46
* subclass class name.
47
47
*/
48
48
public abstract static class NameMatcher { // note: public since 2.11
49
- public abstract boolean match (String clazzName );
49
+ public abstract boolean match (MapperConfig <?> config , String clazzName );
50
50
}
51
51
52
52
/*
@@ -104,7 +104,7 @@ protected Builder() { }
104
104
public Builder allowIfBaseType (final Class <?> baseOfBase ) {
105
105
return _appendBaseMatcher (new TypeMatcher () {
106
106
@ Override
107
- public boolean match (Class <?> clazz ) {
107
+ public boolean match (MapperConfig <?> config , Class <?> clazz ) {
108
108
return baseOfBase .isAssignableFrom (clazz );
109
109
}
110
110
});
@@ -130,7 +130,7 @@ public boolean match(Class<?> clazz) {
130
130
public Builder allowIfBaseType (final Pattern patternForBase ) {
131
131
return _appendBaseMatcher (new TypeMatcher () {
132
132
@ Override
133
- public boolean match (Class <?> clazz ) {
133
+ public boolean match (MapperConfig <?> config , Class <?> clazz ) {
134
134
return patternForBase .matcher (clazz .getName ()).matches ();
135
135
}
136
136
});
@@ -150,7 +150,7 @@ public boolean match(Class<?> clazz) {
150
150
public Builder allowIfBaseType (final String prefixForBase ) {
151
151
return _appendBaseMatcher (new TypeMatcher () {
152
152
@ Override
153
- public boolean match (Class <?> clazz ) {
153
+ public boolean match (MapperConfig <?> config , Class <?> clazz ) {
154
154
return clazz .getName ().startsWith (prefixForBase );
155
155
}
156
156
});
@@ -207,7 +207,7 @@ public Builder denyForExactBaseType(final Class<?> baseTypeToDeny) {
207
207
public Builder allowIfSubType (final Class <?> subTypeBase ) {
208
208
return _appendSubClassMatcher (new TypeMatcher () {
209
209
@ Override
210
- public boolean match (Class <?> clazz ) {
210
+ public boolean match (MapperConfig <?> config , Class <?> clazz ) {
211
211
return subTypeBase .isAssignableFrom (clazz );
212
212
}
213
213
});
@@ -232,7 +232,7 @@ public boolean match(Class<?> clazz) {
232
232
public Builder allowIfSubType (final Pattern patternForSubType ) {
233
233
return _appendSubNameMatcher (new NameMatcher () {
234
234
@ Override
235
- public boolean match (String clazzName ) {
235
+ public boolean match (MapperConfig <?> config , String clazzName ) {
236
236
return patternForSubType .matcher (clazzName ).matches ();
237
237
}
238
238
});
@@ -252,7 +252,7 @@ public boolean match(String clazzName) {
252
252
public Builder allowIfSubType (final String prefixForSubType ) {
253
253
return _appendSubNameMatcher (new NameMatcher () {
254
254
@ Override
255
- public boolean match (String clazzName ) {
255
+ public boolean match (MapperConfig <?> config , String clazzName ) {
256
256
return clazzName .startsWith (prefixForSubType );
257
257
}
258
258
});
@@ -290,7 +290,7 @@ public Builder allowIfSubType(final TypeMatcher matcher) {
290
290
public Builder allowIfSubTypeIsArray () {
291
291
return _appendSubClassMatcher (new TypeMatcher () {
292
292
@ Override
293
- public boolean match (Class <?> clazz ) {
293
+ public boolean match (MapperConfig <?> config , Class <?> clazz ) {
294
294
return clazz .isArray ();
295
295
}
296
296
});
@@ -320,7 +320,7 @@ public boolean match(Class<?> clazz) {
320
320
public Builder allowSubTypesWithExplicitDeserializer () {
321
321
return _appendSubClassMatcher (new TypeMatcher () {
322
322
@ Override
323
- public boolean match (Class <?> clazz ) {
323
+ public boolean match (MapperConfig <?> config , Class <?> clazz ) {
324
324
return clazz .isArray ();
325
325
}
326
326
});
@@ -414,7 +414,7 @@ public Validity validateBaseType(MapperConfig<?> ctxt, JavaType baseType) {
414
414
}
415
415
if (_baseTypeMatchers != null ) {
416
416
for (TypeMatcher m : _baseTypeMatchers ) {
417
- if (m .match (rawBase )) {
417
+ if (m .match (ctxt , rawBase )) {
418
418
return Validity .ALLOWED ;
419
419
}
420
420
}
@@ -430,7 +430,7 @@ public Validity validateSubClassName(MapperConfig<?> ctxt, JavaType baseType,
430
430
//System.err.println("validateSubClassName('"+subClassName+"')");
431
431
if (_subTypeNameMatchers != null ) {
432
432
for (NameMatcher m : _subTypeNameMatchers ) {
433
- if (m .match (subClassName )) {
433
+ if (m .match (ctxt , subClassName )) {
434
434
return Validity .ALLOWED ;
435
435
}
436
436
}
@@ -447,7 +447,7 @@ public Validity validateSubType(MapperConfig<?> ctxt, JavaType baseType, JavaTyp
447
447
if (_subClassMatchers != null ) {
448
448
final Class <?> subClass = subType .getRawClass ();
449
449
for (TypeMatcher m : _subClassMatchers ) {
450
- if (m .match (subClass )) {
450
+ if (m .match (ctxt , subClass )) {
451
451
return Validity .ALLOWED ;
452
452
}
453
453
}
0 commit comments