org.rhq.enterprise.communications.command.param
Class Parameter

java.lang.Object
  extended by org.rhq.enterprise.communications.command.param.Parameter
All Implemented Interfaces:
Serializable

public class Parameter
extends Object
implements Serializable

A parameter encapsulates both a definition and an object value. Note that a parameter is allowed to have a null definition, that is, the parameter can be of an unknown type and name; in this case, only its value is known.

A definition is immutable but this class allows for its parameter value to be set.

Author:
Charles Crouch, John Mazzitelli
See Also:
Serialized Form

Constructor Summary
  Parameter(Parameter original)
          Copy-constructor for Parameter.
  Parameter(ParameterDefinition definition, Object value)
          Constructor for Parameter with the given initializers.
protected Parameter(ParameterDefinition definition, Object value, boolean isDirty)
          Creates a new Parameter object given the individual parts of the parameter.
 
Method Summary
 boolean equals(Object obj)
           
 ParameterDefinition getDefinition()
          Returns the parameter's definition.
 String getName()
          This is a convienence method to get the name of the parameter from its definition.
 Object getValue()
          Returns the parameter's data value.
 int hashCode()
           
 boolean isDirty()
          Returns true if the dirty flag has been set; that is, if setValue(Object) has been called, thus changing the value of this object's original value.
 void setValue(Object value)
          Sets the parameter's data value.
 String toString()
          Same as toString(true).
 String toString(boolean showValue)
          Will provide the string form of the parameter but the value's actual toString will only be returned in the string if showValue is true.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Parameter

public Parameter(Parameter original)
Copy-constructor for Parameter.

Parameters:
original - the original to copy

Parameter

protected Parameter(ParameterDefinition definition,
                    Object value,
                    boolean isDirty)
Creates a new Parameter object given the individual parts of the parameter.

Parameters:
definition - the parameter's definition
value - the value of the parameter
isDirty - the flag to indicate if the parameter's value was changed (i.e. different than its original or default value)

Parameter

public Parameter(ParameterDefinition definition,
                 Object value)
Constructor for Parameter with the given initializers. Note that the definition may be null, in which case nothing is known about the parameter other than its value.

Parameters:
definition - the object that defines the parameter metadata like its name, type, etc. (may be null)
value - the actual value of the parameter (may be null)
Method Detail

getName

public String getName()
This is a convienence method to get the name of the parameter from its definition.

Returns:
the parameter name

getDefinition

public ParameterDefinition getDefinition()
Returns the parameter's definition. This may be null, in which case you don't know anything about the parameter other than its value.

Returns:
the parameter's metadata definition (like its name, type, etc.)

getValue

public Object getValue()
Returns the parameter's data value. This may be null.

Returns:
the parameter value

setValue

public void setValue(Object value)
Sets the parameter's data value. This may be null. The dirty flag is set when this method is called.

Parameters:
value - the parameter value

isDirty

public boolean isDirty()
Returns true if the dirty flag has been set; that is, if setValue(Object) has been called, thus changing the value of this object's original value.

Returns:
true if the parameter's value was changed from its original value from the time this object was instantiated

toString

public String toString()
Same as toString(true).

Overrides:
toString in class Object
See Also:
Object.toString()

toString

public String toString(boolean showValue)
Will provide the string form of the parameter but the value's actual toString will only be returned in the string if showValue is true. If it is false, the value will be omitted from the string.

Parameters:
showValue - if true, the parameter's value will be in the returned string, it will not be if false
Returns:
the string form of the parameter
See Also:
Object.toString()

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.