public class ParametricBase extends java.lang.Object implements Parametric
Parametric
interface on encapsulated Map
.
Note that this class can be used as wrapper for Map
.Constructor and Description |
---|
ParametricBase(java.util.Map<java.lang.String,? extends java.lang.Object> map)
Creates a new instance of ParametricBase backed-up by the given map with parameters.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.StringBuilder |
append(java.lang.StringBuilder str,
Parametric parametric,
java.lang.String nameValueSeparator,
java.lang.String parameterSeparator,
boolean addFirstParameterSeparator)
Appends the given
Parametric instance to the given string. |
static java.lang.StringBuilder |
appendParameter(java.lang.StringBuilder str,
Parametric parametric,
java.lang.String parameterName,
java.lang.String nameValueSeparator)
|
static void |
clearSurplusData(java.util.Iterator<?> data,
boolean removeNonClearables,
boolean treatPrimitiveAsClearable)
|
static boolean |
clearSurplusData(java.lang.Object object,
boolean treatPrimitiveAsClearable)
|
boolean |
containsParameter(java.lang.String name)
Returns whether a parameter with the given
name exists in this parametric object. |
java.lang.Object |
getParameter(java.lang.String name)
Returns an additional parameter with the given
name . |
<T> T |
getParameter(java.lang.String name,
java.lang.Class<? extends T> parameterClass)
Returns an additional parameter with the given
name . |
<T> T |
getParameter(java.lang.String name,
java.lang.Class<? extends T> parameterClass,
T defaultValue)
Returns an additional parameter with the given
name . |
int |
getParameterCount()
Returns the number of additional parameters.
|
java.util.Map<java.lang.String,? extends java.lang.Object> |
getParameterMap()
Returns the map of all additional parameters.
|
java.util.Collection<java.lang.String> |
getParameterNames()
Returns a set of additional parameter names present in this object.
|
java.lang.Object |
getRequiredParameter(java.lang.String name)
Returns an additional parameter with the given
name . |
<T> T |
getRequiredParameter(java.lang.String name,
java.lang.Class<? extends T> parameterClass)
Returns an additional parameter with the given
name . |
java.lang.String |
toString() |
static java.lang.String |
toStringWithCast(java.lang.Object object,
java.lang.String separator,
java.lang.String nameValueSeparator,
java.lang.String parameterSeparator)
Converts the given object to string.
|
public ParametricBase(java.util.Map<java.lang.String,? extends java.lang.Object> map)
map
- the map that provides the parameter valuespublic int getParameterCount()
Parametric
getParameterCount
in interface Parametric
public java.util.Collection<java.lang.String> getParameterNames()
Parametric
getParameterNames
in interface Parametric
public boolean containsParameter(java.lang.String name)
Parametric
name
exists in this parametric object.containsParameter
in interface Parametric
name
- the name of the additional parameter to getname
or false if it does notpublic java.lang.Object getParameter(java.lang.String name)
Parametric
name
.getParameter
in interface Parametric
name
- the name of the additional parameter to getname
or null if it is not setpublic java.lang.Object getRequiredParameter(java.lang.String name) throws java.lang.IllegalArgumentException
Parametric
name
.
If the parameter with the given name
is not set, an exception is thrown.getRequiredParameter
in interface Parametric
name
- the name of the additional parameter to getname
java.lang.IllegalArgumentException
- if the parameter with the given name
is not setpublic <T> T getRequiredParameter(java.lang.String name, java.lang.Class<? extends T> parameterClass) throws java.lang.IllegalArgumentException, java.lang.ClassCastException
Parametric
name
.
If the parameter with the given name
is not set or is not an
instance of parameterClass
, an exception is thrown.getRequiredParameter
in interface Parametric
T
- the class of the parametername
- the name of the additional parameter to getparameterClass
- the class of the parameter to getjava.lang.IllegalArgumentException
- if the parameter with the given name
is not setjava.lang.ClassCastException
- if the parameter with the given name
is not an instance of parameterClass
public <T> T getParameter(java.lang.String name, java.lang.Class<? extends T> parameterClass, T defaultValue)
Parametric
name
.
If the parameter is not set or is not an instance of parameterClass
,
the defaultValue
is returned instead.getParameter
in interface Parametric
T
- the class of the parametername
- the name of the additional parameter to getparameterClass
- the class of the parameter to getdefaultValue
- the default value to use if the parameter is nullpublic <T> T getParameter(java.lang.String name, java.lang.Class<? extends T> parameterClass)
Parametric
name
.
If the parameter name
exists but it is not an instance of
parameterClass
, null is returned.getParameter
in interface Parametric
T
- the class of the parametername
- the name of the additional parameter to getparameterClass
- the class of the parameter to getname
or null if it is not setpublic java.util.Map<java.lang.String,? extends java.lang.Object> getParameterMap()
Parametric
getParameterMap
in interface Parametric
public static java.lang.StringBuilder appendParameter(java.lang.StringBuilder str, Parametric parametric, java.lang.String parameterName, java.lang.String nameValueSeparator)
parameterName
from the Parametric
instance to the str
.
The parameter is printed as <parameter-name><<nameValueSeparator
><parameter-value>.str
- the string builder to append the parametric values toparametric
- the parametric instance the values of which to append to the stringparameterName
- the name of the parameter to appendnameValueSeparator
- string that is placed between the parameter name and the parameter valuepublic static java.lang.StringBuilder append(java.lang.StringBuilder str, Parametric parametric, java.lang.String nameValueSeparator, java.lang.String parameterSeparator, boolean addFirstParameterSeparator)
Parametric
instance to the given string.
Each parameter from the parametric
is printed as the
<parameter-name><<nameValueSeparator
><parameter-value>.
The respective parameters are separated using the given parameterSeparator
.str
- the string builder to append the parametric values toparametric
- the parametric instance the values of which to append to the stringnameValueSeparator
- string that is placed between the parameter name and the parameter valueparameterSeparator
- string that is placed between each parameter recordaddFirstParameterSeparator
- flag whether to add the parameterSeparator
for the first parameter or notpublic static java.lang.String toStringWithCast(java.lang.Object object, java.lang.String separator, java.lang.String nameValueSeparator, java.lang.String parameterSeparator)
Parametric
interface, the parameters are
appended
to the string after the specified separator.object
- the object to convert to stringseparator
- the string to append after the object and before the parametersnameValueSeparator
- string that is placed between the parameter name and the parameter valueparameterSeparator
- string that is placed between each parameter recordpublic java.lang.String toString()
toString
in class java.lang.Object
public static void clearSurplusData(java.util.Iterator<?> data, boolean removeNonClearables, boolean treatPrimitiveAsClearable)
public static boolean clearSurplusData(java.lang.Object object, boolean treatPrimitiveAsClearable)
object
- the object to cleartreatPrimitiveAsClearable
- flag whether to consider primitive
classes as implicitly cleared