I want to pass Class as parameter and return the same class as parameter. Parameter can be any of the class. so I want comman method in which I need to pass only object of particular class and it will give me same object as return. I know with Java - Generics or with java collection it is possible but I don't know how?
Code:
public Class_object_as_paramter(parent) webCall(Class Obj as parameter(parent))
throws JsonSyntaxException, IOException, XmlPullParserException {
GsonBuilder gsonBuilder = new GsonBuilder();
Gson gson = gsonBuilder.create();
parent = (Collection<?>) gson.fromJson(SoaplCalls
.GetUserwiseSalesContracts(GsonExample.this, "55000024"),
ParentSalesContract.class (also has to pass same class here);
return parent;
}
Create generic method like this:
<T> T method(T t) {
...
T tt = ...
return tt;
}
public <T> T webCall(T type)
{
return type;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With