Skip to content

Commit d7b3db1

Browse files
author
John Keyes
committed
- minor code tidy
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/cli/trunk@279205 13f79535-47bb-0310-9956-ffa450edef68
1 parent 6b7691b commit d7b3db1

3 files changed

Lines changed: 12 additions & 25 deletions

File tree

src/java/org/apache/commons/cli2/option/Command.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,9 @@ public Command(
8686
this.preferredName = preferredName;
8787

8888
// gracefully and defensively handle aliases
89-
if (aliases == null) {
90-
this.aliases = Collections.EMPTY_SET;
91-
}
92-
else {
93-
this.aliases = Collections.unmodifiableSet(new HashSet(aliases));
94-
}
89+
this.aliases = (aliases == null)
90+
? Collections.EMPTY_SET
91+
: Collections.unmodifiableSet(new HashSet(aliases));
9592

9693
// populate the triggers Set
9794
final Set newTriggers = new HashSet();

src/java/org/apache/commons/cli2/option/DefaultOption.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,13 @@ public DefaultOption(
9898
this.burstLength = shortPrefix.length() + 1;
9999

100100
this.preferredName = preferredName;
101-
if (aliases == null) {
102-
this.aliases = Collections.EMPTY_SET;
103-
}
104-
else {
105-
this.aliases = Collections.unmodifiableSet(new HashSet(aliases));
106-
}
101+
this.aliases = (aliases == null)
102+
? Collections.EMPTY_SET
103+
: Collections.unmodifiableSet(new HashSet(aliases));
107104

108-
if (burstAliases == null) {
109-
this.burstAliases = Collections.EMPTY_SET;
110-
}
111-
else {
112-
this.burstAliases =
113-
Collections.unmodifiableSet(new HashSet(burstAliases));
114-
}
105+
this.burstAliases = (burstAliases == null)
106+
? Collections.EMPTY_SET
107+
: Collections.unmodifiableSet(new HashSet(burstAliases));
115108

116109
final Set newTriggers = new HashSet();
117110
newTriggers.add(preferredName);

src/java/org/apache/commons/cli2/option/ParentImpl.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,9 @@ public boolean canProcess(final WriteableCommandLine commandLine, final String a
114114
* @see org.apache.commons.cli2.Option#prefixes()
115115
*/
116116
public Set getPrefixes() {
117-
if (children == null) {
118-
return Collections.EMPTY_SET;
119-
}
120-
else {
121-
return children.getPrefixes();
122-
}
117+
return (children == null)
118+
? Collections.EMPTY_SET
119+
: children.getPrefixes();
123120
}
124121

125122
/*

0 commit comments

Comments
 (0)