Package com.chemaxon.apidiscovery
Class ParameterWrapper
- java.lang.Object
-
- com.chemaxon.apidiscovery.ParameterWrapper
-
@Beta @PublicAPI 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ParameterWrapper.ParameterType
Wrapped parameter types.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getAPIFieldName()
API field name.boolean
getBooleanValue()
Value of a boolean field.Object
getCurrentValue()
Current value.Object
getCurrentValueOn(Object o)
Current value on a different object.String
getDetailedDescription()
Detailed description.double
getDoubleValue()
Value of a double field.Class<? extends Enum>
getEnumParameterClass()
Return enum class for enum field.Enum
getEnumValue()
Value of an enum field.int
getIntValue()
Value of an int field.long
getLongValue()
Value of an long field.com.google.common.base.Optional<Double>
getMaxDouble()
Largest possible floating point value for floating point fields.com.google.common.base.Optional<Long>
getMaxLong()
Largest possible fixed point value for fixed point fields.com.google.common.base.Optional<Double>
getMinDouble()
Smallest possible floating point value for floating point fields.com.google.common.base.Optional<Long>
getMinLong()
Smallest possible fixed point value for fixed point fields.String
getName()
Name.Class<?>
getParameterClass()
Parameter field class.String
getShortName()
Short name.String
getStringValue()
Value of a String field.ParameterWrapper.ParameterType
getType()
Type.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
setLongValue(long i)
Set long value of a long 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.
-
-
-
Method Detail
-
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
-
getMinDouble
public com.google.common.base.Optional<Double> getMinDouble()
Smallest possible floating point value for floating point fields.- Returns:
- smallest possible floating point value if specified
-
getMaxDouble
public com.google.common.base.Optional<Double> getMaxDouble()
Largest possible floating point value for floating point fields.- Returns:
- largest possible floating point value if specified
-
getMinLong
public com.google.common.base.Optional<Long> getMinLong()
Smallest possible fixed point value for fixed point fields.- Returns:
- smallest possible fixed point value if specified
-
getMaxLong
public com.google.common.base.Optional<Long> getMaxLong()
Largest possible fixed point value for fixed point fields.- Returns:
- largest possible fixed point value if specified
-
getCurrentValue
public Object getCurrentValue()
Current value.- Returns:
- The current value of the represented parameter
-
getCurrentValueOn
public Object getCurrentValueOn(Object o)
Current value on a different object.- Parameters:
o
- Object to use to get the value- Returns:
- The current value of the represented parameter on a different objetc
-
setValue
public void setValue(Object o)
Set value.- Parameters:
o
- Value to set. Type must match represented parameter type. Note that settingnull
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 itsObject.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 isParameterWrapper.ParameterType.OTHER
-
parseParameterValue
public void parseParameterValue(String value)
Parse parameter value from a String.- Parameters:
value
- String value. Note thatnull
values are not allowed.- Throws:
IllegalArgumentException
- when parse failedUnsupportedOperationException
- when represented parameter type isParameterWrapper.ParameterType.OTHER
-
getLongValue
public long getLongValue()
Value of an long field.- Returns:
- The value of the long field.
- Throws:
UnsupportedOperationException
- when the associated parameters type is different
-
setLongValue
public void setLongValue(long i)
Set long value of a long field.- Parameters:
i
- Value to be set- Throws:
UnsupportedOperationException
- when the associated parameters type is different
-
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
-
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()
Parameter field class.- Returns:
- Parameter field class
-
getEnumParameterClass
public Class<? extends Enum> getEnumParameterClass()
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
-
-