BasicRelationship Class

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

public final class 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 JsonProperty from the Jackson serialization library. Because of this, this type will only work if the default json serializer is used by the digital twins client or if the custom json serializer uses Jackson as well. In order to use a different json library, a new BasicRelationship class must be constructed and have its json properties tagged by the annotation used by that json library.

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 an additional custom property to this model.

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.

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 an additional 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.

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

Applies to