Skip to content

Commit 27b961f

Browse files
Use EMPTY_STRING_ARRAY constant. (apache#102)
1 parent 1af9b95 commit 27b961f

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Licensed to the Apache Software Foundation (ASF) under one or more
2525
import java.util.List;
2626
import java.util.Properties;
2727

28+
import static org.apache.commons.cli.Util.EMPTY_STRING_ARRAY;
29+
2830
/**
2931
* Represents list of arguments parsed against a {@link Options} descriptor.
3032
* <p>
@@ -328,7 +330,7 @@ public String[] getOptionValues(final Option option) {
328330
}
329331
}
330332

331-
return values.isEmpty() ? null : values.toArray(new String[values.size()]);
333+
return values.isEmpty() ? null : values.toArray(EMPTY_STRING_ARRAY);
332334
}
333335

334336
/**

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Licensed to the Apache Software Foundation (ASF) under one or more
2222
import java.util.List;
2323
import java.util.Objects;
2424

25+
import static org.apache.commons.cli.Util.EMPTY_STRING_ARRAY;
26+
2527
/**
2628
* Describes a single command-line option. It maintains information regarding the short-name of the option, the
2729
* long-name, if any exists, a flag indicating if an argument is required for this option, and a self-documenting
@@ -617,7 +619,7 @@ public String getValue(final String defaultValue) {
617619
* @return the values of this Option as a String array or null if there are no values
618620
*/
619621
public String[] getValues() {
620-
return hasNoValues() ? null : values.toArray(new String[values.size()]);
622+
return hasNoValues() ? null : values.toArray(EMPTY_STRING_ARRAY);
621623
}
622624

623625
/**

0 commit comments

Comments
 (0)