Skip to content

Commit f87f0b3

Browse files
committed
Rename some internals.
1 parent f2aa308 commit f87f0b3

3 files changed

Lines changed: 74 additions & 72 deletions

File tree

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

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,10 @@ public Builder valueSeparator(final char sep) {
250250
}
251251
}
252252

253-
/** constant that specifies the number of argument values has not been specified */
253+
/** Specifies the number of argument values has not been specified */
254254
public static final int UNINITIALIZED = -1;
255255

256-
/** constant that specifies the number of argument values is infinite */
256+
/** Specifies the number of argument values is infinite */
257257
public static final int UNLIMITED_VALUES = -2;
258258

259259
/** The serial version UID. */
@@ -281,34 +281,34 @@ public static Builder builder(final String opt) {
281281
return new Builder(opt);
282282
}
283283

284-
/** The name of the option */
285-
private final String opt;
284+
/** The name of the option. */
285+
private final String option;
286286

287-
/** The long representation of the option */
288-
private String longOpt;
287+
/** The long representation of the option. */
288+
private String longOption;
289289

290-
/** The name of the argument for this option */
290+
/** The name of the argument for this option. */
291291
private String argName;
292292

293-
/** description of the option */
293+
/** Description of the option. */
294294
private String description;
295295

296-
/** specifies whether this option is required to be present */
296+
/** Specifies whether this option is required to be present. */
297297
private boolean required;
298298

299-
/** specifies whether the argument value of this Option is optional */
299+
/** Specifies whether the argument value of this Option is optional. */
300300
private boolean optionalArg;
301301

302-
/** The number of argument values this option can have */
303-
private int numberOfArgs = UNINITIALIZED;
302+
/** The number of argument values this option can have. */
303+
private int argCount = UNINITIALIZED;
304304

305-
/** The type of this Option */
305+
/** The type of this Option. */
306306
private Class<?> type = String.class;
307307

308-
/** The list of argument values **/
308+
/** The list of argument values. **/
309309
private List<String> values = new ArrayList<>();
310310

311-
/** The character that is the value separator */
311+
/** The character that is the value separator. */
312312
private char valuesep;
313313

314314
/**
@@ -319,9 +319,9 @@ public static Builder builder(final String opt) {
319319
private Option(final Builder builder) {
320320
this.argName = builder.argName;
321321
this.description = builder.description;
322-
this.longOpt = builder.longOption;
323-
this.numberOfArgs = builder.argCount;
324-
this.opt = builder.option;
322+
this.longOption = builder.longOption;
323+
this.argCount = builder.argCount;
324+
this.option = builder.option;
325325
this.optionalArg = builder.optionalArg;
326326
this.required = builder.required;
327327
this.type = builder.type;
@@ -365,12 +365,12 @@ public Option(final String option, final String description) throws IllegalArgum
365365
*/
366366
public Option(final String option, final String longOption, final boolean hasArg, final String description) throws IllegalArgumentException {
367367
// ensure that the option is valid
368-
this.opt = OptionValidator.validate(option);
369-
this.longOpt = longOption;
368+
this.option = OptionValidator.validate(option);
369+
this.longOption = longOption;
370370

371371
// if hasArg is set then the number of arguments is 1
372372
if (hasArg) {
373-
this.numberOfArgs = 1;
373+
this.argCount = 1;
374374
}
375375

376376
this.description = description;
@@ -383,7 +383,7 @@ public Option(final String option, final String longOption, final boolean hasArg
383383
* @since 1.3
384384
*/
385385
boolean acceptsArg() {
386-
return (hasArg() || hasArgs() || hasOptionalArg()) && (numberOfArgs <= 0 || values.size() < numberOfArgs);
386+
return (hasArg() || hasArgs() || hasOptionalArg()) && (argCount <= 0 || values.size() < argCount);
387387
}
388388

389389
/**
@@ -424,7 +424,7 @@ public boolean addValue(final String value) {
424424
* @param value is a/the value of this Option
425425
*/
426426
void addValueForProcessing(final String value) {
427-
if (numberOfArgs == UNINITIALIZED) {
427+
if (argCount == UNINITIALIZED) {
428428
throw new RuntimeException("NO_ARGS_ALLOWED");
429429
}
430430
processValue(value);
@@ -471,7 +471,8 @@ public boolean equals(final Object o) {
471471

472472
final Option option = (Option) o;
473473

474-
if ((opt != null ? !opt.equals(option.opt) : option.opt != null) || (longOpt != null ? !longOpt.equals(option.longOpt) : option.longOpt != null)) {
474+
if ((this.option != null ? !this.option.equals(option.option) : option.option != null)
475+
|| (longOption != null ? !longOption.equals(option.longOption) : option.longOption != null)) {
475476
return false;
476477
}
477478

@@ -501,7 +502,7 @@ public String getArgName() {
501502
* @see #UNLIMITED_VALUES
502503
*/
503504
public int getArgs() {
504-
return numberOfArgs;
505+
return argCount;
505506
}
506507

507508
/**
@@ -530,7 +531,7 @@ public int getId() {
530531
*/
531532
String getKey() {
532533
// if 'opt' is null, then it is a 'long' option
533-
return opt == null ? longOpt : opt;
534+
return option == null ? longOption : option;
534535
}
535536

536537
/**
@@ -539,7 +540,7 @@ String getKey() {
539540
* @return Long name of this option, or null, if there is no long name
540541
*/
541542
public String getLongOpt() {
542-
return longOpt;
543+
return longOption;
543544
}
544545

545546
/**
@@ -551,7 +552,7 @@ public String getLongOpt() {
551552
* @return The name of this option
552553
*/
553554
public String getOpt() {
554-
return opt;
555+
return option;
555556
}
556557

557558
/**
@@ -631,7 +632,7 @@ public List<String> getValuesList() {
631632
* @return boolean flag indicating if an argument is required
632633
*/
633634
public boolean hasArg() {
634-
return numberOfArgs > 0 || numberOfArgs == UNLIMITED_VALUES;
635+
return argCount > 0 || argCount == UNLIMITED_VALUES;
635636
}
636637

637638
/**
@@ -649,14 +650,14 @@ public boolean hasArgName() {
649650
* @return boolean flag indicating if multiple values are allowed
650651
*/
651652
public boolean hasArgs() {
652-
return numberOfArgs > 1 || numberOfArgs == UNLIMITED_VALUES;
653+
return argCount > 1 || argCount == UNLIMITED_VALUES;
653654
}
654655

655656
@Override
656657
public int hashCode() {
657658
int result;
658-
result = opt != null ? opt.hashCode() : 0;
659-
result = 31 * result + (longOpt != null ? longOpt.hashCode() : 0);
659+
result = option != null ? option.hashCode() : 0;
660+
result = 31 * result + (longOption != null ? longOption.hashCode() : 0);
660661
return result;
661662
}
662663

@@ -666,7 +667,7 @@ public int hashCode() {
666667
* @return boolean flag indicating existence of a long name
667668
*/
668669
public boolean hasLongOpt() {
669-
return longOpt != null;
670+
return longOption != null;
670671
}
671672

672673
/**
@@ -725,7 +726,7 @@ private void processValue(String value) {
725726
// while there are more value separators
726727
while (index != -1) {
727728
// next value to be added
728-
if (values.size() == numberOfArgs - 1) {
729+
if (values.size() == argCount - 1) {
729730
break;
730731
}
731732

@@ -754,7 +755,7 @@ boolean requiresArg() {
754755
if (optionalArg) {
755756
return false;
756757
}
757-
if (numberOfArgs == UNLIMITED_VALUES) {
758+
if (argCount == UNLIMITED_VALUES) {
758759
return values.isEmpty();
759760
}
760761
return acceptsArg();
@@ -775,7 +776,7 @@ public void setArgName(final String argName) {
775776
* @param num the number of argument values
776777
*/
777778
public void setArgs(final int num) {
778-
this.numberOfArgs = num;
779+
this.argCount = num;
779780
}
780781

781782
/**
@@ -794,7 +795,7 @@ public void setDescription(final String description) {
794795
* @param longOpt the long name of this Option
795796
*/
796797
public void setLongOpt(final String longOpt) {
797-
this.longOpt = longOpt;
798+
this.longOption = longOpt;
798799
}
799800

800801
/**
@@ -857,10 +858,10 @@ public void setValueSeparator(final char sep) {
857858
public String toString() {
858859
final StringBuilder buf = new StringBuilder().append("[ option: ");
859860

860-
buf.append(opt);
861+
buf.append(option);
861862

862-
if (longOpt != null) {
863-
buf.append(" ").append(longOpt);
863+
if (longOption != null) {
864+
buf.append(" ").append(longOption);
864865
}
865866

866867
buf.append(" ");

0 commit comments

Comments
 (0)