Java - Converting from string to generic type -


in c# this

public static tconvertible changetype<tconvertible>(object value) tconvertible : iconvertible     {         try         {             if (value == null)                 return default(tconvertible);              return (tconvertible)convert.changetype(value, typeof(tconvertible));         }         catch (system.formatexception)         {             return default(tconvertible);         }     } 

is there way similar in java? using android sharedpreferences , trying wrap management class around it. rather using getstring, getint, getlong, etc, i'd pass in value, store string, , convert on it's way out.

i believe isn't possible due java's implementation of generics , whole type erasure issue wouldn't know tconvertible @ runtime.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -