8000 Add supports of generics on RestTemplate · Issue #220 · androidannotations/androidannotations · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Add supports of generics on RestTemplate #220

@DayS

Description

@DayS

With a rest method like this :

@Post("/user/infos")
ResponseEntity<String> sendUserInfos(Map<String, Object> infos);

AA will generate this method :

@Override
public ResponseEntity<String> sendUserInfos(Object>infos) {
    HttpHeaders httpHeaders = new HttpHeaders();
    HttpEntity<Object>> requestEntity = new HttpEntity<Object>>(infos, httpHeaders);
    return restTemplate.exchange("http://localhost:8081/epod/rest-services/user/infos", HttpMethod.POST, requestEntity, String.class);
}

But if we change the rest method for this one (without generics) :

@Post("/user/infos")
ResponseEntity<String> sendUserInfos(Map infos);

The generated class will be fine :

@Override
public ResponseEntity<String> sendUserInfos(Map infos) {
    HttpHeaders httpHeaders = new HttpHeaders();
    HttpEntity<Map> requestEntity = new HttpEntity<Map>(infos, httpHeaders);
    return restTemplate.exchange("http://localhost:8081/epod/rest-services/user/infos", HttpMethod.POST, requestEntity, String.class);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0