How please works following generic casting?
private <T, N> N send(final T request) {
final String serviceUrl = "someUri"
try {
return (N) webServiceTemplate.marshalSendAndReceive(serviceUrl, request);
} catch (final SoapFaultClientException e) {
}
}
When I call this private method like this:
MyReq request = new MyReq();
MyResp response = send(req);
How this method casting this object into MyResp object? What mean this in return type:
< T, N>
<T, N>means, that the method has two type parameters, namedTandN.N.private ... N.N.<T, N>is a kind of initialization of the generic variables. This is the syntax of generic variables initialization.