Skip to content

Commit 6a64704

Browse files
committed
Sort members
1 parent 00fb0a1 commit 6a64704

8 files changed

Lines changed: 247 additions & 247 deletions

File tree

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

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -400,46 +400,32 @@ public <T> T getParsedOptionValue(final char opt) throws ParseException {
400400
/**
401401
* Gets a version of this {@code Option} converted to a particular type.
402402
*
403-
* @param option the name of the option.
403+
* @param opt the name of the option.
404+
* @param defaultValue the default value to return if opt is not set.
404405
* @param <T> The return type for the method.
405406
* @return the value parsed into a particular object.
406407
* @throws ParseException if there are problems turning the option value into the desired type
407408
* @see PatternOptionBuilder
408-
* @since 1.5.0
409+
* @since 1.7.0
409410
*/
410-
public <T> T getParsedOptionValue(final Option option) throws ParseException {
411-
return getParsedOptionValue(option, null);
411+
public <T> T getParsedOptionValue(final char opt, final T defaultValue) throws ParseException {
412+
return getParsedOptionValue(String.valueOf(opt), defaultValue);
412413
}
413414

414415
/**
415416
* Gets a version of this {@code Option} converted to a particular type.
416417
*
417-
* @param opt the name of the option.
418+
* @param option the name of the option.
418419
* @param <T> The return type for the method.
419420
* @return the value parsed into a particular object.
420421
* @throws ParseException if there are problems turning the option value into the desired type
421422
* @see PatternOptionBuilder
422-
* @since 1.2
423+
* @since 1.5.0
423424
*/
424-
public <T> T getParsedOptionValue(final String opt) throws ParseException {
425-
return getParsedOptionValue(resolveOption(opt));
425+
public <T> T getParsedOptionValue(final Option option) throws ParseException {
426+
return getParsedOptionValue(option, null);
426427
}
427428

428-
/**
429-
* Gets a version of this {@code Option} converted to a particular type.
430-
*
431-
* @param opt the name of the option.
432-
* @param defaultValue the default value to return if opt is not set.
433-
* @param <T> The return type for the method.
434-
* @return the value parsed into a particular object.
435-
* @throws ParseException if there are problems turning the option value into the desired type
436-
* @see PatternOptionBuilder
437-
* @since 1.7.0
438-
*/
439-
public <T> T getParsedOptionValue(final char opt, final T defaultValue) throws ParseException {
440-
return getParsedOptionValue(String.valueOf(opt), defaultValue);
441-
}
442-
443429
/**
444430
* Gets a version of this {@code Option} converted to a particular type.
445431
*
@@ -465,6 +451,20 @@ public <T> T getParsedOptionValue(final Option option, final T defaultValue) thr
465451
}
466452
}
467453

454+
/**
455+
* Gets a version of this {@code Option} converted to a particular type.
456+
*
457+
* @param opt the name of the option.
458+
* @param <T> The return type for the method.
459+
* @return the value parsed into a particular object.
460+
* @throws ParseException if there are problems turning the option value into the desired type
461+
* @see PatternOptionBuilder
462+
* @since 1.2
463+
*/
464+
public <T> T getParsedOptionValue(final String opt) throws ParseException {
465+
return getParsedOptionValue(resolveOption(opt));
466+
}
467+
468468
/**
469469
* Gets a version of this {@code Option} converted to a particular type.
470470
*

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

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,18 @@ public Option build() {
120120
return new Option(this);
121121
}
122122

123+
/**
124+
* Sets the converter for the option.
125+
* <p>Note: see {@link TypeHandler} for serialization discussion.</p>
126+
* @param converter the Converter to use.
127+
* @return this builder, to allow method chaining.
128+
* @since 1.7.0
129+
*/
130+
public Builder converter(final Converter<?> converter) {
131+
this.converter = converter;
132+
return this;
133+
}
134+
123135
/**
124136
* Sets the description for this option.
125137
*
@@ -273,18 +285,6 @@ public Builder valueSeparator(final char valueSeparator) {
273285
this.valueSeparator = valueSeparator;
274286
return this;
275287
}
276-
277-
/**
278-
* Sets the converter for the option.
279-
* <p>Note: see {@link TypeHandler} for serialization discussion.</p>
280-
* @param converter the Converter to use.
281-
* @return this builder, to allow method chaining.
282-
* @since 1.7.0
283-
*/
284-
public Builder converter(final Converter<?> converter) {
285-
this.converter = converter;
286-
return this;
287-
}
288288

289289
}
290290

@@ -542,6 +542,15 @@ public int getArgs() {
542542
return argCount;
543543
}
544544

545+
/**
546+
* Gets the value to type converter.
547+
* @return the value to type converter
548+
* @since 1.7.0
549+
*/
550+
public Converter<?> getConverter() {
551+
return converter == null ? TypeHandler.getConverter(type) : converter;
552+
}
553+
545554
/**
546555
* Gets the self-documenting description of this Option
547556
*
@@ -816,6 +825,15 @@ public void setArgs(final int num) {
816825
this.argCount = num;
817826
}
818827

828+
/**
829+
* Sets the value to type converter.
830+
* @param converter The converter to convert the string value to the type.
831+
* @since 1.7.0
832+
*/
833+
public void setConverter(final Converter<?> converter) {
834+
this.converter = converter;
835+
}
836+
819837
/**
820838
* Sets the self-documenting description of this Option
821839
*
@@ -862,7 +880,7 @@ public void setRequired(final boolean required) {
862880
public void setType(final Class<?> type) {
863881
this.type = type;
864882
}
865-
883+
866884
/**
867885
* Sets the type of this Option.
868886
* <p>
@@ -886,24 +904,6 @@ public void setType(final Object type) {
886904
public void setValueSeparator(final char sep) {
887905
this.valuesep = sep;
888906
}
889-
890-
/**
891-
* Gets the value to type converter.
892-
* @return the value to type converter
893-
* @since 1.7.0
894-
*/
895-
public Converter<?> getConverter() {
896-
return converter == null ? TypeHandler.getConverter(type) : converter;
897-
}
898-
899-
/**
900-
* Sets the value to type converter.
901-
* @param converter The converter to convert the string value to the type.
902-
* @since 1.7.0
903-
*/
904-
public void setConverter(final Converter<?> converter) {
905-
this.converter = converter;
906-
}
907907

908908
/**
909909
* Dump state, suitable for debugging.

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ public static ParseException wrap(final Exception e) throws UnsupportedOperation
4949
}
5050
return new ParseException(e);
5151
}
52+
/**
53+
* Constructs a new {@code ParseException} wrapping the specified exception.
54+
* @param e the Exception to wrap.
55+
*/
56+
public ParseException(final Exception e) {
57+
super(e);
58+
}
59+
5260
/**
5361
* Constructs a new {@code ParseException} with the specified detail message.
5462
*
@@ -57,12 +65,4 @@ public static ParseException wrap(final Exception e) throws UnsupportedOperation
5765
public ParseException(final String message) {
5866
super(message);
5967
}
60-
61-
/**
62-
* Constructs a new {@code ParseException} wrapping the specified exception.
63-
* @param e the Exception to wrap.
64-
*/
65-
public ParseException(final Exception e) {
66-
super(e);
67-
}
6868
}

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,6 @@ public class PatternOptionBuilder {
112112
registerTypes();
113113
}
114114

115-
/**
116-
* Registers custom {@code Converter}s with the {@code TypeHandler}.
117-
* @since 1.7.0
118-
*/
119-
public static void registerTypes() {
120-
TypeHandler.register(PatternOptionBuilder.FILES_VALUE, NOT_IMPLEMENTED);
121-
}
122-
123115
/**
124116
* Retrieve the class that {@code ch} represents.
125117
*
@@ -131,7 +123,7 @@ public static void registerTypes() {
131123
public static Object getValueClass(final char ch) {
132124
return getValueType(ch);
133125
}
134-
126+
135127
/**
136128
* Retrieve the class that {@code ch} represents.
137129
*
@@ -163,7 +155,7 @@ public static Class<?> getValueType(final char ch) {
163155

164156
return null;
165157
}
166-
158+
167159
/**
168160
* Returns whether {@code ch} is a value code, i.e. whether it represents a class in a pattern.
169161
*
@@ -223,4 +215,12 @@ public static Options parsePattern(final String pattern) {
223215

224216
return options;
225217
}
218+
219+
/**
220+
* Registers custom {@code Converter}s with the {@code TypeHandler}.
221+
* @since 1.7.0
222+
*/
223+
public static void registerTypes() {
224+
TypeHandler.register(PatternOptionBuilder.FILES_VALUE, NOT_IMPLEMENTED);
225+
}
226226
}

0 commit comments

Comments
 (0)