T
- Data type of the attribute, must be one of the supported data types!public class CloudioAttribute<T>
extends java.lang.Object
class Switch extends ch.hevs.cloudio.endpoint.CloudioObject { @SetPoint public CloudioAttribute<boolean> state; @Status public CloudioAttribute<boolean> stateFeedback; }Attributes are annotated with one of these constraints:
StaticAttribute
annotation does not have to be of type Attribute, use rather native types
for static attributes.Modifier and Type | Method | Description |
---|---|---|
void |
addListener(CloudioAttributeListener listener) |
Adds the given listener to the list of listeners that will get informed about a change of the attribute.
|
java.lang.reflect.Type |
getType() |
Returns the actual type of the attribute.
|
T |
getValue() |
Returns the current value of the attribute.
|
void |
removeListener(CloudioAttributeListener listener) |
Removes the given listener from the list of listeners.
|
void |
setInitialValue(T initialValue) |
Tries to initialize the attribute with the given value.
|
void |
setStringValue(java.lang.String value) |
Tries to parse according to the type of the attribute the given string and sets the attribute's value to the
result of the parsing process.
|
void |
setStringValue(java.lang.String value,
long timestamp) |
Tries to parse according to the type of the attribute the given string and sets the attribute's value to the
result of the parsing process.
|
void |
setValue(T value) |
Tries to change the attribute to the given value.
|
void |
setValue(T value,
java.lang.Long timestamp) |
Tries to change the attribute to the given value and attributes the given timestamp to the new value.
|
public T getValue()
public void setValue(T value) throws CloudioAttributeConstraintException
value
- The new value for the attribute.CloudioAttributeConstraintException
- If the endpoint can not change the attribute.public void setValue(T value, java.lang.Long timestamp) throws CloudioAttributeConstraintException
value
- The new value for the attribute.timestamp
- The timestamp in milliseconds since epoch to link with the new value.CloudioAttributeConstraintException
- If the endpoint can not change the attribute.public void setInitialValue(T initialValue) throws CloudioAttributeConstraintException, CloudioAttributeInitializationException
initialValue
- The value to initialize the attribute with.CloudioAttributeConstraintException
- If the endpoint can not change the attribute.CloudioAttributeInitializationException
- If the attribute is already initialized or the node is already online.public void setStringValue(java.lang.String value) throws java.lang.NumberFormatException, CloudioAttributeConstraintException
value
- String representation of the value to set.java.lang.NumberFormatException
- In the case the attribute is a numeric data type and the parse failed.CloudioAttributeConstraintException
- If the endpoint can not change the attribute.public void setStringValue(java.lang.String value, long timestamp) throws java.lang.NumberFormatException, CloudioAttributeConstraintException
value
- String representation of the value to set.timestamp
- The timestamp in milliseconds since epoch to link with the new value.java.lang.NumberFormatException
- In the case the attribute is a numeric data type and the parse failed.CloudioAttributeConstraintException
- If the endpoint can not change the attribute.public java.lang.reflect.Type getType()
public void addListener(CloudioAttributeListener listener)
listener
- Reference to the object implementing the CloudioAttributeListener interface to add.public void removeListener(CloudioAttributeListener listener)
listener
- Reference to the object implementing the CloudioAttributeListener interface to remove.