Options are not cloneable

When working with my code, I can have clients pass in their own *Options (GetOptions, for example). I, however, want to force the transcoder to be something else - I do not want to modify the *Options from the caller, so would like to clone the provided *Options and only override the transcoder.

No way to do this…

There’s an issue open to add a copy/clone constructor - [JCBC-1885] Add QueryOptions copy constructor - Couchbase database

Without such a method, it’s very difficult. The queryOptions.build() will give you a built object where you can retrieve some of the properties. Then you can injectParams() into a JsonObject, and retrieve them from that (see injectParams() for how they were put there.

   QueryOptions.Built from = queryOptions.build()
    JsonObject queryJson = JsonObject.create();
    if (queryJson.get("consistentWith") != null) {
      clone.consistentWith( (MutationState)(queryJson.get("consistentWith")));