I have this code:
public <V> V getPropertiesByObject(V sample) throws TimeoutException {
//settings fields using reflaction
return sample;
}
which I call like this:
MyClass a = getPropertiesByObject(new MyClass());
only because I don't know how to construct an instance otherwise.
I would prefer:
public <V> V getPropertiesByObject(Class<V> sample) throws TimeoutException {
//how to create a new V instance?
return result;
}
Is there a way to refactor my original code?