java generics T extends Simpletype?
I'd like to write a method, that does return something of a PrimitiveType
like float, integer, boolean and also String if possible. I'd like to use
generics for it but i stuck and dont find a solution for it. I do need it
for a Configparser. Ill use it to get different values from the Config.
Current it des look like this and i know that the switch does not work
like this but you get an idea of what id like to do:
public <T> T getConfig(Class<T> type, String name) {
switch (type) {
case float:
return xml.getFloat(name);
break;
case int:
return xml.getInt(name);
break;
default:
break;
}
return null;
}
Thanks alot
No comments:
Post a Comment