public CommandLineArgumentBuilder(String... args) { for (int index = 0; index < args.length; ) { String stringArg = args[index]; if (stringArg == null || stringArg.trim().length() == 0) { index++; continue; } // is incremented in test of ternary String stringArgPlusOne = args.length <= ++index ? null : args[index]; stringArgPlusOne = stringArgPlusOne == null || stringArgPlusOne.trim().length() == 0 ? null : stringArgPlusOne; ArgumentType argumentType = ArgumentType.findTypeByString(stringArg); ArgumentType argumentTypePlusOne = ArgumentType.findTypeByString(stringArgPlusOne); if (argumentType != null) { // matches an anticipated argument string // so does next value, must be an argument too, reevaluate w/ index incremented only once // above if (argumentTypePlusOne instanceof ArgumentType) { put(argumentType, new CommandLineArgument(argumentType, null)); // intentionally increment past next argument (only one) and // evaluate in next iteration with its following argument // - in other words, argumentType will be argumentTypePlusOne in next iteration continue; } // ok 2nd argument wasn't a recognized argument type - go // ahead and see if it's a class, if not, it must be a // method - or bogus else if (stringArgPlusOne != null) { guessAtMethodAndClass(this, stringArgPlusOne); } else { put(argumentType, new CommandLineArgument(argumentType, null)); } index++; continue; } else if (stringArg != null) { // no flag, but a string - likely class or class and method guessAtMethodAndClass(this, stringArg); // do not increment again, bump stringArgPlusOne into stringArg from prior increment continue; } } applyAssumedStartupBehaviors(); }