Let's say I have a function which deals which returns and accepts generic type. The function may look like this
public T call(T t) { Log.v(FILE_NAME, "t: " + t.toString()); return null; } Let's say if the code detected that t.toString() looks like
{label1=5148.000, label2=8363.000, label3=715.000} Is there any way I can convert t to an object which we can easily manipulate it's content? By manipulating, I mean we can easily, for example change label1, label2 and label3 value to something else, and return the modified t.
Just in case, in the example above, the parameter t that passed was of type Map<String,String>.
Update:
- Yes, I'm implementing
Callable<T>. - In the future, I might supply other type of arguments, and not just
Map<String,String>.
Objectdoesn't has such fields. Either you know the type of objects you like to pass astto provide a bound forTor you can't change its field. (You could also do some nasty stuff with reflection, but ... don't think about it)Map, why are you using generics? If it's not always aMapthen your argument falls down.public void call(Map<String,String> t) {?