I would like to get the class of Foo< T >.class (exactly Foo < T>, neither T.class nor Foo.class)
public class A extends B<C<D>>{
public A() {
super(C<D>.class); // not work
}
}
On StackOverflow has a instruction for obtaining generic class by injecting into constructor but it's not my case because C< D>.class (e.g List< String>.class) is syntax error. At here it seems relate to syntax more than code structure.
To show more detail, higher level view, the original code is the following, its HATEOAS module in Spring framework:
public class CustomerGroupResourceAssembler extends ResourceAssemblerSupport<CustomerGroup, CustomerGroupResource>{
public CustomerGroupResourceAssembler() {
super(CustomerGroupController.class, CustomerGroupResource.class);
}
}
public class CustomerGroupResource extends ResourceSupport {
private CustomerGroup data;
}
But now I want to parameterize the CustomerGroupResource to
public class Resource<T> extends ResourceSupport {
private T data;
}
and then
public class CustomerGroupResourceAssembler extends ResourceAssemblerSupport<CustomerGroup, Resource<CustomerGroup>>{
public CustomerGroupResourceAssembler() {
super(CustomerGroupController.class, Resource<CustomerGroup>.class); // not work here, even Resource.class
}
}