You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*I want to register a TypeParser that operates on all subclasses of the provided class.
More concretely I want to do this:
builder.registerTypeParser(Number.class, new TypeParser() {...})
return parser.parseType(string, invocation.getMethod().getGenericReturnType()); //returntype is Integer
My problem that there exist a lot of subtypes of my superclass and I don't want to register the same TypeParser for all(I might not know all of them) of them .
I also though and tried this:
builder.registerTypeParser(new GenericType<? extends Number>() {},new TypeParserImplementation());
which unfortunately isn't allowed.
If a TypeParser for a specific type is not found could it look for a TypeParser where TypeParserForClass.isAssignableFrom(SpecificClassWithoutTypeParser.class)
*If such subclass typeParsing as above is added the expected type would be nice to access from within a TypeParser.
new TypeParser() {
public ConfigurationData parse(String input,Class expectedType, TypeParserHelper helper) {
if(expectedType instanceof Integer){}
if(expectedType instanceof Float){}
}
The text was updated successfully, but these errors were encountered:
Great suggestion! Internally there is such feature, for List, Map, Set etc. But it is hardcoded :/
I'll try to figure out a way to make it generic and public. Any suggestions/ideas would be great :)
Regarding the "expectedType", It should be possible to add a method: TypeParserHelper.getTargetType() : Type
(TypeParserHelper is there to provide new functionality in a backward compatible way)
*I want to register a TypeParser that operates on all subclasses of the provided class.
More concretely I want to do this:
builder.registerTypeParser(Number.class, new TypeParser() {...})
return parser.parseType(string, invocation.getMethod().getGenericReturnType()); //returntype is Integer
My problem that there exist a lot of subtypes of my superclass and I don't want to register the same TypeParser for all(I might not know all of them) of them .
I also though and tried this:
builder.registerTypeParser(new GenericType<? extends Number>() {},new TypeParserImplementation());
which unfortunately isn't allowed.
If a TypeParser for a specific type is not found could it look for a TypeParser where TypeParserForClass.isAssignableFrom(SpecificClassWithoutTypeParser.class)
*If such subclass typeParsing as above is added the expected type would be nice to access from within a TypeParser.
new TypeParser() {
public ConfigurationData parse(String input,Class expectedType, TypeParserHelper helper) {
if(expectedType instanceof Integer){}
if(expectedType instanceof Float){}
}
The text was updated successfully, but these errors were encountered: