I use this code to return a list from REST endpoint:
private String getCurrencies(Integer id) {
List<CurrencyDTO> list = null;
try {
list = StreamSupport.stream(currenciesService.getCurrencyByContractID(Integer.valueOf(id)).spliterator(), false)
.map(currencies_mapper::toDTO)
.collect(Collectors.toList());
} catch (Exception e) {
e.printStackTrace();
}
return list.toString();
}
DTO:
public class CurrencyDTO {
private Integer id;
private Integer contract_id;
private String code;
...
}
How I can get a list of values from code values? Something like that:
String list = "code, code, code, code, code";