class StatusInfo implements Jsonifiable<JsonObject> {

    @Override
    public JsonObject toJson() {
        final JsonObjectBuilder jsonObjectBuilder = JsonFactory.newObjectBuilder();

        if (label != null) {
            jsonObjectBuilder.set(JSON_KEY_LABEL, label);
        }

        jsonObjectBuilder.set(JSON_KEY_STATUS, status.toString());

        final JsonArray detailsArray = getDetailsAsArray();
        if (!detailsArray.isEmpty()) {
            jsonObjectBuilder.set(JSON_KEY_DETAILS, detailsArray);
        }

        final JsonArray childrenArray = getChildrenAsArray();
        if (!childrenArray.isEmpty()) {
            jsonObjectBuilder.set(JSON_KEY_CHILDREN, childrenArray);
        }

        return jsonObjectBuilder.build();
    }

    private  StatusInfo(final Status status, final Collection<StatusDetailMessage> details,
            final Collection<StatusInfo> children, @Nullable final String label);

}