I am working on a legacy application which uses Java 7. I have a generic Request class (annotations are from lombok):
@AllArgsConstructor
@Getter
public class Request<T> {
int Id;
T requestContext;
}
Here is one of the requestContext type:
@AllArgsConstructor
@Getter
public class StudentRequestContext {
int ID;
String name;
}
I have a ResponseGenerator interface:
public interface ResponseGenerator {
<T> Response getResponse(Request<T> request);
}
Here is the implementer class of this interface:
public class StudentResponseGenerator implements ResponseGenerator {
@Override
public <StudentRequestContext> Response getResponse(
Request<StudentRequestContext> studentRequest) {
StudentRequestContext studentRequestContext =
(StudentRequestContext) studentRequest.getRequestContext();
studentRequestContext.get //NO getName METHOD IS AVAILABLE
}
}
As shown in the code comment above no getter is available for generic type studentRequestContext object in StudentResponseGenerator class. What am I missing?