[Minor] Added ResponseUtil.toResponse(JsonObject)

This commit is contained in:
Robert von Burg 2021-05-17 17:41:01 +02:00
parent 476d652294
commit b99ef252a9
1 changed files with 6 additions and 0 deletions

View File

@ -90,6 +90,12 @@ public class ResponseUtil {
return Response.ok(json, MediaType.APPLICATION_JSON).build();
}
public static Response toResponse(JsonObject response) {
response.addProperty(MSG, StringHelper.DASH);
String json = new Gson().toJson(response);
return Response.ok(json, MediaType.APPLICATION_JSON).build();
}
public static <T> Response toResponse(String member, List<T> list, Function<T, JsonObject> toJson) {
return toResponse(member, list.stream().map(toJson).collect(Collectors.toList()));
}