Interface Parameters
-
public interface ParametersAString-keyed parameter map. The parameter mappings are defined by a synthetic component builder. The CDI container passes the parameter map to functions defined by the same synthetic component builder, whenever it needs to invoke those functions. That is:- a synthetic bean creation and
destruction function, defined by
SyntheticBeanBuilder; - a synthetic observer notification
function, defined by
SyntheticObserverBuilder.
Parameters-accepting function without a change. For example, if the builder defines anintparameter, it must be looked up asintand cannot be looked up aslong.Values of primitive types may be looked up either using the primitive type (such as
int.class), or using the corresponding wrapper type (Integer.class). The return value is always of the wrapper type, so thatnullcan be returned when the parameter does not exist. Note that this does not apply to arrays of primitive types; anint[]cannot be looked up asInteger[]. This is because arrays are reference types and sonullcan be returned.Class-typed parameters are available as instances of
Class, even if an instance ofClassInfowas passed to the builder.Annotation-typed parameters are available as instances of the annotation type, even if an instance of
AnnotationInfowas passed to the builder. - a synthetic bean creation and
destruction function, defined by
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> Tget(String key, Class<T> type)Returns the value of a parameter with givenkey.<T> Tget(String key, Class<T> type, T defaultValue)Returns the value of a parameter with givenkey.
-
-
-
Method Detail
-
get
<T> T get(String key, Class<T> type)
Returns the value of a parameter with givenkey. The value is expected to be of giventype.- Type Parameters:
T- the parameter type- Parameters:
key- the parameter key; must not benulltype- the parameter type; must not benull- Returns:
- the parameter value, or
nullif parameter with givenkeydoes not exist - Throws:
ClassCastException- if the parameter exists, but is of a different type
-
get
<T> T get(String key, Class<T> type, T defaultValue)
Returns the value of a parameter with givenkey. The value is expected to be of giventype. If the parameter does not exist, returnsdefaultValue.- Type Parameters:
T- the parameter type- Parameters:
key- the parameter key; must not benulltype- the parameter type; must not benulldefaultValue- the value to return if parameter with givenkeydoes not exist- Returns:
- the parameter value, or
defaultValueif parameter with givenkeydoes not exist - Throws:
ClassCastException- if the parameter exists, but is of a different type
-
-