-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove DigitalTwins Writable property, rewrite Basic classes to match .NET #16896
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7cc1566
Remove DigitalTwins Writable property, rewrite Basic classes to match…
timtay-microsoft 868579b
fixup
timtay-microsoft 54cc263
add sample code for basic digital twin component
timtay-microsoft 8ffc558
fixup
timtay-microsoft 0cbdadd
fixup
timtay-microsoft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we decided to use
lastUpdatedOn
, I just wanted to say I thinklastUpdatedTime
might have been a better property name. goodbyeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly this is the name the service choose, so I'm not looking to change it.Scratch that, the service went with "lastUpdateTime" but Azure SDK team prefers we name like the above. We already renamed the digital twins model data class' date time field like this, so it should pass review