class MetadataJsonResponseUtils {

    public static ArrayNode populateJSONObjectResponse(Result result, RequestParserMultiple selectRequest)
        throws InvalidParseOperationException {
        ArrayNode jsonListResponse = JsonHandler.createArrayNode();
        // TODO P1 : review if statement because if result.getFinal().get("Result") == null and selectRequest
        // is instanceof SelectParserMultiple, we have an IllegalArgumentException during call to
        // getMetadataJsonObject(). This should not be the case
        // the nbResult problem originates from DbRequest.execRequest:Result result = roots;
        if (result != null && result.getNbResult() > 0 && selectRequest instanceof SelectParserMultiple &&
            result.hasFinalResult()) {
            LOGGER.debug("Result document: " + result.getFinal().toString());
            jsonListResponse = (ArrayNode) getMetadataJsonObject(result.getListFiltered());
        }
        LOGGER.debug("MetaDataImpl / selectUnitsByQuery /Results: " + jsonListResponse.toString());
        return jsonListResponse;
    }

    private  MetadataJsonResponseUtils();

}