Package cdc.args
Class Arg
- java.lang.Object
-
- cdc.args.Arg
-
public final class Arg extends Object
Effective argument.It is a (name, value) pair.
- Author:
- Damien Carbonne
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object object)StringgetName()ObjectgetValue()<T> TgetValue(Class<T> cls)Returns the value cast to a target class.<T> TgetValue(Class<T> cls, T def)Returns the value cast to a target class or a default value.ObjectgetValue(Object def)Returns the value or a default value.inthashCode()booleanisCompliantWith(FormalArg<?> farg)booleanisCompliantWith(FormalArgs fargs)booleanisCompliantWith(Class<?> cls)StringtoString()
-
-
-
Constructor Detail
-
Arg
public Arg(String name, Object value)
Creates an effective argument.No check is done on argument value.
- Parameters:
name- The name. It must be valid.value- the value.- Throws:
IllegalArgumentException- Whennameis invalid.
-
Arg
public Arg(FormalArg<T> farg, T value)
Creates an effective argument that is compliant with a formal argument.- Type Parameters:
T- The formal argument type.- Parameters:
farg- The formal argument.value- The value.- Throws:
IllegalArgumentException- Whenfargis null orvalueis not compliant withfarg.
-
-
Method Detail
-
getName
public String getName()
- Returns:
- The name.
-
getValue
public Object getValue()
- Returns:
- The value.
-
getValue
public Object getValue(Object def)
Returns the value or a default value.- Parameters:
def- The default value.- Returns:
- The value or
defif value isnull.
-
getValue
public <T> T getValue(Class<T> cls)
Returns the value cast to a target class.- Type Parameters:
T- The target type.- Parameters:
cls- The target class.- Returns:
- The cast of value to
cls.
-
getValue
public <T> T getValue(Class<T> cls, T def)
Returns the value cast to a target class or a default value.- Type Parameters:
T- The target type.- Parameters:
cls- The target class.def- The default value.- Returns:
- The value cats to
clsordefif value isnull.
-
isCompliantWith
public boolean isCompliantWith(FormalArg<?> farg)
-
isCompliantWith
public boolean isCompliantWith(FormalArgs fargs)
-
isCompliantWith
public boolean isCompliantWith(Class<?> cls)
-
-