共用方式為


BasicRelationship Class

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

Implements

public final class BasicRelationship
implements JsonSerializable<BasicRelationship>

Although relationships have a user-defined schema, these properties should exist on every instance. This is useful to use as a base class to ensure your custom relationships have the necessary properties.

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
BasicRelationship(String relationshipId, String sourceDigitalTwinId, String targetDigitalTwinId, String relationshipName)

Construct a basic digital twin relationship.

Method Summary

Modifier and Type Method and Description
BasicRelationship addProperty(String key, Object value)

Adds a custom property to this model.

static BasicRelationship fromJson(JsonReader jsonReader)

Reads an instance of BasicRelationship from the JsonReader.

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 relationship.

String getName()

Gets the name of the relationship, which defines the type of link (e.g.

Map<String,Object> getProperties()

Gets the additional custom properties defined in the model.

String getSourceId()

Gets the unique ID of the source digital twin.

String getTargetId()

Gets the unique ID of the target digital twin.

BasicRelationship setETag(String etag)

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

JsonWriter toJson(JsonWriter jsonWriter)

Methods inherited from java.lang.Object

Constructor Details

BasicRelationship

public BasicRelationship(String relationshipId, String sourceDigitalTwinId, String targetDigitalTwinId, String relationshipName)

Construct a basic digital twin relationship.

Parameters:

relationshipId - The unique Id of this relationship.
sourceDigitalTwinId - The digital twin that this relationship comes from.
targetDigitalTwinId - The digital twin that this relationship points to.
relationshipName - The user defined name of this relationship, for instance "Contains" or "isAdjacentTo"

Method Details

addProperty

public BasicRelationship addProperty(String key, Object value)

Adds a custom property to this model. This field will contain any properties of the relationship 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 relationship.
value - The value of the additional property to be added to the relationship.

Returns:

The BasicRelationship object itself.

fromJson

public static BasicRelationship fromJson(JsonReader jsonReader)

Reads an instance of BasicRelationship from the JsonReader.

Parameters:

jsonReader - The JsonReader being read.

Returns:

An instance of BasicRelationship 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 BasicRelationship.

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 relationship. This field is present on every relationship.

Returns:

The unique ID of the relationship. This field is present on every relationship.

getName

public String getName()

Gets the name of the relationship, which defines the type of link (e.g. Contains). This field is present on every relationship.

Returns:

The name of the relationship, which defines the type of link (e.g. Contains). This field is present on every relationship.

getProperties

public Map<String,Object> getProperties()

Gets the additional custom properties defined in the model. This field will contain any properties of the relationship that are not already defined by the other strong types of this class.

Returns:

The additional custom properties defined in the model. This field will contain any properties of the relationship that are not already defined by the other strong types of this class.

getSourceId

public String getSourceId()

Gets the unique ID of the source digital twin. This field is present on every relationship.

Returns:

The unique ID of the source digital twin. This field is present on every relationship.

getTargetId

public String getTargetId()

Gets the unique ID of the target digital twin. This field is present on every relationship.

Returns:

The unique ID of the target digital twin. This field is present on every relationship.

setETag

public BasicRelationship 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 BasicRelationship object itself.

toJson

public JsonWriter toJson(JsonWriter jsonWriter)

Parameters:

jsonWriter

Throws:

Applies to