Skip to content

Commit

Permalink
Simplified CommandUserObject constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
rgoldberg authored and remkop committed Feb 9, 2022
1 parent d5ff8a5 commit 466d864
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main/java/picocli/CommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -11879,13 +11879,14 @@ static class CommandUserObject implements IScope {

private CommandUserObject(Object objectOrClass, IFactory factory) {
this.factory = Assert.notNull(factory, "factory");
type = objectOrClass == null ? null : objectOrClass.getClass();
instance = objectOrClass;
if (objectOrClass instanceof Class) {
type = (Class<?>) objectOrClass;
instance = null;
} else if (objectOrClass instanceof Method) {
type = null; // don't mix in options/positional params from outer class @Command
type = (Class<?>) objectOrClass;
} else {
instance = objectOrClass;
type = objectOrClass == null || objectOrClass instanceof Method // don't mix in options/positional params from outer class @Command
? null
: objectOrClass.getClass();
}
}
@Override public String toString() {
Expand Down

0 comments on commit 466d864

Please sign in to comment.