Dela via


DeviceTwinDevice Class

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

public class DeviceTwinDevice

Represent the twin on IoT hub. Implementing constructors and serialization functionality.

The object is a representation of a module twin if and only if the moduleId is set.

Constructor Summary

Constructor Description
DeviceTwinDevice()

Constructor to create an instance for a device.

DeviceTwinDevice(String deviceId)

Constructor to create instance for a device.

DeviceTwinDevice(String deviceId, String moduleId)

Constructor to create an instance for a module.

Method Summary

Modifier and Type Method and Description
void clearDesiredProperties()

Clears the desired properties set so far.

void clearTags()

Clears the 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 configuration properties.

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

Getter for desired properties.

java.util.Set<Pair> getDesiredProperties()

Getter to get the desired properties setter.

java.lang.Integer getDesiredPropertiesVersion()

Getter for the desired properties version.

java.lang.String getDeviceId()

Getter to get the device Id.

java.lang.String getDeviceScope()

The scope of the device.

java.lang.String getETag()

Getter for the ETag.

java.lang.String getModelId()

Getter for a model Id.

java.lang.String getModuleId()

Getter to get the module Id.

java.util.List<java.lang.String> getParentScopes()

The scopes of the upper level edge devices if applicable.

protected TwinCollection getReportedMap()

Getter for reported properties.

java.util.Set<Pair> getReportedProperties()

Getter to get reported properties setter.

java.lang.Integer getReportedPropertiesVersion()

Getter for the reported properties version.

java.util.Set<Pair> getTags()

Getter for the twin tags.

protected TwinCollection getTagsMap()

Getter for 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 configuration properties.

protected void setConnectionState(String connectionState)

Sets the connection state of the device.

protected void setDesiredProperties(TwinCollection desiredProperties)

Setter for the desired properties.

void setDesiredProperties(Set<Pair> desiredProperties)

Setter for the desired properties.

protected void setDeviceScope(String deviceScope)

Sets the device scope.

void setETag(String eTag)

Setter for ETag.

void setModelId(String modelId)

Setter for a model Id

protected void setParentScopes(List<String> parentScopes)

Sets the parent scopes.

protected void setReportedProperties(TwinCollection reportedProperties)

Setter for the reported properties.

protected void setTags(TwinCollection tag)

Setter for tags.

void setTags(Set<Pair> tags)

Setter for twin 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 an instance for a device.

DeviceTwinDevice

public DeviceTwinDevice(String deviceId)

Constructor to create instance for a device.

Parameters:

deviceId - 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 an instance for a module.

Parameters:

deviceId - Id for this device.
moduleId - Id for this device's module.

Throws:

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

Method Details

clearDesiredProperties

public void clearDesiredProperties()

Clears the desired properties set so far.

clearTags

public void clearTags()

Clears the 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 capabilities, which can be null.

getConfigurations

public Map getConfigurations()

Getter for configuration properties.

Returns:

The configuration properties which can be null.

getConnectionState

public String getConnectionState()

Returns:

Gets the connection state as last reported by the service.

getDesiredMap

protected TwinCollection getDesiredMap()

Getter for desired properties.

Returns:

A map of validated key/value pairs for desired properties.

getDesiredProperties

public Set getDesiredProperties()

Getter to get the desired properties setter.

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 the device Id.

Returns:

The Id for this device.

getDeviceScope

public String getDeviceScope()

The scope of the device. Auto-generated and immutable for edge devices and modifiable in leaf devices to create child/parent relationship.

For more information, see this document.

Returns:

The scope of the device. Auto-generated and immutable for edge devices and modifiable in leaf devices to create child/parent relationship.

getETag

public String getETag()

Getter for the ETag.

Returns:

The stored ETag. It will be null if not set.

getModelId

public String getModelId()

Getter for a model Id.

Returns:

The DTDL model Id of the device. The value will be null for a non-PnP device. The value will be null for a PnP device until the device connects and registers with a model Id.

getModuleId

public String getModuleId()

Getter to get the module Id.

Returns:

The Id for this module.

getParentScopes

public List getParentScopes()

The scopes of the upper level edge devices if applicable. Only available for edge devices.

For more information, see this document.

Returns:

The parent scopes edge and leaf devices, if applicable.

getReportedMap

protected TwinCollection getReportedMap()

Getter for reported properties.

Returns:

A map of validated key/value pairs for reported properties.

getReportedProperties

public Set getReportedProperties()

Getter to get reported properties setter.

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 getTags()

Getter for the twin tags.

Returns:

A set of tag key/value pairs.

getTagsMap

protected TwinCollection getTagsMap()

Getter for tags.

Returns:

A map of validated key/value pairs for tags.

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 - The value of capabilities.

setConfigurations

protected void setConfigurations(Map configurations)

Setter for configuration properties.

Parameters:

configurations - Is the configuration properties.

setConnectionState

protected void setConnectionState(String connectionState)

Sets the connection state of the device.

Parameters:

connectionState - The state to set.

setDesiredProperties

protected void setDesiredProperties(TwinCollection desiredProperties)

Setter for the desired properties.

Parameters:

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

setDesiredProperties

public void setDesiredProperties(Set 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.

setDeviceScope

protected void setDeviceScope(String deviceScope)

Sets the device scope.

Parameters:

deviceScope - The device scope to set.

setETag

public void setETag(String eTag)

Setter for ETag.

Parameters:

eTag - The value of the ETag.

Throws:

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

setModelId

public void setModelId(String modelId)

Setter for a model Id

Parameters:

modelId - is the DTDL model Id of the device.

setParentScopes

protected void setParentScopes(List parentScopes)

Sets the parent scopes.

Parameters:

parentScopes - The parent scopes.

setReportedProperties

protected void setReportedProperties(TwinCollection reportedProperties)

Setter for the reported properties.

Parameters:

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

setTags

protected void setTags(TwinCollection tag)

Setter for tags.

Parameters:

tag - A map of validated key/value pairs for tags.

setTags

public void setTags(Set tags)

Setter for twin tags.

Parameters:

tags - A set of tag key/value pairs.

Throws:

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

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