Wednesday, 18 September 2013

Change This Method to Generic (Without Collection)

Change This Method to Generic (Without Collection)

I have the following method, which clones an object using gson to do a
deep copy. Is there a way to make this method generic, or do generics only
pertain to objects that belong to a Collection?
private Order gsonClone(Order t) {
Gson gson = new Gson();
String json = gson.toJson(t);
return gson.fromJson(json, t.getClass());
}

No comments:

Post a Comment