TypedMember(Field field) { accessible = Assert.notNull(field, "field"); accessible.setAccessible(true); name = field.getName(); typeInfo = createTypeInfo(field.getType(), field.getGenericType()); hasInitialValue = true; } private TypedMember(Field field, Object scope) {
private RuntimeTypeInfo(Class<?> type, Class<?>[] auxiliaryTypes, List<String> actualGenericTypeArguments) { this.type = Assert.notNull(type, "type"); this.auxiliaryTypes = Assert.notNull(auxiliaryTypes, "auxiliaryTypes").clone(); this.actualGenericTypeArguments = actualGenericTypeArguments == null ? Collections.<String>emptyList() : Collections.unmodifiableList(new ArrayList<String>(actualGenericTypeArguments)); }
/** Constructs a new {@code Help} instance with the specified color scheme, initialized from annotatations * on the specified class and superclasses. * @param commandSpec the command model to create usage help for * @param colorScheme the color scheme to use */ public Help(CommandSpec commandSpec, ColorScheme colorScheme) { this.commandSpec = Assert.notNull(commandSpec, "commandSpec"); this.aliases = new ArrayList<String>(Arrays.asList(commandSpec.aliases())); this.aliases.add(0, commandSpec.name()); this.colorScheme = Assert.notNull(colorScheme, "colorScheme").applySystemProperties(); parameterLabelRenderer = createDefaultParamLabelRenderer(); // uses help separator this.addAllSubcommands(commandSpec.subcommands()); }
/** Constructs a new ParameterException with the specified CommandLine and error message. * @param commandLine the command or subcommand whose input was invalid * @param msg describes the problem * @param t the throwable that caused this ParameterException * @since 2.0 */ public ParameterException(CommandLine commandLine, String msg, Throwable t) { super(msg, t); this.commandLine = Assert.notNull(commandLine, "commandLine"); }
/** Constructs a new DefaultParamLabelRenderer with the specified separator string. */ public DefaultParamLabelRenderer(CommandSpec commandSpec) { this.commandSpec = Assert.notNull(commandSpec, "commandSpec"); } public String separator() { return commandSpec.parser().separator(); }
/** {@inheritDoc} */ public void init(CommandLine helpCommandLine, Help.Ansi ansi, PrintStream out, PrintStream err) { this.self = Assert.notNull(helpCommandLine, "helpCommandLine"); this.ansi = Assert.notNull(ansi, "ansi"); this.out = Assert.notNull(out, "out"); this.err = Assert.notNull(err, "err"); } }
public static OptionSpec.Builder builder(String name, String... names) { String[] copy = new String[Assert.notNull(names, "names").length + 1]; copy[0] = Assert.notNull(name, "name"); System.arraycopy(names, 0, copy, 1, names.length); return new Builder(copy); } public static OptionSpec.Builder builder(String[] names) { return new Builder(names); }
/** Constructs a new empty ColorScheme with the specified Ansi enabled mode. * @see Help#defaultColorScheme(Ansi) * @param ansi whether to emit ANSI escape codes or not */ public ColorScheme(Ansi ansi) {this.ansi = Assert.notNull(ansi, "ansi"); }
protected TextTable(Ansi ansi, Column[] columns) { this.ansi = Assert.notNull(ansi, "ansi"); this.columns = Assert.notNull(columns, "columns").clone(); if (columns.length == 0) { throw new IllegalArgumentException("At least one column is required"); } int totalWidth = 0; for (Column col : columns) { totalWidth += col.width; } tableWidth = totalWidth; } /** The column definitions of this table. */
public DefaultOptionRenderer(boolean showDefaultValues, String requiredMarker) { this.showDefaultValues = showDefaultValues; this.requiredMarker = Assert.notNull(requiredMarker, "requiredMarker"); } public Text[][] render(OptionSpec option, IParamLabelRenderer paramLabelRenderer, ColorScheme scheme) {
public Messages(CommandSpec spec, String baseName, ResourceBundle rb) { this.spec = Assert.notNull(spec, "CommandSpec"); this.bundleBaseName = baseName; this.rb = rb; this.keys = keys(rb); } private static ResourceBundle createBundle(String baseName) {
private TypedMember(MethodParam param, Object scope) { accessible = Assert.notNull(param, "command method parameter"); accessible.setAccessible(true); name = param.getName(); typeInfo = createTypeInfo(param.getType(), param.getParameterizedType()); // bind parameter ObjectBinding binding = new ObjectBinding(); getter = binding; setter = binding; initializeInitialValue(param); hasInitialValue = true; }
/** Sets the type info for this option or positional parameter, and returns this builder. * @param typeInfo type information that does not require {@code Class} objects and be constructed both at runtime and compile time * @since 4.0 */ public T typeInfo(ITypeInfo typeInfo) { setTypeInfo(Assert.notNull(typeInfo, "typeInfo")); return self(); } private void setTypeInfo(ITypeInfo newValue) {
/** Sets the command name (also called program name) displayed in the usage help synopsis to the specified value. * Note that this method only modifies the usage help message, it does not impact parsing behaviour. * The command name may also be set declaratively with the {@link CommandLine.Command#name()} annotation attribute. * @param commandName command name (also called program name) displayed in the usage help synopsis * @return this {@code CommandLine} object, to allow method chaining * @see CommandSpec#name(String) * @since 2.0 */ public CommandLine setCommandName(String commandName) { getCommandSpec().name(Assert.notNull(commandName, "commandName")); return this; }
/** Constructs a new ParameterException with the specified CommandLine and error message. * @param commandLine the command or subcommand whose input was invalid * @param msg describes the problem * @since 2.0 */ public ParameterException(CommandLine commandLine, String msg) { super(msg); this.commandLine = Assert.notNull(commandLine, "commandLine"); }
public ExecutionException(CommandLine commandLine, String msg) { super(msg); this.commandLine = Assert.notNull(commandLine, "commandLine"); } public ExecutionException(CommandLine commandLine, String msg, Throwable t) {
public Column(int width, int indent, Overflow overflow) { this.width = width; this.indent = indent; this.overflow = Assert.notNull(overflow, "overflow"); } }
public DefaultParameterRenderer(boolean showDefaultValues, String requiredMarker) { this.showDefaultValues = showDefaultValues; this.requiredMarker = Assert.notNull(requiredMarker, "requiredMarker"); } public Text[][] render(PositionalParamSpec param, IParamLabelRenderer paramLabelRenderer, ColorScheme scheme) {
/** Sets a new {@code IHelpFactory} to customize the usage help message. * @param helpFactory the new help factory. Must be non-{@code null}. * @return this {@code UsageMessageSpec} object, to allow method chaining */ public UsageMessageSpec helpFactory(IHelpFactory helpFactory) { this.helpFactory = Assert.notNull(helpFactory, "helpFactory"); return this; }
public ExecutionException(CommandLine commandLine, String msg, Throwable t) { super(msg, t); this.commandLine = Assert.notNull(commandLine, "commandLine"); } /** Returns the {@code CommandLine} object for the (sub)command that could not be invoked.