public static <T> void maybeMergeOptions(Properties props, String key, OptionSet options, OptionSpec<T> spec) {
        if (options.has(spec) || !props.containsKey(key)) {
            T value = options.valueOf(spec);
            if (value == null) {
                props.remove(key);
            } else {
                props.put(key, value.toString());
            }
        }
    }
@Test
    public void testMaybeMergeOptionsNotOverwriteExisting() {
        setUpOptions();

        props.put("skey", "existing-string");
        props.put("ikey", "300");
        props.put("sokey", "existing-string-2");
        props.put("iokey", "400");
        props.put("sondkey", "existing-string-3");
        props.put("iondkey", "500");

        OptionSet options = parser.parse();

        CommandLineUtils.maybeMergeOptions(props, "skey", options, stringOpt);
        CommandLineUtils.maybeMergeOptions(props, "ikey", options, intOpt);
        CommandLineUtils.maybeMergeOptions(props, "sokey", options, stringOptOptionalArg);
        CommandLineUtils.maybeMergeOptions(props, "iokey", options, intOptOptionalArg);
        CommandLineUtils.maybeMergeOptions(props, "sondkey", options, stringOptOptionalArgNoDefault);
        CommandLineUtils.maybeMergeOptions(props, "iondkey", options, intOptOptionalArgNoDefault);

        assertEquals("existing-string", props.get("skey"));
        assertEquals("300", props.get("ikey"));
        assertEquals("existing-string-2", props.get("sokey"));
        assertEquals("400", props.get("iokey"));
        assertEquals("existing-string-3", props.get("sondkey"));
        assertEquals("500", props.get("iondkey"));
    }