-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove DigitalTwins WritableProperty, rewrite Basic classes to match …
….NET library (#16896)
- Loading branch information
1 parent
017a6c7
commit 25b1547
Showing
18 changed files
with
179 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...e/src/main/java/com/azure/digitaltwins/core/models/BasicDigitalTwinComponentMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.digitaltwins.core.models; | ||
|
||
import com.azure.core.annotation.Fluent; | ||
import com.fasterxml.jackson.annotation.JsonAnyGetter; | ||
import com.fasterxml.jackson.annotation.JsonAnySetter; | ||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* An optional, helper class for deserializing a digital twin component metadata object. This corresponds to the | ||
* {@link DigitalTwinsJsonPropertyNames#DIGITAL_TWIN_METADATA} property object on a {@link BasicDigitalTwinComponent} | ||
* <p> | ||
* Note that this class uses {@link 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 BasicDigitalTwinComponentMetadata class must | ||
* be constructed and have its json propertyMetadata tagged by the annotation used by that json library. | ||
*/ | ||
@Fluent | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public final class BasicDigitalTwinComponentMetadata { | ||
@JsonIgnore | ||
private final Map<String, Object> propertyMetadata = new HashMap<>(); | ||
|
||
/** | ||
* Gets the metadata about changes on properties on a component. The values can be deserialized into {@link BasicDigitalTwinPropertyMetadata} | ||
* @return The metadata about changes on properties on a component. | ||
*/ | ||
@JsonAnyGetter | ||
public Map<String, Object> getPropertyMetadata() { | ||
return propertyMetadata; | ||
} | ||
|
||
/** | ||
* Adds an additional custom property to the digital twin component. This field will contain any property | ||
* of the digital twin component that is not already defined by the other strong types of this class. | ||
* @param key The key of the additional property to be added to the digital twin. | ||
* @param value The value of the additional property to be added to the digital twin. | ||
* @return The BasicDigitalTwin object itself. | ||
*/ | ||
@JsonAnySetter | ||
public BasicDigitalTwinComponentMetadata addPropertyMetadata(String key, Object value) { | ||
this.propertyMetadata.put(key, value); | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...re/src/main/java/com/azure/digitaltwins/core/models/BasicDigitalTwinPropertyMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.digitaltwins.core.models; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.time.OffsetDateTime; | ||
|
||
/** | ||
* Contains metadata about changes on properties on a digital twin or component. | ||
*/ | ||
public class BasicDigitalTwinPropertyMetadata { | ||
@JsonProperty(value = DigitalTwinsJsonPropertyNames.METADATA_PROPERTY_LAST_UPDATE_TIME, required = true) | ||
private OffsetDateTime lastUpdatedOn; | ||
|
||
/** | ||
* Gets the date and time the property was last updated. | ||
* @return The date and time the property was last updated. | ||
*/ | ||
public OffsetDateTime getLastUpdatedOn() { | ||
return lastUpdatedOn; | ||
} | ||
|
||
/** | ||
* Sets the the date and time the property was last updated. | ||
* @param lastUpdatedOn The date and time the property was last updated. | ||
* @return The BasicDigitalTwinPropertyMetadata object itself. | ||
*/ | ||
public BasicDigitalTwinPropertyMetadata setLastUpdatedOn(OffsetDateTime lastUpdatedOn) { | ||
this.lastUpdatedOn = lastUpdatedOn; | ||
return this; | ||
} | ||
} |
60 changes: 0 additions & 60 deletions
60
...digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/ComponentMetadata.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.