class Foo { public T bar(Class type, String str) { return Enum.valueOf(type, str); } }