Announcement Announcement Module
Collapse
No announcement yet.
Unable to get a generic ResponseEntity<T> where T is "SomeClass<SomeGenericType>" Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unable to get a generic ResponseEntity<T> where T is "SomeClass<SomeGenericType>"

    Hi

    Please help me to get a ResponseEntity<T> where T is "SomeClass<SomeGenericType>".
    As I see it of now, this is not supported nowdays.

    Here is my code, that I want to use:
    Code:
    ResponseEntity<CisResponse<CisResponseEntity>> res = this.restTemplate.postForEntity(this.rootURL, myRequestObj, CisResponse.class);
    I'm getting this error:
    Code:
    <<< Type mismatch: cannot convert from ResponseEntity<CisResponse> to ResponseEntity<CisResponse<CisResponseEntity>>
    It's obvious error, but how I can workaround it today?

    Than I do want to get my generic response type:
    Code:
    CisResponse<CisResponseEntity> myResponse= res.getBody();
    CisResponseEntity entity = myResponse.getEntityFromResponse();
    For now, I use this solution, with postForObject and not postForentity:

    Code:
    CisResponse<CisResponseEntity> response = this.restTemplate.postForObject(this.rootURL,myRequestObj, CisResponse.class);
    Thanks,
    Igor
Working...
X