jklustor-all-api-0.0.7-20140619012755 (ChemAxon)


com.chemaxon.apidiscovery
Class ParameterWrapper

Object
  extended by com.chemaxon.apidiscovery.ParameterWrapper

@Beta
public class ParameterWrapper
extends Object

Wraps a parameter which can be set or get on an object.

Usually parameters of Builder objects are wrapped

Please note that support of all types and validation is not complete yet.

Please note that this class is marked with Beta annotation, so it can be subject of incompatible changes or removal in later releases.

Author:
Gabor Imre

Nested Class Summary
static class ParameterWrapper.ParameterType
          Wrapped parameter types.
 
Constructor Summary
ParameterWrapper(Object mutableHostObject, Field parameterField)
          Create a for a parameter field of a mutable object.
 
Method Summary
 String getAPIFieldName()
          API field name.
 boolean getBooleanValue()
          Value of a boolean field.
 Object getCurrentValue()
          Current value.
 String getDetailedDescription()
          Detailed description.
 double getDoubleValue()
          Value of a double field.
 Enum getEnumValue()
          Value of an enum field.
 int getIntValue()
          Value of an int field.
 String getName()
          Name.
(package private)  int getOrder()
          Order stored in parameter annotation.
 Class<?> getParameterClass()
          Return enum class for enum field.
 String getShortName()
          Short name.
 String getStringValue()
          Value of a String field.
 ParameterWrapper.ParameterType getType()
          Type.
 boolean isDoubleValid(double d)
          Check if a value for a double field is valid.
 void parseParameterValue(String value)
          Parse parameter value from a String.
 void setBooleanValue(boolean b)
          Set value of a boolean field.
 void setDoubleValue(double d)
          Set value of a double field.
 void setIntValue(int i)
          Set int value of a int field.
 void setStringValue(String s)
          Set String value of a String field.
 void setValue(Object o)
          Set value.
 String toStringRepresentation()
          Create String representation of the represented value.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParameterWrapper

ParameterWrapper(Object mutableHostObject,
                 Field parameterField)
Create a for a parameter field of a mutable object.

Parameters:
mutableHostObject - The mutable object which a field is wrapped
parameterField - The wrapped field
Method Detail

getOrder

int getOrder()
Order stored in parameter annotation.

Returns:
order from parameter annotation

getAPIFieldName

public String getAPIFieldName()
API field name.

Returns:
The API field name of the represented parameter

getShortName

public String getShortName()
Short name.

Returns:
Short name of the represented parameter - from its Description annotation

getName

public String getName()
Name.

Returns:
Name of the represented parameter - from its Description annotation

getDetailedDescription

public String getDetailedDescription()
Detailed description.

Returns:
Detailed description of the represented parameter - from its Description annotation

getCurrentValue

public Object getCurrentValue()
Current value.

Returns:
The current value of the represented parameter

setValue

public void setValue(Object o)
Set value.

Parameters:
o - Value to set. Type must match represented parameter type. Note that setting null is not allowed.

getType

public ParameterWrapper.ParameterType getType()
Type.

Returns:
Type of the represented parameter

toStringRepresentation

public String toStringRepresentation()
Create String representation of the represented value.

Note that this method uses Enum.name() instead of its Object.toString() since later can be overridden preventing further safe parse.

Note that ParameterWrapper.ParameterType.OTHER type parameters are currently not supported.

Returns:
String representation which can be parsed using parseParameterValue(java.lang.String)
Throws:
UnsupportedOperationException - when represented parameter type is ParameterWrapper.ParameterType.OTHER

parseParameterValue

public void parseParameterValue(String value)
Parse parameter value from a String.

Parameters:
value - String value. Note that null values are not allowed.
Throws:
IllegalArgumentException - when parse failed
UnsupportedOperationException - when represented parameter type is ParameterWrapper.ParameterType.OTHER

getIntValue

public int getIntValue()
Value of an int field.

Returns:
The value of the int field.
Throws:
UnsupportedOperationException - when the associated parameters type is different

setIntValue

public void setIntValue(int i)
Set int value of a int field.

Parameters:
i - Value to be set
Throws:
UnsupportedOperationException - when the associated parameters type is different

getDoubleValue

public double getDoubleValue()
Value of a double field.

Returns:
The value of the represented double field.
Throws:
UnsupportedOperationException - when the associated parameters type is different

setDoubleValue

public void setDoubleValue(double d)
Set value of a double field.

Parameters:
d - Value to be set
Throws:
UnsupportedOperationException - when the associated parameters type is different

isDoubleValid

public boolean isDoubleValid(double d)
Check if a value for a double field is valid.

Parameters:
d - Value
Returns:
true when the value is valid according to the validators
Throws:
UnsupportedOperationException - when the associated parameters type is different

getStringValue

public String getStringValue()
Value of a String field.

Returns:
The value of a String field.
Throws:
UnsupportedOperationException - when the associated parameters type is different

setStringValue

public void setStringValue(String s)
Set String value of a String field.

Parameters:
s - Value to be set
Throws:
UnsupportedOperationException - when the associated parameters type is different

getBooleanValue

public boolean getBooleanValue()
Value of a boolean field.

Returns:
The value of a boolean field.
Throws:
UnsupportedOperationException - when the associated parameters type is different

setBooleanValue

public void setBooleanValue(boolean b)
Set value of a boolean field.

Parameters:
b - Value to be set
Throws:
UnsupportedOperationException - when the associated parameters type is different

getParameterClass

public Class<?> getParameterClass()
Return enum class for enum field.

Returns:
Enum class for enum field

getEnumValue

public Enum getEnumValue()
Value of an enum field.

Returns:
The current value
Throws:
UnsupportedOperationException - when the associated parameters type is different

jklustor-all-api-0.0.7-20140619012755 (ChemAxon)