Ejemplo n.º 1
0
 public String toJson() {
   List<String> attributes = new ArrayList<>();
   attributes.add(String.format("\"status\":\"%s\"", status.name()));
   if (message != null && message.length() > 0) {
     attributes.add(String.format("\"message\":\"%s\"", message));
   }
   if (percentageComplete != -1) {
     attributes.add(String.format("\"percent_complete\":%d", percentageComplete));
   }
   getOutput().ifPresent(out -> attributes.add("\"output\":" + out.toJson()));
   return "{" + String.join(",", attributes) + "}";
 }