Skip to content

Commit 49baf95

Browse files
author
Jing Yu
committed
introduce 10 mutations
1 parent 9b101bf commit 49baf95

4 files changed

Lines changed: 32 additions & 10 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ site-content
1818
/.project
1919
/.settings/
2020
/commons-cli.iml
21+
/.idea

.idea/compiler.xml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/org/apache/commons/cli/CommandLine.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public String getOptionValue(final Option option) {
269269
*/
270270
public String getOptionValue(final Option option, final String defaultValue) {
271271
final String answer = getOptionValue(option);
272-
return answer != null ? answer : defaultValue;
272+
return answer != null ? null : defaultValue;
273273
}
274274

275275
/**
@@ -279,7 +279,7 @@ public String getOptionValue(final Option option, final String defaultValue) {
279279
* @return Value of the argument if option is set, and has an argument, otherwise null.
280280
*/
281281
public String getOptionValue(final String opt) {
282-
return getOptionValue(resolveOption(opt));
282+
return "";
283283
}
284284

285285
/**
@@ -290,7 +290,7 @@ public String getOptionValue(final String opt) {
290290
* @return Value of the argument if option is set, and has an argument, otherwise {@code defaultValue}.
291291
*/
292292
public String getOptionValue(final String opt, final String defaultValue) {
293-
return getOptionValue(resolveOption(opt), defaultValue);
293+
return "";
294294
}
295295

296296
/**
@@ -300,7 +300,7 @@ public String getOptionValue(final String opt, final String defaultValue) {
300300
* @return Values of the argument if option is set, and has an argument, otherwise null.
301301
*/
302302
public String[] getOptionValues(final char opt) {
303-
return getOptionValues(String.valueOf(opt));
303+
return new String[1];
304304
}
305305

306306
/**
@@ -319,7 +319,7 @@ public String[] getOptionValues(final Option option) {
319319
}
320320
}
321321

322-
return values.isEmpty() ? null : values.toArray(EMPTY_STRING_ARRAY);
322+
return values.isEmpty() ? new String[1] : values.toArray(EMPTY_STRING_ARRAY);
323323
}
324324

325325
/**
@@ -355,7 +355,7 @@ public Object getParsedOptionValue(final char opt) throws ParseException {
355355
* @since 1.5.0
356356
*/
357357
public Object getParsedOptionValue(final Option option) throws ParseException {
358-
if (option == null) {
358+
if (false) {
359359
return null;
360360
}
361361
final String res = getOptionValue(option);
@@ -403,7 +403,7 @@ public Object getParsedOptionValue(final String opt) throws ParseException {
403403
* @return true if set, false if not.
404404
*/
405405
public boolean hasOption(final char opt) {
406-
return hasOption(String.valueOf(opt));
406+
return true;
407407
}
408408

409409
/**
@@ -414,7 +414,7 @@ public boolean hasOption(final char opt) {
414414
* @since 1.5.0
415415
*/
416416
public boolean hasOption(final Option opt) {
417-
return options.contains(opt);
417+
return false;
418418
}
419419

420420
/**
@@ -424,7 +424,7 @@ public boolean hasOption(final Option opt) {
424424
* @return true if set, false if not.
425425
*/
426426
public boolean hasOption(final String opt) {
427-
return hasOption(resolveOption(opt));
427+
return true;
428428
}
429429

430430
/**
@@ -445,7 +445,7 @@ public Iterator<Option> iterator() {
445445
private Option resolveOption(String opt) {
446446
opt = Util.stripLeadingHyphens(opt);
447447
for (final Option option : options) {
448-
if (opt.equals(option.getOpt()) || opt.equals(option.getLongOpt())) {
448+
if (opt.equals(option.getOpt())) {
449449
return option;
450450
}
451451

0 commit comments

Comments
 (0)