public class Parameters extends AbstractList<Object> implements Serializable
Parameter,
Parameters(Parameter[]),
Serialized Form| Modifier and Type | Class and Description |
|---|---|
protected static class |
Parameters.SerializableAbstractMap<K,V> |
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
autoCasting
If
true, values are automatically cast to the right type (if possible) when set. |
protected Map<String,Object> |
backing
The contents of this List are stored in this HashMap.
|
protected Parameter<Object>[] |
definition
This array maps integers (position in array) to map keys, making it possible to implement
List.
|
protected List<Map.Entry<String,Object>> |
patternBacking |
protected int |
patternLimit |
protected int |
toIndex |
static Parameters |
VOID
No need to bother for the functions with no parameters.
|
modCount| Modifier | Constructor and Description |
|---|---|
|
Parameters(List<Map.Entry<String,Object>> list) |
|
Parameters(Map<String,Object> backing) |
|
Parameters(Parameter<?>... def)
Constructor, taking an Parameter[] array argument.
|
|
Parameters(Parameter<?>[] def,
Collection<?> values)
If you happen to have a List of parameters, then you can wrap it into an Parameters with this constructor.
|
|
Parameters(Parameter<?>[] def,
Object... values) |
|
Parameters(Parameters params)
Copy-constructor
|
protected |
Parameters(Parameters params,
int from,
int to)
Used for nicer implemenation of subList (which we want to also be instanceof Parameters).
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkDef() |
void |
checkRequiredParameters()
Throws an IllegalArgumentException if one of the required parameters was not entered.
|
boolean |
containsParameter(Parameter<?> parameter)
Checks wether a certain parameter is available, using the Parameter as a qualifier.
|
boolean |
containsParameter(String parameterName)
Checks wether a certain parameter is available, using the parameter name as a qualifier.
|
Object |
get(int i) |
<F> F |
get(Parameter<F> parameter)
Gets the value of a parameter.
|
Object |
get(String parameterName)
Gets the value of a parameter.
|
Parameter<?>[] |
getDefinition() |
String |
getString(Parameter<?> parameter)
Gets the value of a parameter, cast to a String.
|
String |
getString(String parameterName)
Gets the value of a parameter, cast to a String.
|
int |
indexOfParameter(Parameter<?> parameter)
Returns the position of a parameter in the parameters list, using the Parameter as a qualifier.
|
int |
indexOfParameter(String parameterName)
Returns the position of a parameter in the parameters list, using the parameter name as a qualifier.
|
boolean |
isAutoCasting()
Whether this Parameters object is 'automaticly casting'.
|
boolean |
isHavingPatterns() |
Object |
set(int i,
Object value)
implementation of (modifiable) List
|
<F> Parameters |
set(Parameter<F> parameter,
F value)
Sets the value of a parameter.
|
Parameters |
set(String parameterName,
Object value)
Sets the value of a parameter.
|
Parameters |
setAll(Collection<?> values)
Copies all values of a collection to the corresponding values of this Parameters Object.
|
Parameters |
setAll(Map<String,?> map)
Copies all values of a map to the corresponding values of this Parameters Object.
|
Parameters |
setAll(Object... values) |
Parameters |
setAll(Parameters params) |
Parameters |
setAllIfDefined(Parameters params) |
void |
setAutoCasting(boolean autocast)
Sets the 'auto casting' property (which on default is false)
|
<F> Parameters |
setIfDefined(Parameter<F> parameter,
F value)
Sets the value of an argument, if the argument is defined, otherwise do nothing.
|
Parameters |
setIfDefined(String parameterName,
Object value)
Sets the value of an argument, if the argument is defined, otherwise do nothing.
|
int |
size() |
Parameters |
subList(int fromIndex,
int toIndex) |
Class<?>[] |
toClassArray() |
List<Map.Entry<String,Object>> |
toEntryList()
Returns the Parameters as an unmodifiable List of Map.Entrys with predictable iteration order
(the same order of this Parameters, which is a List of the values only, itself)
|
Map<String,Object> |
toMap()
Gives the arguments back as a (unmodifiable) map.
|
String |
toString() |
List<Map.Entry<String,Object>> |
toUndefaultEntryList()
Returns the Parameters as an unmodifiable List of Map.Entrys with predictable iteration order
(the same order of this Parameters, which is a List of the values only, itself)
Values which are the same as the default value are returned as
null. |
Map<String,Object> |
toUndefaultMap()
Returns this parameters object as a (unmodifiable) Map, but all values which only have the
default value are
null |
protected Map<String,Object> |
undefaultBacking()
Returns a view on the backing where every value wich is the default value is set to
null. |
Collection<LocalizedString> |
validate()
Validates all values in the Parameters object with their
Parameter.getDataType(). |
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRangeaddAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArrayclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArrayparallelStream, removeIf, streampublic static final Parameters VOID
protected final Map<String,Object> backing
protected int patternLimit
protected Parameter<Object>[] definition
protected boolean autoCasting
true, values are automatically cast to the right type (if possible) when set.protected int toIndex
public Parameters(Parameter<?>... def)
public final static Parameter[] MYFUNCTION_PARAMETERS = {
new Parameter("type", Integer.class),
new Parameter("text", String.class),
Parameter.CLOUD, // a predefined parameter
new Parameter.Wrapper(OTHERFUNCTION_PARAMETERS) // a way to include another definition in this one
};
public Parameters(Parameter<?>[] def, Collection<?> values)
values - Collection with values. This Collection should have a predictable iteration order.NullPointerException - if definition is nullParameters(Parameter[])public Parameters(Parameters params)
protected Parameters(Parameters params, int from, int to)
public boolean isHavingPatterns()
protected final void checkDef()
public String toString()
toString in class AbstractCollection<Object>public Class<?>[] toClassArray()
public void setAutoCasting(boolean autocast)
autocast - the new value for autocastisAutoCasting()public Parameter<?>[] getDefinition()
public boolean isAutoCasting()
true if autocasting is onpublic int size()
size in interface Collection<Object>size in interface List<Object>size in class AbstractCollection<Object>public Object get(int i)
public Object set(int i, Object value)
set in interface List<Object>set in class AbstractList<Object>NullPointerException - if definition not setpublic void checkRequiredParameters()
For complete datatype validationpublic Collection<LocalizedString> validate()
Parameter.getDataType(). You should
call this method if you ready to pass it into some function or so, if you want
validation. If the returned Collection is not empty, something is wrong, and you may want to
not proceed.public int indexOfParameter(Parameter<?> parameter)
get(int).parameter - the parameterpublic int indexOfParameter(String parameterName)
get(int).parameterName - the name of the parameterpublic boolean containsParameter(Parameter<?> parameter)
parameter - the parametertrue if a parameter exists.public boolean containsParameter(String parameterName)
parameterName - the name of the parametertrue if a parameter exists.public <F> Parameters set(Parameter<F> parameter, F value)
parameter - the Parameter describing the parameter to setvalue - the object value to setIllegalArgumentException - if either the argument name is unknown to this Parameters, or the value is of the wrong type.public Parameters set(String parameterName, Object value)
parameterName - the name of the parameter to setvalue - the object value to setIllegalArgumentException - if either the argument name is unknown to this Parameters, or the value is of the wrong type.public Parameters setAll(Map<String,?> map)
public Parameters setAll(Collection<?> values)
public Parameters setAll(Object... values)
public Parameters setAllIfDefined(Parameters params)
public Parameters setAll(Parameters params)
public Parameters subList(int fromIndex, int toIndex)
public <F> Parameters setIfDefined(Parameter<F> parameter, F value)
parameter - the parameter to setvalue - the object value to setpublic Parameters setIfDefined(String parameterName, Object value)
parameterName - the name of the parameter to setvalue - the object value to setpublic <F> F get(Parameter<F> parameter)
parameter - the parameter to getpublic Object get(String parameterName)
parameterName - the name of the parameter to getpublic String getString(Parameter<?> parameter)
parameter - the parameter to getStringpublic String getString(String parameterName)
parameterName - the name of the parameter to getStringprotected Map<String,Object> undefaultBacking()
null. If the default is not null itself, but the value is,
than the value will be returned as an empty string.
This can be used to generated keys and such, which are not polluted with all kind of default values.public Map<String,Object> toUndefaultMap()
nullpublic List<Map.Entry<String,Object>> toEntryList()
public List<Map.Entry<String,Object>> toUndefaultEntryList()
null. If the
default is not null but the value is, then it is returned as an empty string.MMBase 1.9-SNAPSHOT - ${javadoctimestamp}