com.flexive.shared.configuration.parameters
Class ParameterImpl<T>

java.lang.Object
  extended by com.flexive.shared.configuration.parameters.ParameterImpl<T>
Type Parameters:
T - value type of the parameter
All Implemented Interfaces:
Parameter<T>, java.io.Serializable
Direct Known Subclasses:
BooleanParameter, IntegerParameter, LongParameter, ObjectParameter, StringParameter

public abstract class ParameterImpl<T>
extends java.lang.Object
implements Parameter<T>, java.io.Serializable

Generic parameter implementation.

Author:
Daniel Lichtenberger (daniel.lichtenberger@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
See Also:
Serialized Form

Constructor Summary
protected ParameterImpl(ParameterData<T> parameter, boolean registerParameter)
          Create a new parameter with the given data
 
Method Summary
 Parameter<T> freeze()
          Freeze the parameter configuration.
 ParameterData<T> getData()
          Returns the data object containing path and key for the parameter.
 java.lang.String getDatabaseValue(T value)
          Convert the given value to a string that will be stored in the configuration.
 T getDefaultValue()
          Return the parameter's default value or null if it is not set.
 java.lang.String getKey()
          Return the parameter's key.
 ParameterPath getPath()
          Return the parameter's path (including its scope).
 ParameterScope getScope()
          Return the parameter's scope.
 boolean isValid(T value)
          Returns true if the given value is a valid configuration value (e.g.
 Parameter<T> setData(ParameterData<T> parameterData)
          Sets the data for this parameter.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.flexive.shared.configuration.Parameter
copy, getValue
 

Constructor Detail

ParameterImpl

protected ParameterImpl(ParameterData<T> parameter,
                        boolean registerParameter)
Create a new parameter with the given data

Parameters:
parameter - parameter data
registerParameter - if the parameter should be registered in the static parameter table (don't do this for non-static parameter declarations)
Method Detail

getData

public ParameterData<T> getData()
Returns the data object containing path and key for the parameter.

Specified by:
getData in interface Parameter<T>
Returns:
the data object containing path and key for the parameter.

getDefaultValue

public T getDefaultValue()
Return the parameter's default value or null if it is not set.

Specified by:
getDefaultValue in interface Parameter<T>
Returns:
the parameter's default value or null if it is not set.

getKey

public java.lang.String getKey()
Return the parameter's key.

Specified by:
getKey in interface Parameter<T>
Returns:
the parameter's key.

getPath

public ParameterPath getPath()
Return the parameter's path (including its scope).

Specified by:
getPath in interface Parameter<T>
Returns:
the parameter's path (including its scope).

getScope

public ParameterScope getScope()
Return the parameter's scope.

Specified by:
getScope in interface Parameter<T>
Returns:
the parameter's scope.

isValid

public boolean isValid(T value)
Returns true if the given value is a valid configuration value (e.g. primitive parameters may not be null).

Specified by:
isValid in interface Parameter<T>
Parameters:
value - the value to be checked
Returns:
true if the given value is a valid configuration value

getDatabaseValue

public java.lang.String getDatabaseValue(T value)
Convert the given value to a string that will be stored in the configuration.

Specified by:
getDatabaseValue in interface Parameter<T>
Parameters:
value - the parameter value to be stored
Returns:
the value's string representation
See Also:
Parameter.getValue(Object)

setData

public Parameter<T> setData(ParameterData<T> parameterData)
Description copied from interface: Parameter
Sets the data for this parameter. Only works if the parameter instance is not frozen yet (see Parameter.freeze()).

Specified by:
setData in interface Parameter<T>
Parameters:
parameterData - the parameter data beans
Returns:
this

freeze

public Parameter<T> freeze()
Description copied from interface: Parameter
Freeze the parameter configuration. The parameter data cannot be modified on this instance after calling this method.

Specified by:
freeze in interface Parameter<T>
Returns:
this

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object