Skip to content

Commit cd3f2c4

Browse files
committed
Sort members
1 parent 42be792 commit cd3f2c4

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,6 @@ public Option build() {
136136
return get();
137137
}
138138

139-
/**
140-
* Constructs an Option with the values declared by this {@link Builder}.
141-
*
142-
* @return the new {@link Option}.
143-
* @throws IllegalArgumentException if neither {@code opt} or {@code longOpt} has been set.
144-
*/
145-
public Option get() {
146-
if (option == null && longOption == null) {
147-
throw new IllegalArgumentException("Either opt or longOpt must be specified");
148-
}
149-
return new Option(this);
150-
}
151-
152139
/**
153140
* Sets the converter for the option.
154141
* <p>
@@ -197,6 +184,19 @@ public Builder desc(final String description) {
197184
return this;
198185
}
199186

187+
/**
188+
* Constructs an Option with the values declared by this {@link Builder}.
189+
*
190+
* @return the new {@link Option}.
191+
* @throws IllegalArgumentException if neither {@code opt} or {@code longOpt} has been set.
192+
*/
193+
public Option get() {
194+
if (option == null && longOption == null) {
195+
throw new IllegalArgumentException("Either opt or longOpt must be specified");
196+
}
197+
return new Option(this);
198+
}
199+
200200
/**
201201
* Tests whether the Option will require an argument.
202202
*

src/test/java/org/apache/commons/cli/OptionsTest.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,6 @@ Licensed to the Apache Software Foundation (ASF) under one or more
3636
@SuppressWarnings("deprecation") // tests some deprecated classes
3737
class OptionsTest {
3838

39-
@Test
40-
void testRequiredOptionInGroupShouldNotBeInRequiredList() {
41-
final String key = "a";
42-
final Option option = new Option(key, "along", false, "Option A");
43-
option.setRequired(true);
44-
final Options options = new Options();
45-
options.addOption(option);
46-
assertTrue(options.getRequiredOptions().contains(key));
47-
final OptionGroup optionGroup = new OptionGroup();
48-
optionGroup.addOption(option);
49-
options.addOptionGroup(optionGroup);
50-
assertFalse(options.getOption(key).isRequired());
51-
assertFalse(options.getRequiredOptions().contains(key), "Option in group shouldn't be in required options list.");
52-
}
53-
5439
private void assertToStrings(final Option option) {
5540
// Should never throw.
5641
// Should return a String, not null.
@@ -280,6 +265,21 @@ void testMissingOptionsException() throws ParseException {
280265
assertEquals("Missing required options: f, x", e.getMessage());
281266
}
282267

268+
@Test
269+
void testRequiredOptionInGroupShouldNotBeInRequiredList() {
270+
final String key = "a";
271+
final Option option = new Option(key, "along", false, "Option A");
272+
option.setRequired(true);
273+
final Options options = new Options();
274+
options.addOption(option);
275+
assertTrue(options.getRequiredOptions().contains(key));
276+
final OptionGroup optionGroup = new OptionGroup();
277+
optionGroup.addOption(option);
278+
options.addOptionGroup(optionGroup);
279+
assertFalse(options.getOption(key).isRequired());
280+
assertFalse(options.getRequiredOptions().contains(key), "Option in group shouldn't be in required options list.");
281+
}
282+
283283
@Test
284284
void testSimple() {
285285
final Options options = new Options();

0 commit comments

Comments
 (0)