TwinState Class

  • java.lang.Object
    • java.io.Serializable
      • Serializable
        • com.microsoft.azure.sdk.iot.provisioning.service.configs.TwinState

public class TwinState extends Serializable

Representation of a single Twin initial state for the Device Provisioning Service.

The TwinState can contain one TwinCollection of Tags, and one TwinCollection of properties.desired.

Each entity in the collections can contain a associated TwinMetadata.

These metadata are provided by the Service and contains information about the last updated date time, and version.

For instance, the following is a valid TwinState, represented as initialTwin 

</code> in the rest API. <pre><code>{

    "initialTwin": {

        "tags":{

            "SpeedUnity":"MPH",

            "$metadata":{

                "$lastUpdated":"2017-09-21T02:07:44.238Z",

                "$lastUpdatedVersion":4,

                "SpeedUnity":{

                    "$lastUpdated":"2017-09-21T02:07:44.238Z",

                    "$lastUpdatedVersion":4

                }

            },

            "$version":4

        }

        "properties":{

            "desired": {

                "MaxSpeed":{

                    "Value":500,

                    "NewValue":300

                },

                "$metadata":{

                    "$lastUpdated":"2017-09-21T02:07:44.238Z",

                    "$lastUpdatedVersion":4,

                    "MaxSpeed":{

                        "$lastUpdated":"2017-09-21T02:07:44.238Z",

                        "$lastUpdatedVersion":4,

                        "Value":{

                            "$lastUpdated":"2017-09-21T02:07:44.238Z",

                            "$lastUpdatedVersion":4

                        },

                        "NewValue":{

                            "$lastUpdated":"2017-09-21T02:07:44.238Z",

                            "$lastUpdatedVersion":4

                        }

                    }

                },

                "$version":4

            }

        }

    }

}

</code></pre></p>

Constructor Summary

Constructor Description
TwinState(TwinCollection tags, TwinCollection desiredProperty)

CONSTRUCTOR

This constructor creates an instance of the TwinState with the provided TwinCollection tags and desired properties.

When serialized, this class will looks like the following example:

"initialTwin": {
        "tags":{
            "SpeedUnity":"MPH",
            "$version":4
        }
        "properties":{
            "desired":{
                "MaxSpeed":{
                    "Value":500,
                    "NewValue":300
                },
                "$version":4
            }
        }
    }
     
    }

Method Summary

Modifier and Type Method and Description
TwinCollection getDesiredProperties()

Getter for the desired property.

String toString()

Creates a pretty print JSON with the content of this class and subclasses.

Inherited Members

Constructor Details

TwinState

public TwinState(TwinCollection tags, TwinCollection desiredProperty)

CONSTRUCTOR

This constructor creates an instance of the TwinState with the provided TwinCollection tags and desired properties.

When serialized, this class will looks like the following example:

"initialTwin": {
        "tags":{
            "SpeedUnity":"MPH",
            "$version":4
        }
        "properties":{
            "desired":{
                "MaxSpeed":{
                    "Value":500,
                    "NewValue":300
                },
                "$version":4
            }
        }
    }
     
    }

Parameters:

tags -

the TwinCollection with the initial tags state. It can benull 

</code> . </p>
desiredProperty -

the TwinCollection with the initial desired properties. It can benull 

</code> . </p>

Method Details

getDesiredProperties

public TwinCollection getDesiredProperties()

Getter for the desired property.

Returns:

TheTwinCollection 

</code> with the desired property content. It can be<code>null 

</code> . </p>

toString

public String toString()

Creates a pretty print JSON with the content of this class and subclasses.

Returns:

TheString 

</code> with the pretty print JSON. </p>

Applies to