Package cdc.args
Class Args
java.lang.Object
cdc.args.Args
'Set' of effective arguments.
This class is immutable. Args.Builder can be used to create instances of Args.
Compliance rules
There is compliance between Args args and FormalArgs fargs when:
- In STRICT mode: each
argofargscorresponds to onefargoffargswith a compliant value. - In LOOSE mode: each
argofargs1) is absent offargs, 2) or corresponds to onefargoffargswith a compliant value. - In both nodes, each MANDATORY
farghas a compliant value defined inargs.
fargs = [arg0: MANDATORY String, arg1: OPTIONAL Object], compliance will be:
truewith:args = [arg0: "Hello"]in any mode.truewith:args = [arg0: "Hello", arg1: null]in any mode.truewith:args = [arg0: "Hello", arg1: "World"]in any mode.truewith:args = [arg0: "Hello", arg2: null]in LOOSE mode.falsewith:args = [arg0: "Hello", arg2: null]in STRICT mode.falsewith:args = [arg0: null]in any mode.
- Author:
- Damien Carbonne
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classHelper class used to create Args. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanareCompliant(Args args, FormalArgs fargs, Strictness strictness) Returnstruewhen an arguments is compliant with a formal arguments.static booleanareCompliant(Args args, Strictness strictness, FormalArgs... array) static booleanareCompliant(Args args, Strictness strictness, Collection<FormalArgs> collection) static booleanareLooselyCompliant(Args args, FormalArgs fargs) Returnstruewhen an arguments is loosely compliant with a formal arguments.static booleanareLooselyCompliant(Args args, FormalArgs... array) static booleanareLooselyCompliant(Args args, Collection<FormalArgs> collection) static booleanareStrictlyCompliant(Args args, FormalArgs fargs) Returnstruewhen an arguments is strictly compliant with a formal arguments.static booleanareStrictlyCompliant(Args args, FormalArgs... array) static booleanareStrictlyCompliant(Args args, Collection<FormalArgs> collection) static Args.Builderbuilder()static Args.Builderbuilder(FormalArgs fargs) static voidcheckCompliance(Args args, Strictness strictness, FormalArgs... array) static voidcheckCompliance(Args args, Strictness strictness, Collection<FormalArgs> collection) voidcheckComplianceWithOneOf(Strictness strictness, FormalArgs... array) Checks compliance of the arguments with formal arguments tuples.voidcheckComplianceWithOneOf(Strictness strictness, Collection<FormalArgs> collection) Checks compliance of this arguments with one of a collection of formal arguments.static voidcheckLooseCompliance(Args args, FormalArgs... array) static voidcheckLooseCompliance(Args args, Collection<FormalArgs> collection) voidcheckLooseComplianceWithOneOf(FormalArgs... array) Checks loose compliance of the arguments with formal arguments tuples.voidcheckLooseComplianceWithOneOf(Collection<FormalArgs> collection) Checks loose compliance of this arguments with one of a collection of formal arguments.static voidcheckStrictCompliance(Args args, FormalArgs... array) static voidcheckStrictCompliance(Args args, Collection<FormalArgs> collection) voidcheckStrictComplianceWithOneOf(FormalArgs... array) Checks strict compliance of the arguments with formal arguments tuples.voidcheckStrictComplianceWithOneOf(Collection<FormalArgs> collection) Checks strict compliance of this arguments with one of a collection of formal arguments.booleanReturns the argument that has a given name ornull.getArgs()getNames()<T> TReturns the value associated to a formal argument ornull.<T> TReturns the value associated to a formal argument or a default value.Returns the value (as Object) associated to a name or null.<T> TReturns the value associated to a name, as a type, ornull.<T> TReturns the value associated to a name, as a type, or a default value.Returns the value (as Object) associated to a name or a default value.booleanReturnstrueif this Args contains an argument with a particular name.booleanhasArgWithMatchingName(FormalArg<?> farg) Returnstrueif this tuple contains an argument whose name matches the name of a formal argument.inthashCode()booleanisCompliantWith(FormalArgs fargs, Strictness strictness) Returns true when this Args is compliant with formal arguments and strictness.booleanisCompliantWithOneOf(Strictness strictness, FormalArgs... array) Returnstrueif this arguments is compliant with at least one formal argument tuple.booleanisCompliantWithOneOf(Strictness strictness, Collection<FormalArgs> collection) Returnstrueif this arguments is compliant with at least one formal argument tuple.booleanisConflictingWith(FormalArgs fargs) booleanisEmpty()booleanbooleanisLooselyCompliantWith(FormalArgs fargs) Returns true when this Args is loosely compliant with formal arguments.booleanisLooselyCompliantWithOneOf(FormalArgs... array) Returnstrueif this arguments is loosely compliant with at least one formal argument tuple.booleanisLooselyCompliantWithOneOf(Collection<FormalArgs> collection) Returnstrueif this arguments is loosely compliant with at least one formal argument tuple.booleanReturns true when this Args is strictly compliant with formal arguments.booleanisStrictlyCompliantWithOneOf(FormalArgs... array) Returnstrueif this arguments is strictly compliant with at least one formal argument tuple.booleanisStrictlyCompliantWithOneOf(Collection<FormalArgs> collection) Returnstrueif this arguments is strictly compliant with at least one formal argument tuple.static FormalArgsreduceNecessity(FormalArgs fargs, Args args) Creates a new set from this one and another one.intsize()toString()
-
Field Details
-
NO_ARGS
Empty arguments.
-
-
Constructor Details
-
Args
public Args()Creates an empty set. -
Args
Creates a set.- Parameters:
args- The arguments.
-
Args
Creates a set.- Parameters:
args- The arguments.
-
-
Method Details
-
isEmpty
public boolean isEmpty()- Returns:
truewhen there are no arguments.
-
isEmptyOrAllValuesAreNull
public boolean isEmptyOrAllValuesAreNull()- Returns:
trueif this tuple is empty or all its values arenull.
-
size
public int size()- Returns:
- The number of arguments.
-
getNames
- Returns:
- A list of argument names, in the order they were declared.
-
getSortedNames
-
getArg
Returns the argument that has a given name ornull.- Parameters:
name- The name.- Returns:
- The argument named
nameornull
-
getArgs
- Returns:
- A list of arguments, in the order they were declared.
-
hasArg
Returnstrueif this Args contains an argument with a particular name.- Parameters:
name- The name.- Returns:
trueif this args contains an argument namedname.
-
hasArgWithMatchingName
Returnstrueif this tuple contains an argument whose name matches the name of a formal argument.- Parameters:
farg- The formal argument.- Returns:
trueif this tuple contains an argument whose name matches the name offarg.
-
set
Creates a new set from this one and another one.Values in
othertake precedence on values of this set.- Parameters:
other- The other arguments.- Returns:
- A new set from this one and
other.
-
getValue
Returns the value (as Object) associated to a name or a default value.- Parameters:
name- Name of the retrieved value.def- The default value.- Returns:
- The value (as Object) associated to name or def.
-
getValue
Returns the value (as Object) associated to a name or null.If no value is associated to name,
nullis returned.- Parameters:
name- Name of the retrieved value.- Returns:
- The value (as Object) associated to name or null.
- Throws:
IllegalArgumentException- Whennameisnull.
-
getValue
Returns the value associated to a formal argument or a default value.- Type Parameters:
T- The formal argument type.- Parameters:
farg- The formal argument.def- The default value.- Returns:
- The value corresponding to
fargornull. - Throws:
IllegalArgumentException- Whenfargisnull.ClassCastException- When the associated value can not be cast to expected class.
-
getValue
Returns the value associated to a formal argument ornull.- Type Parameters:
T- The formal argument type.- Parameters:
farg- The formal argument.- Returns:
- The value associated to
farg. - Throws:
IllegalArgumentException- Whenfargisnull.ClassCastException- When the associated value can not be cast to expected class.
-
getValue
Returns the value associated to a name, as a type, or a default value.If the value associated to name can not be converted to type, an exception is raised.
- Type Parameters:
T- Return type.- Parameters:
name- Name of the retrieved value.cls- Class of the retrieved value.def- The default value to return if no value is associated to name.- Returns:
- The value associated to
nameordef. - Throws:
IllegalArgumentException- Whennameofclsisnull.ClassCastException- When the associated value can not be cast tocls.
-
getValue
Returns the value associated to a name, as a type, ornull.If no value is associated to name,
nullis returned.
If the value associated to name can not be converted to type, an exception is raised.- Type Parameters:
T- Return type.- Parameters:
name- Name of the retrieved value.cls- Class of the retrieved value.- Returns:
- The value associated to
nameornull. - Throws:
IllegalArgumentException- Whennameofclsisnull.ClassCastException- When the associated value can not be cast tocls.
-
isCompliantWith
Returns true when this Args is compliant with formal arguments and strictness.- Parameters:
fargs- The formal arguments.strictness- The compliance strictness.- Returns:
trueif this Args is compliant withfargsandstrictness.
-
isLooselyCompliantWith
Returns true when this Args is loosely compliant with formal arguments.- Parameters:
fargs- The formal arguments.- Returns:
trueif this Args is loosely compliant withfargs.
-
isStrictlyCompliantWith
Returns true when this Args is strictly compliant with formal arguments.- Parameters:
fargs- The formal arguments.- Returns:
trueif this Args is strictly compliant withfargs.
-
isConflictingWith
-
isCompliantWithOneOf
Returnstrueif this arguments is compliant with at least one formal argument tuple.- Parameters:
strictness- The compliance strictness.collection- The collection of formal arguments tuples.- Returns:
trueif this arguments is compliant with at least one element ofcollection.
-
isLooselyCompliantWithOneOf
Returnstrueif this arguments is loosely compliant with at least one formal argument tuple.- Parameters:
collection- The collection of formal arguments tuples.- Returns:
trueif this arguments is loosely compliant with at least one element ofcollection.
-
isStrictlyCompliantWithOneOf
Returnstrueif this arguments is strictly compliant with at least one formal argument tuple.- Parameters:
collection- The collection of formal arguments tuples.- Returns:
trueif this arguments is strictly compliant with at least one element ofcollection.
-
isCompliantWithOneOf
Returnstrueif this arguments is compliant with at least one formal argument tuple.- Parameters:
strictness- The compliance strictness.array- The array of formal arguments tuples.- Returns:
trueif this arguments is compliant with at least one element ofarray.
-
isLooselyCompliantWithOneOf
Returnstrueif this arguments is loosely compliant with at least one formal argument tuple.- Parameters:
array- The array of formal arguments tuples.- Returns:
trueif this arguments is loosely compliant with at least one element ofarray.
-
isStrictlyCompliantWithOneOf
Returnstrueif this arguments is strictly compliant with at least one formal argument tuple.- Parameters:
array- The array of formal arguments tuples.- Returns:
trueif this arguments is strictly compliant with at least one element ofarray.
-
checkComplianceWithOneOf
Checks compliance of this arguments with one of a collection of formal arguments.- Parameters:
strictness- The strictness.collection- The collection of formal arguments.- Throws:
InvalidArgsException- If there is no compliance.
-
checkLooseComplianceWithOneOf
Checks loose compliance of this arguments with one of a collection of formal arguments.- Parameters:
collection- The collection of formal arguments.- Throws:
InvalidArgsException- If there is no compliance.
-
checkStrictComplianceWithOneOf
Checks strict compliance of this arguments with one of a collection of formal arguments.- Parameters:
collection- The collection of formal arguments.- Throws:
InvalidArgsException- If there is no compliance.
-
checkComplianceWithOneOf
Checks compliance of the arguments with formal arguments tuples.- Parameters:
strictness- The compliance strictness.array- The array of formal arguments tuples.- Throws:
InvalidArgsException- When there is no compliance.
-
checkLooseComplianceWithOneOf
Checks loose compliance of the arguments with formal arguments tuples.- Parameters:
array- The array of formal arguments tuples.- Throws:
IllegalArgumentException- When there is no compliance.
-
checkStrictComplianceWithOneOf
Checks strict compliance of the arguments with formal arguments tuples.- Parameters:
array- The array of formal arguments tuples.- Throws:
IllegalArgumentException- When there is no compliance.
-
areCompliant
Returnstruewhen an arguments is compliant with a formal arguments.- Parameters:
args- The arguments.fargs- The formal arguments.strictness- The strictness.- Returns:
truewhenargsis compliant withfargs.
-
areLooselyCompliant
Returnstruewhen an arguments is loosely compliant with a formal arguments.- Parameters:
args- The arguments.fargs- The formal arguments.- Returns:
truewhenargsis loosely compliant withfargs.
-
areStrictlyCompliant
Returnstruewhen an arguments is strictly compliant with a formal arguments.- Parameters:
args- The arguments.fargs- The formal arguments.- Returns:
truewhenargsis strictly compliant withfargs.
-
areCompliant
public static boolean areCompliant(Args args, Strictness strictness, Collection<FormalArgs> collection) -
areLooselyCompliant
-
areStrictlyCompliant
-
areCompliant
-
areLooselyCompliant
-
areStrictlyCompliant
-
checkCompliance
public static void checkCompliance(Args args, Strictness strictness, Collection<FormalArgs> collection) -
checkLooseCompliance
-
checkStrictCompliance
-
checkCompliance
-
checkLooseCompliance
-
checkStrictCompliance
-
reduceNecessity
-
hashCode
public int hashCode() -
equals
-
toString
-
builder
- Returns:
- A new Builder instance.
-
builder
-