Share via


BasicDigitalTwin Class

  • java.lang.Object
    • com.azure.digitaltwins.core.BasicDigitalTwin

Implements

public final class BasicDigitalTwin
implements JsonSerializable<BasicDigitalTwin>

An optional, helper class for deserializing a digital twin. Only properties with non-null values are included.

Note that this class uses JsonSerializable<T> from azure-json. Because of this, this type will work with any implementation of azure-json but support for generic objects is limited to what JsonWriter supports in JsonWriter#writeUntyped(Object). In order to support custom objects, a custom serializer must be used.

Constructor Summary

Constructor Description
BasicDigitalTwin(String digitalTwinId)

Construct a basic digital twin.

Method Summary

Modifier and Type Method and Description
BasicDigitalTwin addToContents(String key, Object value)

Adds a custom property to the digital twin contents.

static BasicDigitalTwin fromJson(JsonReader jsonReader)

Reads an instance of BasicDigitalTwin from the JsonReader.

Map<String,Object> getContents()

Gets the additional custom contents of the digital twin.

String getETag()

Gets a string representing a weak ETag for the entity that this request performs an operation against, as per RFC7232.

String getId()

Gets the unique ID of the digital twin in a digital twins instance.

OffsetDateTime getLastUpdatedOn()

Gets the date and time when the twin was last updated.

BasicDigitalTwinMetadata getMetadata()

Gets the information about the model a digital twin conforms to.

BasicDigitalTwin setETag(String etag)

Sets a string representing a weak ETag for the entity that this request performs an operation against, as per RFC7232.

BasicDigitalTwin setMetadata(BasicDigitalTwinMetadata metadata)

Sets the information about the model a digital twin conforms to.

JsonWriter toJson(JsonWriter jsonWriter)

Methods inherited from java.lang.Object

Constructor Details

BasicDigitalTwin

public BasicDigitalTwin(String digitalTwinId)

Construct a basic digital twin.

Parameters:

digitalTwinId - The ID of the digital twin. The Id is unique within the service and case-sensitive.

Method Details

addToContents

public BasicDigitalTwin addToContents(String key, Object value)

Adds a custom property to the digital twin contents. This field will contain any contents of the digital twin that are not already defined by the other strong types of this class.

Parameters:

key - The key of the additional property to be added to the digital twin.
value - The value of the additional property to be added to the digital twin.

Returns:

The BasicDigitalTwin object itself.

fromJson

public static BasicDigitalTwin fromJson(JsonReader jsonReader)

Reads an instance of BasicDigitalTwin from the JsonReader.

Parameters:

jsonReader - The JsonReader being read.

Returns:

An instance of BasicDigitalTwin if the JsonReader was pointing to an instance of it, or null if it was pointing to JSON null.

Throws:

IOException

- If an error occurs while reading the BasicDigitalTwin.

getContents

public Map<String,Object> getContents()

Gets the additional custom contents of the digital twin. This field will contain any contents of the digital twin that are not already defined by the other strong types of this class.

Returns:

The additional contents of the digital twin. This field will contain any contents of the digital twin that are not already defined by the other strong types of this class.

getETag

public String getETag()

Gets a string representing a weak ETag for the entity that this request performs an operation against, as per RFC7232.

Returns:

A string representing a weak ETag for the entity that this request performs an operation against, as per RFC7232.

getId

public String getId()

Gets the unique ID of the digital twin in a digital twins instance. This field is present on every digital twin.

Returns:

The unique ID of the digital twin in a digital twins instance. This field is present on every digital twin.

getLastUpdatedOn

public OffsetDateTime getLastUpdatedOn()

Gets the date and time when the twin was last updated.

Returns:

The date and time the twin was last updated.

getMetadata

public BasicDigitalTwinMetadata getMetadata()

Gets the information about the model a digital twin conforms to. This field is present on every digital twin.

Returns:

The information about the model a digital twin conforms to. This field is present on every digital twin.

setETag

public BasicDigitalTwin setETag(String etag)

Sets a string representing a weak ETag for the entity that this request performs an operation against, as per RFC7232.

Parameters:

etag - A string representing a weak ETag for the entity that this request performs an operation against, as per RFC7232.

Returns:

The BasicDigitalTwin object itself.

setMetadata

public BasicDigitalTwin setMetadata(BasicDigitalTwinMetadata metadata)

Sets the information about the model a digital twin conforms to. This field is present on every digital twin.

Parameters:

metadata - The information about the model a digital twin conforms to. This field is present on every digital twin.

Returns:

The BasicDigitalTwin object itself.

toJson

public JsonWriter toJson(JsonWriter jsonWriter)

Parameters:

jsonWriter

Throws:

Applies to