- java.lang.Object
-
- org.omnifaces.component.SimpleParam<T>
-
- Type Parameters:
T
- The type of the value.
- All Implemented Interfaces:
ValueHolder
,ParamHolder<T>
public class SimpleParam<T> extends Object implements ParamHolder<T>
This class provides a basic and default implementation of theParamHolder
interface. Ultimately, this class can be used as a simple key-value pair holder (parameter name-value) which uses an explicit/implicit Faces converter to convert the object value to string.- Since:
- 1.7
- Author:
- Bauke Scholtz
-
-
Constructor Summary
Constructors Constructor Description SimpleParam()
Default constructor.SimpleParam(UIParameter param)
Construct a simple param with name and value of givenUIParameter
component.SimpleParam(String name, T value)
Construct a simple param with name and value.SimpleParam(String name, T value, Converter<T> converter)
Construct a simple param with name, value and converter.SimpleParam(ParamHolder<T> param)
Construct a simple param with name, value and converter of givenParamHolder
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Converter<T>
getConverter()
Returns the converter, if any.T
getLocalValue()
Returns the original, unconverted value of the parameter.String
getName()
Returns the name of the parameter.String
getValue()
Returns the value of the parameter asString
.void
setConverter(Converter converter)
void
setName(String name)
Sets the parameter name.void
setValue(Object value)
-
-
-
Constructor Detail
-
SimpleParam
public SimpleParam()
Default constructor.
-
SimpleParam
public SimpleParam(String name, T value)
Construct a simple param with name and value.- Parameters:
name
- The parameter name.value
- The parameter value.
-
SimpleParam
public SimpleParam(String name, T value, Converter<T> converter)
Construct a simple param with name, value and converter.- Parameters:
name
- The parameter name.value
- The parameter value.converter
- The converter.
-
SimpleParam
public SimpleParam(UIParameter param)
Construct a simple param with name and value of givenUIParameter
component.- Parameters:
param
- TheUIParameter
to copy.- Throws:
ClassCastException
- When actual parameter value is notT
.- Since:
- 2.2
-
SimpleParam
public SimpleParam(ParamHolder<T> param)
Construct a simple param with name, value and converter of givenParamHolder
instance.- Parameters:
param
- TheParamHolder
to copy.- Since:
- 2.2
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:ParamHolder
Returns the name of the parameter.- Specified by:
getName
in interfaceParamHolder<T>
- Returns:
- The name of the parameter.
-
setName
public void setName(String name)
Sets the parameter name.- Parameters:
name
- The parameter name.
-
getLocalValue
public T getLocalValue()
Description copied from interface:ParamHolder
Returns the original, unconverted value of the parameter.- Specified by:
getLocalValue
in interfaceParamHolder<T>
- Specified by:
getLocalValue
in interfaceValueHolder
- Returns:
- The original, unconverted value of the parameter.
-
getValue
public String getValue()
Description copied from interface:ParamHolder
Returns the value of the parameter asString
. If the converter is set, or if any converter is available byApplication.createConverter(Class)
, passing the value's class, then return the result ofConverter.getAsString(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent, Object)
, otherwise return theObject.toString()
of the value.- Specified by:
getValue
in interfaceParamHolder<T>
- Specified by:
getValue
in interfaceValueHolder
- Returns:
- The value of the parameter as
String
. - See Also:
Converter.getAsString(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent, Object)
-
setValue
public void setValue(Object value)
- Specified by:
setValue
in interfaceValueHolder
- Throws:
ClassCastException
- When actual value is notT
.
-
getConverter
public Converter<T> getConverter()
Description copied from interface:ParamHolder
Returns the converter, if any.- Specified by:
getConverter
in interfaceParamHolder<T>
- Specified by:
getConverter
in interfaceValueHolder
- Returns:
- The converter, if any.
-
setConverter
public void setConverter(Converter converter)
- Specified by:
setConverter
in interfaceValueHolder
-
-