你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
DeviceTwinDevice Class
- java.
lang. Object - com.
microsoft. azure. sdk. iot. service. devicetwin. DeviceTwinDevice
- com.
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. |
Device |
getCapabilities()
Getter for capabilities. |
java.util.Map<java.lang.String,Configuration |
getConfigurations()
Getter for configuration properties. |
java.lang.String | getConnectionState() |
protected
Twin |
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
Twin |
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
Twin |
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
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:
Throws:
null
or empty
DeviceTwinDevice
public DeviceTwinDevice(String deviceId, String moduleId)
Constructor to create an instance for a module.
Parameters:
Throws:
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:
getCapabilities
public DeviceCapabilities getCapabilities()
Getter for capabilities.
Returns:
null
.getConfigurations
public Map
Getter for configuration properties.
Returns:
null
.getConnectionState
public String getConnectionState()
Returns:
getDesiredMap
protected TwinCollection getDesiredMap()
Getter for desired properties.
Returns:
getDesiredProperties
public Set
Getter to get the desired properties setter.
Returns:
getDesiredPropertiesVersion
public Integer getDesiredPropertiesVersion()
Getter for the desired properties version.
Returns:
Integer
with the desired properties collection version.getDeviceId
public String getDeviceId()
Getter to get the device Id.
Returns:
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:
getETag
public String getETag()
Getter for the ETag.
Returns:
null
if not set.getModelId
public String getModelId()
Getter for a model Id.
Returns:
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:
getParentScopes
public List
The scopes of the upper level edge devices if applicable. Only available for edge devices.
For more information, see this document.
Returns:
getReportedMap
protected TwinCollection getReportedMap()
Getter for reported properties.
Returns:
getReportedProperties
public Set
Getter to get reported properties setter.
Returns:
getReportedPropertiesVersion
public Integer getReportedPropertiesVersion()
Getter for the reported properties version.
Returns:
Integer
with the desired properties collection version.getTags
public Set
Getter for the twin tags.
Returns:
getTagsMap
protected TwinCollection getTagsMap()
Getter for tags.
Returns:
getTagsVersion
public Integer getTagsVersion()
Getter for the tag version.
Returns:
Integer
with the tags collection version.getVersion
public Integer getVersion()
Getter for the twin version.
Returns:
null
.reportedPropertiesToString
public String reportedPropertiesToString()
String representation for this device containing reported properties.'
Returns:
setCapabilities
protected void setCapabilities(DeviceCapabilities capabilities)
Setter for capabilities.
Parameters:
setConfigurations
protected void setConfigurations(Map
Setter for configuration properties.
Parameters:
setConnectionState
protected void setConnectionState(String connectionState)
Sets the connection state of the device.
Parameters:
setDesiredProperties
protected void setDesiredProperties(TwinCollection desiredProperties)
Setter for the desired properties.
Parameters:
setDesiredProperties
public void setDesiredProperties(Set
Setter for the desired properties.
Parameters:
Throws:
null
.
setDeviceScope
protected void setDeviceScope(String deviceScope)
Sets the device scope.
Parameters:
setETag
public void setETag(String eTag)
Setter for ETag.
Parameters:
Throws:
null
or empty.
setModelId
public void setModelId(String modelId)
Setter for a model Id
Parameters:
setParentScopes
protected void setParentScopes(List
Sets the parent scopes.
Parameters:
setReportedProperties
protected void setReportedProperties(TwinCollection reportedProperties)
Setter for the reported properties.
Parameters:
setTags
protected void setTags(TwinCollection tag)
Setter for tags.
Parameters:
setTags
public void setTags(Set
Setter for twin tags.
Parameters:
Throws:
null
.
tagsToString
public String tagsToString()
String representation for this device containing tags.
Returns:
toString
public String toString()
String representation for this device containing device Id, tags, desired and reported properties.
Overrides:
DeviceTwinDevice.toString()Returns: