code: public static <T extends CreateOptions> CreateOptions[] setOpt(T newValue, CreateOptions ... opts) {
      boolean alreadyInOpts = false;
      if (opts != null) {
        for (int i = 0; i < opts.length; ++i) {
          if (opts[i].getClass() == newValue.getClass()) {
            if (alreadyInOpts)
              throw new IllegalArgumentException("Multiple args with type " + newValue.getClass());
            alreadyInOpts = true;
            opts[i] = newValue;
          }
        }
      }
      CreateOptions[] resultOpt = opts;
      if (!alreadyInOpts) { // no newValue in opt
        CreateOptions[] newOpts = new CreateOptions[opts.length + 1];
        System.arraycopy(opts, 0, newOpts, 0, opts.length);
        newOpts[opts.length] = newValue;
        resultOpt = newOpts;
      }
      return resultOpt;
    }
docs: set an option
  
  @param newValue
  the option to be set
  @param opts
  - the option is set into this array of opts
  @return updated CreateOpts[] == opts + newValue
  @throws IllegalArgumentException If two options with the same type as newValue exists change will apply to one of them, and an Exception will be thrown.