code: public static void populateParameters(JsonObject query, JsonValue params) {
          if (params instanceof JsonArray && !((JsonArray) params).isEmpty()) {
              query.put("args", (JsonArray) params);
          } else if (params instanceof JsonObject && !((JsonObject) params).isEmpty()) {
              JsonObject namedParams = (JsonObject) params;
              for (String key : namedParams.getNames()) {
                  Object value = namedParams.get(key);
                  if (key.charAt(0) != '$') {
                      query.put('$' + key, value);
                  } else {
                      query.put(key, value);
                  }
              }
          } //else do nothing, as if a simple statement
      }
docs: Populate a {@link JsonObject} representation of a query with parameters, either positional or named.
  
  - If params is a {@link JsonObject}, named parameters will be used (prefixing the names with '$' if not present).
  - If params is a {@link JsonArray}, positional parameters will be used.
  - If params is null or an empty json, no parameters are populated in the query object.
  
  Note that the {@link JsonValue} should not be mutated until {@link #n1ql()} is called since it backs the
  creation of the query string.
  
  Also, the {@link Statement} is expected to contain the correct placeholders (corresponding names and number).
  
  @param query the query JsonObject to populated with parameters.
  @param params the parameters.