Compartilhar via


DeviceTwinDevice Class

  • java.lang.Object
    • com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice

public class DeviceTwinDevice

The DeviceTwinDevice class represent the twin on iotHub. implementing constructors and serialization functionality. If object is a representation of the module twin if and only if the moduleId is set.

Constructor Summary

Constructor Description
DeviceTwinDevice()

Constructor to create instance for a device

DeviceTwinDevice(String deviceId)

Constructor to create instance for a device.

DeviceTwinDevice(String deviceId, String moduleId)

Constructor to create instance for a module.

Method Summary

Modifier and Type Method and Description
void clearDesiredProperties()

Clear desired properties set so far

void clearTags()

Clear tags set so far

void clearTwin()

Clear tags and desired properties set so far

java.lang.String desiredPropertiesToString()

String representation for this device containing desired properties

DeviceCapabilities getCapabilities()

Getter for capabilities

java.util.Map<java.lang.String,ConfigurationInfo> getConfigurations()

Getter for the configuration properties

java.lang.String getConnectionState()
protected TwinCollection getDesiredMap()

Getter for the desired properties

java.util.Set<Pair> getDesiredProperties()

Getter to get Desired Properties set

java.lang.Integer getDesiredPropertiesVersion()

Getter for the desired properties version.

java.lang.String getDeviceId()

Getter to get device ID

java.lang.String getETag()

Getter for the eTag

java.lang.String getModelId()
java.lang.String getModuleId()

Getter to get module ID

protected TwinCollection getReportedMap()

Getter for the reported properties

java.util.Set<Pair> getReportedProperties()

Getter to get Reported Properties Set

java.lang.Integer getReportedPropertiesVersion()

Getter for the reported properties version.

java.util.Set<Pair> getTags()

Getter to get Tags Set

protected TwinCollection getTagsMap()

Getter for the tags

java.lang.Integer getTagsVersion()

Getter for the tag version.

java.lang.Integer getVersion()

Getter for the Twin version

java.lang.String reportedPropertiesToString()

String representation for this device containing reported properties

protected void setCapabilities(DeviceCapabilities capabilities)

Setter for capabilities

protected void setConfigurations(Map<String,ConfigurationInfo> configurations)

Setter for the configuration properties

protected void setConnectionState(String connectionState)

Set the connection state of the device

void setDesiredProperties(Set<Pair> desiredProperties)

Setter for the desired properties

protected void setDesiredProperties(TwinCollection desiredProperties)

Setter for the desired properties

void setETag(String eTag)

Setter for ETag

void setModelId(String modelId)
protected void setReportedProperties(TwinCollection reportedProperties)

Setter for the reported properties

void setTags(Set<Pair> tags)

Setter for the tags

protected void setTags(TwinCollection tag)

Setter for the tags

java.lang.String tagsToString()

String representation for this device containing tags

java.lang.String toString()

String representation for this device containing device id, tags, desired and reported properties

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Constructor Details

DeviceTwinDevice

public DeviceTwinDevice()

Constructor to create instance for a device

DeviceTwinDevice

public DeviceTwinDevice(String deviceId)

Constructor to create instance for a device.

Parameters:

deviceId - Device ID for this device

Throws:

java.lang.IllegalArgumentException - This exception is thrown if the device id is null or empty

DeviceTwinDevice

public DeviceTwinDevice(String deviceId, String moduleId)

Constructor to create instance for a module.

Parameters:

deviceId - Device ID for the device which this module belongs to
moduleId - Module ID for this module

Throws:

java.lang.IllegalArgumentException - This exception is thrown if the device id is null or empty

Method Details

clearDesiredProperties

public void clearDesiredProperties()

Clear desired properties set so far

clearTags

public void clearTags()

Clear tags set so far

clearTwin

public void clearTwin()

Clear tags and desired properties set so far

desiredPropertiesToString

public String desiredPropertiesToString()

String representation for this device containing desired properties

Returns:

String representation for this device desired properties

getCapabilities

public DeviceCapabilities getCapabilities()

Getter for capabilities

Returns:

the value of the capabilities. It can be null.

getConfigurations

public Map<String,ConfigurationInfo> getConfigurations()

Getter for the configuration properties

Returns:

the configuration properties. It can be null.

getConnectionState

public String getConnectionState()

Returns:

get the connection state as last reported by the service

getDesiredMap

protected TwinCollection getDesiredMap()

Getter for the desired properties

Returns:

A map of validated key and value pairs for desired properties

getDesiredProperties

public Set<Pair> getDesiredProperties()

Getter to get Desired Properties set

Returns:

A set of desired property pairs.

getDesiredPropertiesVersion

public Integer getDesiredPropertiesVersion()

Getter for the desired properties version.

Returns:

The Integer with the Desired properties Collection version.

getDeviceId

public String getDeviceId()

Getter to get device ID

Returns:

device id for this device

getETag

public String getETag()

Getter for the eTag

Returns:

the stored eTag. It will be null if not set.

getModelId

public String getModelId()

getModuleId

public String getModuleId()

Getter to get module ID

Returns:

device id for this device

getReportedMap

protected TwinCollection getReportedMap()

Getter for the reported properties

Returns:

A map of validated key and value pairs for reported properties

getReportedProperties

public Set<Pair> getReportedProperties()

Getter to get Reported Properties Set

Returns:

A set of reported property pairs.

getReportedPropertiesVersion

public Integer getReportedPropertiesVersion()

Getter for the reported properties version.

Returns:

The Integer with the Desired properties Collection version.

getTags

public Set<Pair> getTags()

Getter to get Tags Set

Returns:

A set of tag key value pairs.

getTagsMap

protected TwinCollection getTagsMap()

Getter for the tags

Returns:

A map of validated key and value pairs for tag

getTagsVersion

public Integer getTagsVersion()

Getter for the tag version.

Returns:

The Integer with the Tags Collection version.

getVersion

public Integer getVersion()

Getter for the Twin version

Returns:

the stored version. It can be null.

reportedPropertiesToString

public String reportedPropertiesToString()

String representation for this device containing reported properties

Returns:

String representation for this device reported properties

setCapabilities

protected void setCapabilities(DeviceCapabilities capabilities)

Setter for capabilities

Parameters:

capabilities - is the value of the capabilities

setConfigurations

protected void setConfigurations(Map<String,ConfigurationInfo> configurations)

Setter for the configuration properties

Parameters:

configurations - is the configuration properties.

setConnectionState

protected void setConnectionState(String connectionState)

Set the connection state of the device

Parameters:

connectionState - the state to set

setDesiredProperties

public void setDesiredProperties(Set<Pair> desiredProperties)

Setter for the desired properties

Parameters:

desiredProperties - A set of key-value pairs for desired properties

Throws:

java.lang.IllegalArgumentException - This exception is thrown if the set is null

setDesiredProperties

protected void setDesiredProperties(TwinCollection desiredProperties)

Setter for the desired properties

Parameters:

desiredProperties - A map of validated key and value pairs for desired properties

setETag

public void setETag(String eTag)

Setter for ETag

Parameters:

eTag - is the value of the etag

Throws:

java.lang.IllegalArgumentException - if the provided etag is null or empty

setModelId

public void setModelId(String modelId)

Parameters:

modelId

setReportedProperties

protected void setReportedProperties(TwinCollection reportedProperties)

Setter for the reported properties

Parameters:

reportedProperties - A map of validated key and value pairs for reported properties

setTags

public void setTags(Set<Pair> tags)

Setter for the tags

Parameters:

tags - A set of tag key-value pairs

Throws:

java.lang.IllegalArgumentException - This exception is thrown if the set tags is null

setTags

protected void setTags(TwinCollection tag)

Setter for the tags

Parameters:

tag - A map of validated key and value pairs for tag

tagsToString

public String tagsToString()

String representation for this device containing tags

Returns:

String representation for this device tags

toString

public String toString()

String representation for this device containing device id, tags, desired and reported properties

Overrides:

DeviceTwinDevice.toString()

Returns:

String representation for this device

Applies to