Skip to content

Package io.github.qishr.cascara.common.util

Class Builder

java.lang.Object
        io.github.qishr.cascara.common.util.CommandLine.Model.ArgGroupSpec.Builder

Enclosing Class:
    io.github.qishr.cascara.common.util.CommandLine.Model.ArgGroupSpec


public static class Builder

Builder responsible for creating valid ArgGroupSpec objects.

Method Summary

Modifier and Type Method Description
public Builder updateArgGroupAttributes(ArgGroup group) Updates this builder from the specified annotation values.
public ArgGroupSpec build() Returns a valid ArgGroupSpec instance.
public boolean exclusive() Returns whether this is a mutually exclusive group; true by default.
public Builder exclusive(boolean newValue) Sets whether this is a mutually exclusive group; true by default.
public Range multiplicity() Returns the multiplicity of this group: how many occurrences it may have on the command line; "0..1" (optional) by default.
public Builder multiplicity(String newValue) Sets the multiplicity of this group: how many occurrences it may have on the command line; "0..1" (optional) by default.
public Builder multiplicity(Range newValue) Sets the multiplicity of this group: how many occurrences it may have on the command line; "0..1" (optional) by default.
public boolean validate() Returns whether picocli should validate the rules of this group: for a mutually exclusive group this means that no more than one arguments in the group is specified on the command line; for a co-occurring group this means that all arguments in the group are specified on the command line.
public Builder validate(boolean newValue) Sets whether picocli should validate the rules of this group: for a mutually exclusive group this means that no more than one arguments in the group is specified on the command line; for a co-occurring group this means that all arguments in the group are specified on the command line.
public int order() Returns the position in the options list in the usage help message at which this group should be shown.
public Builder order(int order) Sets the position in the options list in the usage help message at which this group should be shown, and returns this builder.
public String heading() Returns the heading of this group, used when generating the usage documentation.
public Builder heading(String newValue) Sets the heading of this group (may be null), used when generating the usage documentation.
public String headingKey() Returns the heading key of this group, used to get the heading from a resource bundle.
public Builder headingKey(String newValue) Sets the heading key of this group, used to get the heading from a resource bundle.
public ITypeInfo typeInfo() Returns the type info for the annotated program element associated with this group.
public Builder typeInfo(ITypeInfo newValue) Sets the type info for the annotated program element associated with this group, and returns this builder.
public IGetter getter() Returns the IGetter that is responsible for supplying the value of the annotated program element associated with this group.
public Builder getter(IGetter getter) Sets the IGetter that is responsible for getting the value of the annotated program element associated with this group, and returns this builder.
public ISetter setter() Returns the ISetter that is responsible for modifying the value of the annotated program element associated with this group.
public Builder setter(ISetter setter) Sets the ISetter that is responsible for modifying the value of the annotated program element associated with this group, and returns this builder.
public IScope scope() Returns the IScope that determines where the setter sets the value (or the getter gets the value) of the annotated program element associated with this group.
public Builder scope(IScope scope) Sets the IScope that targets where the setter sets the value of the annotated program element associated with this group, and returns this builder.
public Builder addArg(ArgSpec arg) Adds the specified argument to the list of options and positional parameters that depend on this group.
public List<ArgSpec> args() Returns the list of options and positional parameters that depend on this group.
public Builder addSubgroup(ArgGroupSpec group) Adds the specified group to the list of subgroups that this group is composed of.
public List<ArgGroupSpec> subgroups() Returns the list of subgroups that this group is composed of.
public Builder addSpecElement(IAnnotatedElement element) Adds the specified {@literal @}Spec annotated program element to the list of spec elements for this group.
public List<IAnnotatedElement> specElements() Returns the list of program elements annotated with {@literal @}Spec configured for this group.

Method Details

updateArgGroupAttributes

public Builder updateArgGroupAttributes(ArgGroup group)

Updates this builder from the specified annotation values.

Parameters:

group - annotation values

Returns:

this builder for method chaining


build

public ArgGroupSpec build()

Returns a valid ArgGroupSpec instance.


exclusive

public boolean exclusive()

Returns whether this is a mutually exclusive group; true by default.If false, this is a co-occurring group. Ignored if validate.validate is false.

See Also:

exclusive


exclusive

public Builder exclusive(boolean newValue)

Sets whether this is a mutually exclusive group; true by default.If false, this is a co-occurring group. Ignored if validate.validate is false.

See Also:

exclusive


multiplicity

public Range multiplicity()

Returns the multiplicity of this group: how many occurrences it may have on the command line; "0..1" (optional) by default.A group can be made required by specifying a multiplicity of "1". For a group of mutually exclusive arguments, being required means that one of the arguments in the group must appear on the command line, or a MissingParameterException is thrown. For a group of co-occurring arguments, being required means that all arguments in the group must appear on the command line. Ignored if validate.validate is false.

See Also:

multiplicity


multiplicity

public Builder multiplicity(String newValue)

Sets the multiplicity of this group: how many occurrences it may have on the command line; "0..1" (optional) by default.A group can be made required by specifying a multiplicity of "1". For a group of mutually exclusive arguments, being required means that one of the arguments in the group must appear on the command line, or a MissingParameterException is thrown. For a group of co-occurring arguments, being required means that all arguments in the group must appear on the command line. Ignored if validate.validate is false.

See Also:

multiplicity


multiplicity

public Builder multiplicity(Range newValue)

Sets the multiplicity of this group: how many occurrences it may have on the command line; "0..1" (optional) by default.A group can be made required by specifying a multiplicity of "1". For a group of mutually exclusive arguments, being required means that one of the arguments in the group must appear on the command line, or a MissingParameterException is thrown. For a group of co-occurring arguments, being required means that all arguments in the group must appear on the command line. Ignored if validate.validate is false.

See Also:

multiplicity


validate

public boolean validate()

Returns whether picocli should validate the rules of this group: for a mutually exclusive group this means that no more than one arguments in the group is specified on the command line; for a co-occurring group this means that all arguments in the group are specified on the command line.true by default.

See Also:

validate


validate

public Builder validate(boolean newValue)

Sets whether picocli should validate the rules of this group: for a mutually exclusive group this means that no more than one arguments in the group is specified on the command line; for a co-occurring group this means that all arguments in the group are specified on the command line.true by default.

See Also:

validate


order

public int order()

Returns the position in the options list in the usage help message at which this group should be shown.Groups with a lower number are shown before groups with a higher number. This attribute is only honored for groups that have a heading.heading (or a headingKey.headingKey with a non-null resource bundle value).


order

public Builder order(int order)

Sets the position in the options list in the usage help message at which this group should be shown, and returns this builder.


heading

public String heading()

Returns the heading of this group, used when generating the usage documentation.

See Also:

heading


heading

public Builder heading(String newValue)

Sets the heading of this group (may be null), used when generating the usage documentation.

See Also:

heading


headingKey

public String headingKey()

Returns the heading key of this group, used to get the heading from a resource bundle.

See Also:

headingKey


headingKey

public Builder headingKey(String newValue)

Sets the heading key of this group, used to get the heading from a resource bundle.

See Also:

headingKey


typeInfo

public ITypeInfo typeInfo()

Returns the type info for the annotated program element associated with this group.

Returns:

type information that does not require Class objects and be constructed both at runtime and compile time


typeInfo

public Builder typeInfo(ITypeInfo newValue)

Sets the type info for the annotated program element associated with this group, and returns this builder.

Parameters:

newValue - type information that does not require Class objects and be constructed both at runtime and compile time


getter

public IGetter getter()

Returns the IGetter that is responsible for supplying the value of the annotated program element associated with this group.


getter

public Builder getter(IGetter getter)

Sets the IGetter that is responsible for getting the value of the annotated program element associated with this group, and returns this builder.


setter

public ISetter setter()

Returns the ISetter that is responsible for modifying the value of the annotated program element associated with this group.


setter

public Builder setter(ISetter setter)

Sets the ISetter that is responsible for modifying the value of the annotated program element associated with this group, and returns this builder.


scope

public IScope scope()

Returns the IScope that determines where the setter sets the value (or the getter gets the value) of the annotated program element associated with this group.


scope

public Builder scope(IScope scope)

Sets the IScope that targets where the setter sets the value of the annotated program element associated with this group, and returns this builder.


addArg

public Builder addArg(ArgSpec arg)

Adds the specified argument to the list of options and positional parameters that depend on this group.


args

public List<ArgSpec> args()

Returns the list of options and positional parameters that depend on this group.


addSubgroup

public Builder addSubgroup(ArgGroupSpec group)

Adds the specified group to the list of subgroups that this group is composed of.


subgroups

public List<ArgGroupSpec> subgroups()

Returns the list of subgroups that this group is composed of.


addSpecElement

public Builder addSpecElement(IAnnotatedElement element)

Adds the specified {@literal @}Spec annotated program element to the list of spec elements for this group.

Since:

4.6


specElements

public List<IAnnotatedElement> specElements()

Returns the list of program elements annotated with {@literal @}Spec configured for this group.

Since:

4.6