use of com.robo4j.socket.http.dto.ResponseAttributeListDTO in project robo4j by Robo4J.
the class JsonUtil method toJsonArrayServer.
public static <T> String toJsonArrayServer(List<T> list) {
return JsonElementStringBuilder.Builder().add(Utf8Constant.UTF8_SQUARE_BRACKET_LEFT).add(list.stream().map(e -> {
if (e instanceof ResponseAttributeDTO) {
ResponseAttributeDTO ra = (ResponseAttributeDTO) e;
switch(ra.getType()) {
case "java.util.ArrayList":
List<HttpPathMethodDTO> tmpList = JsonUtil.readPathConfig(HttpPathMethodDTO.class, ra.getValue());
ResponseAttributeListDTO tmpAttr = new ResponseAttributeListDTO();
tmpAttr.setId(ra.getId());
tmpAttr.setType(ra.getType());
tmpAttr.setValue(tmpList);
return ReflectUtils.createJson(tmpAttr);
default:
return ReflectUtils.createJson(e);
}
} else {
return ReflectUtils.createJson(e);
}
}).collect(Collectors.joining(Utf8Constant.UTF8_COMMA))).add(Utf8Constant.UTF8_SQUARE_BRACKET_RIGHT).build();
}
use of com.robo4j.socket.http.dto.ResponseAttributeListDTO in project robo4j by Robo4J.
the class ReflectUtilTests method serverAttributesResponse.
@Test
void serverAttributesResponse() {
ResponseAttributeListDTO tmpAttr = new ResponseAttributeListDTO();
tmpAttr.setType("Type");
tmpAttr.setId("ID");
// String roboUnit, HttpMethod method, List<String> callbacks
tmpAttr.addValue(new HttpPathMethodDTO("testUnit", HttpMethod.GET, Collections.singletonList("test")));
String result = ReflectUtils.createJson(tmpAttr);
System.out.println("result:" + result);
}
Aggregations