diff --git a/sdk/face/azure-ai-vision-face/pom.xml b/sdk/face/azure-ai-vision-face/pom.xml index 8edc53f9c4a54..5a776ae571c34 100644 --- a/sdk/face/azure-ai-vision-face/pom.xml +++ b/sdk/face/azure-ai-vision-face/pom.xml @@ -57,6 +57,11 @@ azure-core-http-netty 1.15.2 + + com.azure + azure-json + 1.1.0 + org.junit.jupiter junit-jupiter-api diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/implementation/models/DetectFromUrlImplRequest.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/implementation/models/DetectFromUrlImplRequest.java index 31e40f3b12d4c..7344c38258789 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/implementation/models/DetectFromUrlImplRequest.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/implementation/models/DetectFromUrlImplRequest.java @@ -5,20 +5,22 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * The DetectFromUrlImplRequest model. */ @Immutable -public final class DetectFromUrlImplRequest { +public final class DetectFromUrlImplRequest implements JsonSerializable { /* * URL of input image. */ @Generated - @JsonProperty(value = "url") private final String url; /** @@ -27,8 +29,7 @@ public final class DetectFromUrlImplRequest { * @param url the url value to set. */ @Generated - @JsonCreator - public DetectFromUrlImplRequest(@JsonProperty(value = "url") String url) { + public DetectFromUrlImplRequest(String url) { this.url = url; } @@ -41,4 +42,41 @@ public DetectFromUrlImplRequest(@JsonProperty(value = "url") String url) { public String getUrl() { return this.url; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("url", this.url); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DetectFromUrlImplRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DetectFromUrlImplRequest if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the DetectFromUrlImplRequest. + */ + @Generated + public static DetectFromUrlImplRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String url = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("url".equals(fieldName)) { + url = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new DetectFromUrlImplRequest(url); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/implementation/models/FindSimilarRequest.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/implementation/models/FindSimilarRequest.java index c32af80a79ffa..3269866e751a8 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/implementation/models/FindSimilarRequest.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/implementation/models/FindSimilarRequest.java @@ -6,36 +6,36 @@ import com.azure.ai.vision.face.models.FindSimilarMatchMode; import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; import java.util.List; /** * The FindSimilarRequest model. */ @Fluent -public final class FindSimilarRequest { +public final class FindSimilarRequest implements JsonSerializable { /* * faceId of the query face. User needs to call "Detect" first to get a valid faceId. Note that this faceId is not * persisted and will expire 24 hours after the detection call. */ @Generated - @JsonProperty(value = "faceId") private final String faceId; /* * The number of top similar faces returned. The valid range is [1, 1000]. Default value is 20. */ @Generated - @JsonProperty(value = "maxNumOfCandidatesReturned") private Integer maxNumOfCandidatesReturned; /* * Similar face searching mode. It can be 'matchPerson' or 'matchFace'. Default value is 'matchPerson'. */ @Generated - @JsonProperty(value = "mode") private FindSimilarMatchMode mode; /* @@ -43,7 +43,6 @@ public final class FindSimilarRequest { * detection call. The number of faceIds is limited to 1000. */ @Generated - @JsonProperty(value = "faceIds") private final List faceIds; /** @@ -53,9 +52,7 @@ public final class FindSimilarRequest { * @param faceIds the faceIds value to set. */ @Generated - @JsonCreator - public FindSimilarRequest(@JsonProperty(value = "faceId") String faceId, - @JsonProperty(value = "faceIds") List faceIds) { + public FindSimilarRequest(String faceId, List faceIds) { this.faceId = faceId; this.faceIds = faceIds; } @@ -129,4 +126,56 @@ public FindSimilarRequest setMode(FindSimilarMatchMode mode) { public List getFaceIds() { return this.faceIds; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("faceId", this.faceId); + jsonWriter.writeArrayField("faceIds", this.faceIds, (writer, element) -> writer.writeString(element)); + jsonWriter.writeNumberField("maxNumOfCandidatesReturned", this.maxNumOfCandidatesReturned); + jsonWriter.writeStringField("mode", this.mode == null ? null : this.mode.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FindSimilarRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FindSimilarRequest if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FindSimilarRequest. + */ + @Generated + public static FindSimilarRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String faceId = null; + List faceIds = null; + Integer maxNumOfCandidatesReturned = null; + FindSimilarMatchMode mode = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("faceId".equals(fieldName)) { + faceId = reader.getString(); + } else if ("faceIds".equals(fieldName)) { + faceIds = reader.readArray(reader1 -> reader1.getString()); + } else if ("maxNumOfCandidatesReturned".equals(fieldName)) { + maxNumOfCandidatesReturned = reader.getNullable(JsonReader::getInt); + } else if ("mode".equals(fieldName)) { + mode = FindSimilarMatchMode.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + FindSimilarRequest deserializedFindSimilarRequest = new FindSimilarRequest(faceId, faceIds); + deserializedFindSimilarRequest.maxNumOfCandidatesReturned = maxNumOfCandidatesReturned; + deserializedFindSimilarRequest.mode = mode; + return deserializedFindSimilarRequest; + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/implementation/models/GroupRequest.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/implementation/models/GroupRequest.java index c43fdd83bc21b..d7201dfa8dc2b 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/implementation/models/GroupRequest.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/implementation/models/GroupRequest.java @@ -5,21 +5,23 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; import java.util.List; /** * The GroupRequest model. */ @Immutable -public final class GroupRequest { +public final class GroupRequest implements JsonSerializable { /* * Array of candidate faceIds created by "Detect". The maximum is 1000 faces. */ @Generated - @JsonProperty(value = "faceIds") private final List faceIds; /** @@ -28,8 +30,7 @@ public final class GroupRequest { * @param faceIds the faceIds value to set. */ @Generated - @JsonCreator - public GroupRequest(@JsonProperty(value = "faceIds") List faceIds) { + public GroupRequest(List faceIds) { this.faceIds = faceIds; } @@ -42,4 +43,41 @@ public GroupRequest(@JsonProperty(value = "faceIds") List faceIds) { public List getFaceIds() { return this.faceIds; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("faceIds", this.faceIds, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GroupRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GroupRequest if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the GroupRequest. + */ + @Generated + public static GroupRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List faceIds = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("faceIds".equals(fieldName)) { + faceIds = reader.readArray(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + return new GroupRequest(faceIds); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/implementation/models/VerifyFaceToFaceRequest.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/implementation/models/VerifyFaceToFaceRequest.java index 744e26d10f7b4..2c8cca77a4815 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/implementation/models/VerifyFaceToFaceRequest.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/implementation/models/VerifyFaceToFaceRequest.java @@ -5,27 +5,28 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * The VerifyFaceToFaceRequest model. */ @Immutable -public final class VerifyFaceToFaceRequest { +public final class VerifyFaceToFaceRequest implements JsonSerializable { /* * The faceId of one face, come from "Detect". */ @Generated - @JsonProperty(value = "faceId1") private final String faceId1; /* * The faceId of another face, come from "Detect". */ @Generated - @JsonProperty(value = "faceId2") private final String faceId2; /** @@ -35,9 +36,7 @@ public final class VerifyFaceToFaceRequest { * @param faceId2 the faceId2 value to set. */ @Generated - @JsonCreator - public VerifyFaceToFaceRequest(@JsonProperty(value = "faceId1") String faceId1, - @JsonProperty(value = "faceId2") String faceId2) { + public VerifyFaceToFaceRequest(String faceId1, String faceId2) { this.faceId1 = faceId1; this.faceId2 = faceId2; } @@ -61,4 +60,45 @@ public String getFaceId1() { public String getFaceId2() { return this.faceId2; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("faceId1", this.faceId1); + jsonWriter.writeStringField("faceId2", this.faceId2); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VerifyFaceToFaceRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VerifyFaceToFaceRequest if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the VerifyFaceToFaceRequest. + */ + @Generated + public static VerifyFaceToFaceRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String faceId1 = null; + String faceId2 = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("faceId1".equals(fieldName)) { + faceId1 = reader.getString(); + } else if ("faceId2".equals(fieldName)) { + faceId2 = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new VerifyFaceToFaceRequest(faceId1, faceId2); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/AccessoryItem.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/AccessoryItem.java index be2990dda6ec0..f305fbbf1ebdb 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/AccessoryItem.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/AccessoryItem.java @@ -5,27 +5,28 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * Accessory item and corresponding confidence level. */ @Immutable -public final class AccessoryItem { +public final class AccessoryItem implements JsonSerializable { /* * Type of the accessory. */ @Generated - @JsonProperty(value = "type") private final AccessoryType type; /* * Confidence level of the accessory type. Range between [0,1]. */ @Generated - @JsonProperty(value = "confidence") private final double confidence; /** @@ -35,9 +36,7 @@ public final class AccessoryItem { * @param confidence the confidence value to set. */ @Generated - @JsonCreator - private AccessoryItem(@JsonProperty(value = "type") AccessoryType type, - @JsonProperty(value = "confidence") double confidence) { + private AccessoryItem(AccessoryType type, double confidence) { this.type = type; this.confidence = confidence; } @@ -61,4 +60,45 @@ public AccessoryType getType() { public double getConfidence() { return this.confidence; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeDoubleField("confidence", this.confidence); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AccessoryItem from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AccessoryItem if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AccessoryItem. + */ + @Generated + public static AccessoryItem fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AccessoryType type = null; + double confidence = 0.0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + type = AccessoryType.fromString(reader.getString()); + } else if ("confidence".equals(fieldName)) { + confidence = reader.getDouble(); + } else { + reader.skipChildren(); + } + } + return new AccessoryItem(type, confidence); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/AccessoryType.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/AccessoryType.java index 064ae64a0f967..7f6435f26c3d2 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/AccessoryType.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/AccessoryType.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -48,7 +47,6 @@ public AccessoryType() { * @return the corresponding AccessoryType. */ @Generated - @JsonCreator public static AccessoryType fromString(String name) { return fromString(name, AccessoryType.class); } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/AuditLivenessResponseInfo.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/AuditLivenessResponseInfo.java index a74b744957897..5baa92df06c07 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/AuditLivenessResponseInfo.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/AuditLivenessResponseInfo.java @@ -5,34 +5,34 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * Audit entry for a response in the session. */ @Immutable -public final class AuditLivenessResponseInfo { +public final class AuditLivenessResponseInfo implements JsonSerializable { /* * The response body. The schema of this field will depend on the request.url and request.method used by the client. */ @Generated - @JsonProperty(value = "body") private final LivenessResponseBody body; /* * The HTTP status code returned to the client. */ @Generated - @JsonProperty(value = "statusCode") private final int statusCode; /* * The server measured latency for this request in milliseconds. */ @Generated - @JsonProperty(value = "latencyInMilliseconds") private final long latencyInMilliseconds; /** @@ -43,10 +43,7 @@ public final class AuditLivenessResponseInfo { * @param latencyInMilliseconds the latencyInMilliseconds value to set. */ @Generated - @JsonCreator - private AuditLivenessResponseInfo(@JsonProperty(value = "body") LivenessResponseBody body, - @JsonProperty(value = "statusCode") int statusCode, - @JsonProperty(value = "latencyInMilliseconds") long latencyInMilliseconds) { + private AuditLivenessResponseInfo(LivenessResponseBody body, int statusCode, long latencyInMilliseconds) { this.body = body; this.statusCode = statusCode; this.latencyInMilliseconds = latencyInMilliseconds; @@ -82,4 +79,49 @@ public int getStatusCode() { public long getLatencyInMilliseconds() { return this.latencyInMilliseconds; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("body", this.body); + jsonWriter.writeIntField("statusCode", this.statusCode); + jsonWriter.writeLongField("latencyInMilliseconds", this.latencyInMilliseconds); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AuditLivenessResponseInfo from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AuditLivenessResponseInfo if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AuditLivenessResponseInfo. + */ + @Generated + public static AuditLivenessResponseInfo fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + LivenessResponseBody body = null; + int statusCode = 0; + long latencyInMilliseconds = 0L; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("body".equals(fieldName)) { + body = LivenessResponseBody.fromJson(reader); + } else if ("statusCode".equals(fieldName)) { + statusCode = reader.getInt(); + } else if ("latencyInMilliseconds".equals(fieldName)) { + latencyInMilliseconds = reader.getLong(); + } else { + reader.skipChildren(); + } + } + return new AuditLivenessResponseInfo(body, statusCode, latencyInMilliseconds); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/AuditRequestInfo.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/AuditRequestInfo.java index a23766fa70411..b01607537f25b 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/AuditRequestInfo.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/AuditRequestInfo.java @@ -5,48 +5,46 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * Audit entry for a request in the session. */ @Immutable -public final class AuditRequestInfo { +public final class AuditRequestInfo implements JsonSerializable { /* * The relative URL and query of the liveness request. */ @Generated - @JsonProperty(value = "url") private final String url; /* * The HTTP method of the request (i.e., GET, POST, DELETE). */ @Generated - @JsonProperty(value = "method") private final String method; /* * The length of the request body in bytes. */ @Generated - @JsonProperty(value = "contentLength") private Long contentLength; /* * The content type of the request. */ @Generated - @JsonProperty(value = "contentType") private final String contentType; /* * The user agent used to submit the request. */ @Generated - @JsonProperty(value = "userAgent") private String userAgent; /** @@ -57,9 +55,7 @@ public final class AuditRequestInfo { * @param contentType the contentType value to set. */ @Generated - @JsonCreator - private AuditRequestInfo(@JsonProperty(value = "url") String url, @JsonProperty(value = "method") String method, - @JsonProperty(value = "contentType") String contentType) { + private AuditRequestInfo(String url, String method, String contentType) { this.url = url; this.method = method; this.contentType = contentType; @@ -114,4 +110,60 @@ public String getContentType() { public String getUserAgent() { return this.userAgent; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("url", this.url); + jsonWriter.writeStringField("method", this.method); + jsonWriter.writeStringField("contentType", this.contentType); + jsonWriter.writeNumberField("contentLength", this.contentLength); + jsonWriter.writeStringField("userAgent", this.userAgent); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AuditRequestInfo from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AuditRequestInfo if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AuditRequestInfo. + */ + @Generated + public static AuditRequestInfo fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String url = null; + String method = null; + String contentType = null; + Long contentLength = null; + String userAgent = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("url".equals(fieldName)) { + url = reader.getString(); + } else if ("method".equals(fieldName)) { + method = reader.getString(); + } else if ("contentType".equals(fieldName)) { + contentType = reader.getString(); + } else if ("contentLength".equals(fieldName)) { + contentLength = reader.getNullable(JsonReader::getLong); + } else if ("userAgent".equals(fieldName)) { + userAgent = reader.getString(); + } else { + reader.skipChildren(); + } + } + AuditRequestInfo deserializedAuditRequestInfo = new AuditRequestInfo(url, method, contentType); + deserializedAuditRequestInfo.contentLength = contentLength; + deserializedAuditRequestInfo.userAgent = userAgent; + return deserializedAuditRequestInfo; + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/BlurLevel.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/BlurLevel.java index aed8e3575ae82..3ab21aa5c9220 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/BlurLevel.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/BlurLevel.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -48,7 +47,6 @@ public BlurLevel() { * @return the corresponding BlurLevel. */ @Generated - @JsonCreator public static BlurLevel fromString(String name) { return fromString(name, BlurLevel.class); } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/BlurProperties.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/BlurProperties.java index fd3809491d1f8..a597d33066e0d 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/BlurProperties.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/BlurProperties.java @@ -5,27 +5,28 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * Properties describing any presence of blur within the image. */ @Immutable -public final class BlurProperties { +public final class BlurProperties implements JsonSerializable { /* * An enum value indicating level of blurriness. */ @Generated - @JsonProperty(value = "blurLevel") private final BlurLevel blurLevel; /* * A number indicating level of blurriness ranging from 0 to 1. */ @Generated - @JsonProperty(value = "value") private final double value; /** @@ -35,9 +36,7 @@ public final class BlurProperties { * @param value the value value to set. */ @Generated - @JsonCreator - private BlurProperties(@JsonProperty(value = "blurLevel") BlurLevel blurLevel, - @JsonProperty(value = "value") double value) { + private BlurProperties(BlurLevel blurLevel, double value) { this.blurLevel = blurLevel; this.value = value; } @@ -61,4 +60,45 @@ public BlurLevel getBlurLevel() { public double getValue() { return this.value; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("blurLevel", this.blurLevel == null ? null : this.blurLevel.toString()); + jsonWriter.writeDoubleField("value", this.value); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BlurProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BlurProperties if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the BlurProperties. + */ + @Generated + public static BlurProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BlurLevel blurLevel = null; + double value = 0.0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("blurLevel".equals(fieldName)) { + blurLevel = BlurLevel.fromString(reader.getString()); + } else if ("value".equals(fieldName)) { + value = reader.getDouble(); + } else { + reader.skipChildren(); + } + } + return new BlurProperties(blurLevel, value); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/CreateLivenessSessionContent.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/CreateLivenessSessionContent.java index 6d4b7eaf75cf8..82557fe066c7d 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/CreateLivenessSessionContent.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/CreateLivenessSessionContent.java @@ -5,20 +5,22 @@ import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * Request for creating liveness session. */ @Fluent -public final class CreateLivenessSessionContent { +public final class CreateLivenessSessionContent implements JsonSerializable { /* * Type of liveness mode the client should follow. */ @Generated - @JsonProperty(value = "livenessOperationMode") private final LivenessOperationMode livenessOperationMode; /* @@ -28,7 +30,6 @@ public final class CreateLivenessSessionContent { * implemented. */ @Generated - @JsonProperty(value = "sendResultsToClient") private Boolean sendResultsToClient; /* @@ -36,7 +37,6 @@ public final class CreateLivenessSessionContent { * 'deviceCorrelationId' must be set in this request body. */ @Generated - @JsonProperty(value = "deviceCorrelationIdSetInClient") private Boolean deviceCorrelationIdSetInClient; /* @@ -44,14 +44,12 @@ public final class CreateLivenessSessionContent { * 'deviceCorrelationIdSetInClient' is true in this request, this 'deviceCorrelationId' must be null. */ @Generated - @JsonProperty(value = "deviceCorrelationId") private String deviceCorrelationId; /* * Seconds the session should last for. Range is 60 to 86400 seconds. Default value is 600. */ @Generated - @JsonProperty(value = "authTokenTimeToLiveInSeconds") private Integer authTokenTimeToLiveInSeconds; /** @@ -60,9 +58,7 @@ public final class CreateLivenessSessionContent { * @param livenessOperationMode the livenessOperationMode value to set. */ @Generated - @JsonCreator - public CreateLivenessSessionContent( - @JsonProperty(value = "livenessOperationMode") LivenessOperationMode livenessOperationMode) { + public CreateLivenessSessionContent(LivenessOperationMode livenessOperationMode) { this.livenessOperationMode = livenessOperationMode; } @@ -179,4 +175,64 @@ public CreateLivenessSessionContent setAuthTokenTimeToLiveInSeconds(Integer auth this.authTokenTimeToLiveInSeconds = authTokenTimeToLiveInSeconds; return this; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("livenessOperationMode", + this.livenessOperationMode == null ? null : this.livenessOperationMode.toString()); + jsonWriter.writeBooleanField("sendResultsToClient", this.sendResultsToClient); + jsonWriter.writeBooleanField("deviceCorrelationIdSetInClient", this.deviceCorrelationIdSetInClient); + jsonWriter.writeStringField("deviceCorrelationId", this.deviceCorrelationId); + jsonWriter.writeNumberField("authTokenTimeToLiveInSeconds", this.authTokenTimeToLiveInSeconds); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CreateLivenessSessionContent from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CreateLivenessSessionContent if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the CreateLivenessSessionContent. + */ + @Generated + public static CreateLivenessSessionContent fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + LivenessOperationMode livenessOperationMode = null; + Boolean sendResultsToClient = null; + Boolean deviceCorrelationIdSetInClient = null; + String deviceCorrelationId = null; + Integer authTokenTimeToLiveInSeconds = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("livenessOperationMode".equals(fieldName)) { + livenessOperationMode = LivenessOperationMode.fromString(reader.getString()); + } else if ("sendResultsToClient".equals(fieldName)) { + sendResultsToClient = reader.getNullable(JsonReader::getBoolean); + } else if ("deviceCorrelationIdSetInClient".equals(fieldName)) { + deviceCorrelationIdSetInClient = reader.getNullable(JsonReader::getBoolean); + } else if ("deviceCorrelationId".equals(fieldName)) { + deviceCorrelationId = reader.getString(); + } else if ("authTokenTimeToLiveInSeconds".equals(fieldName)) { + authTokenTimeToLiveInSeconds = reader.getNullable(JsonReader::getInt); + } else { + reader.skipChildren(); + } + } + CreateLivenessSessionContent deserializedCreateLivenessSessionContent + = new CreateLivenessSessionContent(livenessOperationMode); + deserializedCreateLivenessSessionContent.sendResultsToClient = sendResultsToClient; + deserializedCreateLivenessSessionContent.deviceCorrelationIdSetInClient = deviceCorrelationIdSetInClient; + deserializedCreateLivenessSessionContent.deviceCorrelationId = deviceCorrelationId; + deserializedCreateLivenessSessionContent.authTokenTimeToLiveInSeconds = authTokenTimeToLiveInSeconds; + return deserializedCreateLivenessSessionContent; + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/CreateLivenessSessionResult.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/CreateLivenessSessionResult.java index 4abdb4146b604..1b410ca784455 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/CreateLivenessSessionResult.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/CreateLivenessSessionResult.java @@ -5,21 +5,23 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * Response of liveness session creation. */ @Immutable -public final class CreateLivenessSessionResult { +public final class CreateLivenessSessionResult implements JsonSerializable { /* * The unique session ID of the created session. It will expire 48 hours after it was created or may be deleted * sooner using the corresponding Session DELETE operation. */ @Generated - @JsonProperty(value = "sessionId") private final String sessionId; /* @@ -27,7 +29,6 @@ public final class CreateLivenessSessionResult { * limited permissions to perform only the required action and expires after the TTL time. It is also auditable. */ @Generated - @JsonProperty(value = "authToken") private final String authToken; /** @@ -37,9 +38,7 @@ public final class CreateLivenessSessionResult { * @param authToken the authToken value to set. */ @Generated - @JsonCreator - private CreateLivenessSessionResult(@JsonProperty(value = "sessionId") String sessionId, - @JsonProperty(value = "authToken") String authToken) { + private CreateLivenessSessionResult(String sessionId, String authToken) { this.sessionId = sessionId; this.authToken = authToken; } @@ -66,4 +65,45 @@ public String getSessionId() { public String getAuthToken() { return this.authToken; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("sessionId", this.sessionId); + jsonWriter.writeStringField("authToken", this.authToken); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CreateLivenessSessionResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CreateLivenessSessionResult if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the CreateLivenessSessionResult. + */ + @Generated + public static CreateLivenessSessionResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String sessionId = null; + String authToken = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("sessionId".equals(fieldName)) { + sessionId = reader.getString(); + } else if ("authToken".equals(fieldName)) { + authToken = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new CreateLivenessSessionResult(sessionId, authToken); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/CreateLivenessWithVerifySessionResult.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/CreateLivenessWithVerifySessionResult.java index e2e7308243d17..2dd365aefc33c 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/CreateLivenessWithVerifySessionResult.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/CreateLivenessWithVerifySessionResult.java @@ -5,21 +5,24 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * Response of liveness session with verify creation with verify image provided. */ @Immutable -public final class CreateLivenessWithVerifySessionResult { +public final class CreateLivenessWithVerifySessionResult + implements JsonSerializable { /* * The unique session ID of the created session. It will expire 48 hours after it was created or may be deleted * sooner using the corresponding Session DELETE operation. */ @Generated - @JsonProperty(value = "sessionId") private final String sessionId; /* @@ -27,14 +30,12 @@ public final class CreateLivenessWithVerifySessionResult { * limited permissions to perform only the required action and expires after the TTL time. It is also auditable. */ @Generated - @JsonProperty(value = "authToken") private final String authToken; /* * The detail of face for verification. */ @Generated - @JsonProperty(value = "verifyImage") private LivenessWithVerifyImage verifyImage; /** @@ -44,9 +45,7 @@ public final class CreateLivenessWithVerifySessionResult { * @param authToken the authToken value to set. */ @Generated - @JsonCreator - private CreateLivenessWithVerifySessionResult(@JsonProperty(value = "sessionId") String sessionId, - @JsonProperty(value = "authToken") String authToken) { + private CreateLivenessWithVerifySessionResult(String sessionId, String authToken) { this.sessionId = sessionId; this.authToken = authToken; } @@ -83,4 +82,52 @@ public String getAuthToken() { public LivenessWithVerifyImage getVerifyImage() { return this.verifyImage; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("sessionId", this.sessionId); + jsonWriter.writeStringField("authToken", this.authToken); + jsonWriter.writeJsonField("verifyImage", this.verifyImage); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CreateLivenessWithVerifySessionResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CreateLivenessWithVerifySessionResult if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the CreateLivenessWithVerifySessionResult. + */ + @Generated + public static CreateLivenessWithVerifySessionResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String sessionId = null; + String authToken = null; + LivenessWithVerifyImage verifyImage = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("sessionId".equals(fieldName)) { + sessionId = reader.getString(); + } else if ("authToken".equals(fieldName)) { + authToken = reader.getString(); + } else if ("verifyImage".equals(fieldName)) { + verifyImage = LivenessWithVerifyImage.fromJson(reader); + } else { + reader.skipChildren(); + } + } + CreateLivenessWithVerifySessionResult deserializedCreateLivenessWithVerifySessionResult + = new CreateLivenessWithVerifySessionResult(sessionId, authToken); + deserializedCreateLivenessWithVerifySessionResult.verifyImage = verifyImage; + return deserializedCreateLivenessWithVerifySessionResult; + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/ExposureLevel.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/ExposureLevel.java index 7a0617b5da6c9..1207dd37c2923 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/ExposureLevel.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/ExposureLevel.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -48,7 +47,6 @@ public ExposureLevel() { * @return the corresponding ExposureLevel. */ @Generated - @JsonCreator public static ExposureLevel fromString(String name) { return fromString(name, ExposureLevel.class); } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/ExposureProperties.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/ExposureProperties.java index 6ec04e73035e2..35df66576eacc 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/ExposureProperties.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/ExposureProperties.java @@ -5,20 +5,22 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * Properties describing exposure level of the image. */ @Immutable -public final class ExposureProperties { +public final class ExposureProperties implements JsonSerializable { /* * An enum value indicating level of exposure. */ @Generated - @JsonProperty(value = "exposureLevel") private final ExposureLevel exposureLevel; /* @@ -26,7 +28,6 @@ public final class ExposureProperties { * good exposure. [0.75, 1] is over exposure. */ @Generated - @JsonProperty(value = "value") private final double value; /** @@ -36,9 +37,7 @@ public final class ExposureProperties { * @param value the value value to set. */ @Generated - @JsonCreator - private ExposureProperties(@JsonProperty(value = "exposureLevel") ExposureLevel exposureLevel, - @JsonProperty(value = "value") double value) { + private ExposureProperties(ExposureLevel exposureLevel, double value) { this.exposureLevel = exposureLevel; this.value = value; } @@ -63,4 +62,45 @@ public ExposureLevel getExposureLevel() { public double getValue() { return this.value; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("exposureLevel", this.exposureLevel == null ? null : this.exposureLevel.toString()); + jsonWriter.writeDoubleField("value", this.value); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExposureProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExposureProperties if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ExposureProperties. + */ + @Generated + public static ExposureProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ExposureLevel exposureLevel = null; + double value = 0.0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("exposureLevel".equals(fieldName)) { + exposureLevel = ExposureLevel.fromString(reader.getString()); + } else if ("value".equals(fieldName)) { + value = reader.getDouble(); + } else { + reader.skipChildren(); + } + } + return new ExposureProperties(exposureLevel, value); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceAttributeType.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceAttributeType.java index 6d26b93294826..4688a31c30c3f 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceAttributeType.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceAttributeType.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -115,7 +114,6 @@ public FaceAttributeType() { * @return the corresponding FaceAttributeType. */ @Generated - @JsonCreator public static FaceAttributeType fromString(String name) { return fromString(name, FaceAttributeType.class); } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceAttributes.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceAttributes.java index c6796736a6866..5d00ec95ec403 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceAttributes.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceAttributes.java @@ -5,97 +5,89 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; import java.util.List; /** * Face attributes for the detected face. */ @Immutable -public final class FaceAttributes { +public final class FaceAttributes implements JsonSerializable { /* * Age in years. */ @Generated - @JsonProperty(value = "age") private Double age; /* * Smile intensity, a number between [0,1]. */ @Generated - @JsonProperty(value = "smile") private Double smile; /* * Properties describing facial hair attributes. */ @Generated - @JsonProperty(value = "facialHair") private FacialHair facialHair; /* * Glasses type if any of the face. */ @Generated - @JsonProperty(value = "glasses") private GlassesType glasses; /* * 3-D roll/yaw/pitch angles for face direction. */ @Generated - @JsonProperty(value = "headPose") private HeadPose headPose; /* * Properties describing hair attributes. */ @Generated - @JsonProperty(value = "hair") private HairProperties hair; /* * Properties describing occlusions on a given face. */ @Generated - @JsonProperty(value = "occlusion") private OcclusionProperties occlusion; /* * Properties describing any accessories on a given face. */ @Generated - @JsonProperty(value = "accessories") private List accessories; /* * Properties describing any presence of blur within the image. */ @Generated - @JsonProperty(value = "blur") private BlurProperties blur; /* * Properties describing exposure level of the image. */ @Generated - @JsonProperty(value = "exposure") private ExposureProperties exposure; /* * Properties describing noise level of the image. */ @Generated - @JsonProperty(value = "noise") private NoiseProperties noise; /* * Properties describing the presence of a mask on a given face. */ @Generated - @JsonProperty(value = "mask") private MaskProperties mask; /* @@ -103,7 +95,6 @@ public final class FaceAttributes { * sufficient quality to attempt face recognition on. */ @Generated - @JsonProperty(value = "qualityForRecognition") private QualityForRecognition qualityForRecognition; /** @@ -243,4 +234,79 @@ public MaskProperties getMask() { public QualityForRecognition getQualityForRecognition() { return this.qualityForRecognition; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("age", this.age); + jsonWriter.writeNumberField("smile", this.smile); + jsonWriter.writeJsonField("facialHair", this.facialHair); + jsonWriter.writeStringField("glasses", this.glasses == null ? null : this.glasses.toString()); + jsonWriter.writeJsonField("headPose", this.headPose); + jsonWriter.writeJsonField("hair", this.hair); + jsonWriter.writeJsonField("occlusion", this.occlusion); + jsonWriter.writeArrayField("accessories", this.accessories, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("blur", this.blur); + jsonWriter.writeJsonField("exposure", this.exposure); + jsonWriter.writeJsonField("noise", this.noise); + jsonWriter.writeJsonField("mask", this.mask); + jsonWriter.writeStringField("qualityForRecognition", + this.qualityForRecognition == null ? null : this.qualityForRecognition.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FaceAttributes from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FaceAttributes 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 FaceAttributes. + */ + @Generated + public static FaceAttributes fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FaceAttributes deserializedFaceAttributes = new FaceAttributes(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("age".equals(fieldName)) { + deserializedFaceAttributes.age = reader.getNullable(JsonReader::getDouble); + } else if ("smile".equals(fieldName)) { + deserializedFaceAttributes.smile = reader.getNullable(JsonReader::getDouble); + } else if ("facialHair".equals(fieldName)) { + deserializedFaceAttributes.facialHair = FacialHair.fromJson(reader); + } else if ("glasses".equals(fieldName)) { + deserializedFaceAttributes.glasses = GlassesType.fromString(reader.getString()); + } else if ("headPose".equals(fieldName)) { + deserializedFaceAttributes.headPose = HeadPose.fromJson(reader); + } else if ("hair".equals(fieldName)) { + deserializedFaceAttributes.hair = HairProperties.fromJson(reader); + } else if ("occlusion".equals(fieldName)) { + deserializedFaceAttributes.occlusion = OcclusionProperties.fromJson(reader); + } else if ("accessories".equals(fieldName)) { + List accessories = reader.readArray(reader1 -> AccessoryItem.fromJson(reader1)); + deserializedFaceAttributes.accessories = accessories; + } else if ("blur".equals(fieldName)) { + deserializedFaceAttributes.blur = BlurProperties.fromJson(reader); + } else if ("exposure".equals(fieldName)) { + deserializedFaceAttributes.exposure = ExposureProperties.fromJson(reader); + } else if ("noise".equals(fieldName)) { + deserializedFaceAttributes.noise = NoiseProperties.fromJson(reader); + } else if ("mask".equals(fieldName)) { + deserializedFaceAttributes.mask = MaskProperties.fromJson(reader); + } else if ("qualityForRecognition".equals(fieldName)) { + deserializedFaceAttributes.qualityForRecognition + = QualityForRecognition.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return deserializedFaceAttributes; + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceDetectionModel.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceDetectionModel.java index 9bff54d8f2534..aa5815a95f795 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceDetectionModel.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceDetectionModel.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -49,7 +48,6 @@ public FaceDetectionModel() { * @return the corresponding FaceDetectionModel. */ @Generated - @JsonCreator public static FaceDetectionModel fromString(String name) { return fromString(name, FaceDetectionModel.class); } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceDetectionResult.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceDetectionResult.java index c392d3c13b443..074e15621523e 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceDetectionResult.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceDetectionResult.java @@ -5,21 +5,23 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * Response for detect API. */ @Immutable -public final class FaceDetectionResult { +public final class FaceDetectionResult implements JsonSerializable { /* * Unique faceId of the detected face, created by detection API and it will expire 24 hours after the detection * call. To return this, it requires 'returnFaceId' parameter to be true. */ @Generated - @JsonProperty(value = "faceId") private String faceId; /* @@ -27,14 +29,12 @@ public final class FaceDetectionResult { * explicitly set as true. */ @Generated - @JsonProperty(value = "recognitionModel") private FaceRecognitionModel recognitionModel; /* * A rectangle area for the face location on image. */ @Generated - @JsonProperty(value = "faceRectangle") private final FaceRectangle faceRectangle; /* @@ -42,14 +42,12 @@ public final class FaceDetectionResult { * requires 'returnFaceLandmarks' parameter to be true. */ @Generated - @JsonProperty(value = "faceLandmarks") private FaceLandmarks faceLandmarks; /* * Face attributes for detected face. */ @Generated - @JsonProperty(value = "faceAttributes") private FaceAttributes faceAttributes; /** @@ -58,8 +56,7 @@ public final class FaceDetectionResult { * @param faceRectangle the faceRectangle value to set. */ @Generated - @JsonCreator - private FaceDetectionResult(@JsonProperty(value = "faceRectangle") FaceRectangle faceRectangle) { + private FaceDetectionResult(FaceRectangle faceRectangle) { this.faceRectangle = faceRectangle; } @@ -115,4 +112,63 @@ public FaceLandmarks getFaceLandmarks() { public FaceAttributes getFaceAttributes() { return this.faceAttributes; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("faceRectangle", this.faceRectangle); + jsonWriter.writeStringField("faceId", this.faceId); + jsonWriter.writeStringField("recognitionModel", + this.recognitionModel == null ? null : this.recognitionModel.toString()); + jsonWriter.writeJsonField("faceLandmarks", this.faceLandmarks); + jsonWriter.writeJsonField("faceAttributes", this.faceAttributes); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FaceDetectionResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FaceDetectionResult if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FaceDetectionResult. + */ + @Generated + public static FaceDetectionResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FaceRectangle faceRectangle = null; + String faceId = null; + FaceRecognitionModel recognitionModel = null; + FaceLandmarks faceLandmarks = null; + FaceAttributes faceAttributes = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("faceRectangle".equals(fieldName)) { + faceRectangle = FaceRectangle.fromJson(reader); + } else if ("faceId".equals(fieldName)) { + faceId = reader.getString(); + } else if ("recognitionModel".equals(fieldName)) { + recognitionModel = FaceRecognitionModel.fromString(reader.getString()); + } else if ("faceLandmarks".equals(fieldName)) { + faceLandmarks = FaceLandmarks.fromJson(reader); + } else if ("faceAttributes".equals(fieldName)) { + faceAttributes = FaceAttributes.fromJson(reader); + } else { + reader.skipChildren(); + } + } + FaceDetectionResult deserializedFaceDetectionResult = new FaceDetectionResult(faceRectangle); + deserializedFaceDetectionResult.faceId = faceId; + deserializedFaceDetectionResult.recognitionModel = recognitionModel; + deserializedFaceDetectionResult.faceLandmarks = faceLandmarks; + deserializedFaceDetectionResult.faceAttributes = faceAttributes; + return deserializedFaceDetectionResult; + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceFindSimilarResult.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceFindSimilarResult.java index acf2748660c63..56d17ca796744 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceFindSimilarResult.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceFindSimilarResult.java @@ -5,20 +5,22 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * Response body for find similar face operation. */ @Immutable -public final class FaceFindSimilarResult { +public final class FaceFindSimilarResult implements JsonSerializable { /* * Confidence value of the candidate. The higher confidence, the more similar. Range between [0,1]. */ @Generated - @JsonProperty(value = "confidence") private final double confidence; /* @@ -26,7 +28,6 @@ public final class FaceFindSimilarResult { * detection call. */ @Generated - @JsonProperty(value = "faceId") private String faceId; /* @@ -34,7 +35,6 @@ public final class FaceFindSimilarResult { * face list is persisted and will not expire. */ @Generated - @JsonProperty(value = "persistedFaceId") private String persistedFaceId; /** @@ -43,8 +43,7 @@ public final class FaceFindSimilarResult { * @param confidence the confidence value to set. */ @Generated - @JsonCreator - private FaceFindSimilarResult(@JsonProperty(value = "confidence") double confidence) { + private FaceFindSimilarResult(double confidence) { this.confidence = confidence; } @@ -80,4 +79,52 @@ public String getFaceId() { public String getPersistedFaceId() { return this.persistedFaceId; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("confidence", this.confidence); + jsonWriter.writeStringField("faceId", this.faceId); + jsonWriter.writeStringField("persistedFaceId", this.persistedFaceId); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FaceFindSimilarResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FaceFindSimilarResult if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FaceFindSimilarResult. + */ + @Generated + public static FaceFindSimilarResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + double confidence = 0.0; + String faceId = null; + String persistedFaceId = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("confidence".equals(fieldName)) { + confidence = reader.getDouble(); + } else if ("faceId".equals(fieldName)) { + faceId = reader.getString(); + } else if ("persistedFaceId".equals(fieldName)) { + persistedFaceId = reader.getString(); + } else { + reader.skipChildren(); + } + } + FaceFindSimilarResult deserializedFaceFindSimilarResult = new FaceFindSimilarResult(confidence); + deserializedFaceFindSimilarResult.faceId = faceId; + deserializedFaceFindSimilarResult.persistedFaceId = persistedFaceId; + return deserializedFaceFindSimilarResult; + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceGroupingResult.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceGroupingResult.java index 36a01aa0eef32..12cdd80f52bcf 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceGroupingResult.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceGroupingResult.java @@ -5,28 +5,29 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; import java.util.List; /** * Response body for group face operation. */ @Immutable -public final class FaceGroupingResult { +public final class FaceGroupingResult implements JsonSerializable { /* * A partition of the original faces based on face similarity. Groups are ranked by number of faces. */ @Generated - @JsonProperty(value = "groups") private final List> groups; /* * Face ids array of faces that cannot find any similar faces from original faces. */ @Generated - @JsonProperty(value = "messyGroup") private final List messyGroup; /** @@ -36,9 +37,7 @@ public final class FaceGroupingResult { * @param messyGroup the messyGroup value to set. */ @Generated - @JsonCreator - private FaceGroupingResult(@JsonProperty(value = "groups") List> groups, - @JsonProperty(value = "messyGroup") List messyGroup) { + private FaceGroupingResult(List> groups, List messyGroup) { this.groups = groups; this.messyGroup = messyGroup; } @@ -63,4 +62,46 @@ public List> getGroups() { public List getMessyGroup() { return this.messyGroup; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("groups", this.groups, + (writer, element) -> writer.writeArray(element, (writer1, element1) -> writer1.writeString(element1))); + jsonWriter.writeArrayField("messyGroup", this.messyGroup, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FaceGroupingResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FaceGroupingResult if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FaceGroupingResult. + */ + @Generated + public static FaceGroupingResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List> groups = null; + List messyGroup = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("groups".equals(fieldName)) { + groups = reader.readArray(reader1 -> reader1.readArray(reader2 -> reader2.getString())); + } else if ("messyGroup".equals(fieldName)) { + messyGroup = reader.readArray(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + return new FaceGroupingResult(groups, messyGroup); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceImageType.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceImageType.java index c84683004c13b..7a7dc59c5dbd8 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceImageType.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceImageType.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -48,7 +47,6 @@ public FaceImageType() { * @return the corresponding FaceImageType. */ @Generated - @JsonCreator public static FaceImageType fromString(String name) { return fromString(name, FaceImageType.class); } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceLandmarks.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceLandmarks.java index 9460a6c145fe3..5a95d1d10a3b7 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceLandmarks.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceLandmarks.java @@ -5,202 +5,178 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * A collection of 27-point face landmarks pointing to the important positions of face components. */ @Immutable -public final class FaceLandmarks { +public final class FaceLandmarks implements JsonSerializable { /* * The coordinates of the left eye pupil. */ @Generated - @JsonProperty(value = "pupilLeft") private final LandmarkCoordinate pupilLeft; /* * The coordinates of the right eye pupil. */ @Generated - @JsonProperty(value = "pupilRight") private final LandmarkCoordinate pupilRight; /* * The coordinates of the nose tip. */ @Generated - @JsonProperty(value = "noseTip") private final LandmarkCoordinate noseTip; /* * The coordinates of the mouth left. */ @Generated - @JsonProperty(value = "mouthLeft") private final LandmarkCoordinate mouthLeft; /* * The coordinates of the mouth right. */ @Generated - @JsonProperty(value = "mouthRight") private final LandmarkCoordinate mouthRight; /* * The coordinates of the left eyebrow outer. */ @Generated - @JsonProperty(value = "eyebrowLeftOuter") private final LandmarkCoordinate eyebrowLeftOuter; /* * The coordinates of the left eyebrow inner. */ @Generated - @JsonProperty(value = "eyebrowLeftInner") private final LandmarkCoordinate eyebrowLeftInner; /* * The coordinates of the left eye outer. */ @Generated - @JsonProperty(value = "eyeLeftOuter") private final LandmarkCoordinate eyeLeftOuter; /* * The coordinates of the left eye top. */ @Generated - @JsonProperty(value = "eyeLeftTop") private final LandmarkCoordinate eyeLeftTop; /* * The coordinates of the left eye bottom. */ @Generated - @JsonProperty(value = "eyeLeftBottom") private final LandmarkCoordinate eyeLeftBottom; /* * The coordinates of the left eye inner. */ @Generated - @JsonProperty(value = "eyeLeftInner") private final LandmarkCoordinate eyeLeftInner; /* * The coordinates of the right eyebrow inner. */ @Generated - @JsonProperty(value = "eyebrowRightInner") private final LandmarkCoordinate eyebrowRightInner; /* * The coordinates of the right eyebrow outer. */ @Generated - @JsonProperty(value = "eyebrowRightOuter") private final LandmarkCoordinate eyebrowRightOuter; /* * The coordinates of the right eye inner. */ @Generated - @JsonProperty(value = "eyeRightInner") private final LandmarkCoordinate eyeRightInner; /* * The coordinates of the right eye top. */ @Generated - @JsonProperty(value = "eyeRightTop") private final LandmarkCoordinate eyeRightTop; /* * The coordinates of the right eye bottom. */ @Generated - @JsonProperty(value = "eyeRightBottom") private final LandmarkCoordinate eyeRightBottom; /* * The coordinates of the right eye outer. */ @Generated - @JsonProperty(value = "eyeRightOuter") private final LandmarkCoordinate eyeRightOuter; /* * The coordinates of the nose root left. */ @Generated - @JsonProperty(value = "noseRootLeft") private final LandmarkCoordinate noseRootLeft; /* * The coordinates of the nose root right. */ @Generated - @JsonProperty(value = "noseRootRight") private final LandmarkCoordinate noseRootRight; /* * The coordinates of the nose left alar top. */ @Generated - @JsonProperty(value = "noseLeftAlarTop") private final LandmarkCoordinate noseLeftAlarTop; /* * The coordinates of the nose right alar top. */ @Generated - @JsonProperty(value = "noseRightAlarTop") private final LandmarkCoordinate noseRightAlarTop; /* * The coordinates of the nose left alar out tip. */ @Generated - @JsonProperty(value = "noseLeftAlarOutTip") private final LandmarkCoordinate noseLeftAlarOutTip; /* * The coordinates of the nose right alar out tip. */ @Generated - @JsonProperty(value = "noseRightAlarOutTip") private final LandmarkCoordinate noseRightAlarOutTip; /* * The coordinates of the upper lip top. */ @Generated - @JsonProperty(value = "upperLipTop") private final LandmarkCoordinate upperLipTop; /* * The coordinates of the upper lip bottom. */ @Generated - @JsonProperty(value = "upperLipBottom") private final LandmarkCoordinate upperLipBottom; /* * The coordinates of the under lip top. */ @Generated - @JsonProperty(value = "underLipTop") private final LandmarkCoordinate underLipTop; /* * The coordinates of the under lip bottom. */ @Generated - @JsonProperty(value = "underLipBottom") private final LandmarkCoordinate underLipBottom; /** @@ -235,34 +211,15 @@ public final class FaceLandmarks { * @param underLipBottom the underLipBottom value to set. */ @Generated - @JsonCreator - private FaceLandmarks(@JsonProperty(value = "pupilLeft") LandmarkCoordinate pupilLeft, - @JsonProperty(value = "pupilRight") LandmarkCoordinate pupilRight, - @JsonProperty(value = "noseTip") LandmarkCoordinate noseTip, - @JsonProperty(value = "mouthLeft") LandmarkCoordinate mouthLeft, - @JsonProperty(value = "mouthRight") LandmarkCoordinate mouthRight, - @JsonProperty(value = "eyebrowLeftOuter") LandmarkCoordinate eyebrowLeftOuter, - @JsonProperty(value = "eyebrowLeftInner") LandmarkCoordinate eyebrowLeftInner, - @JsonProperty(value = "eyeLeftOuter") LandmarkCoordinate eyeLeftOuter, - @JsonProperty(value = "eyeLeftTop") LandmarkCoordinate eyeLeftTop, - @JsonProperty(value = "eyeLeftBottom") LandmarkCoordinate eyeLeftBottom, - @JsonProperty(value = "eyeLeftInner") LandmarkCoordinate eyeLeftInner, - @JsonProperty(value = "eyebrowRightInner") LandmarkCoordinate eyebrowRightInner, - @JsonProperty(value = "eyebrowRightOuter") LandmarkCoordinate eyebrowRightOuter, - @JsonProperty(value = "eyeRightInner") LandmarkCoordinate eyeRightInner, - @JsonProperty(value = "eyeRightTop") LandmarkCoordinate eyeRightTop, - @JsonProperty(value = "eyeRightBottom") LandmarkCoordinate eyeRightBottom, - @JsonProperty(value = "eyeRightOuter") LandmarkCoordinate eyeRightOuter, - @JsonProperty(value = "noseRootLeft") LandmarkCoordinate noseRootLeft, - @JsonProperty(value = "noseRootRight") LandmarkCoordinate noseRootRight, - @JsonProperty(value = "noseLeftAlarTop") LandmarkCoordinate noseLeftAlarTop, - @JsonProperty(value = "noseRightAlarTop") LandmarkCoordinate noseRightAlarTop, - @JsonProperty(value = "noseLeftAlarOutTip") LandmarkCoordinate noseLeftAlarOutTip, - @JsonProperty(value = "noseRightAlarOutTip") LandmarkCoordinate noseRightAlarOutTip, - @JsonProperty(value = "upperLipTop") LandmarkCoordinate upperLipTop, - @JsonProperty(value = "upperLipBottom") LandmarkCoordinate upperLipBottom, - @JsonProperty(value = "underLipTop") LandmarkCoordinate underLipTop, - @JsonProperty(value = "underLipBottom") LandmarkCoordinate underLipBottom) { + private FaceLandmarks(LandmarkCoordinate pupilLeft, LandmarkCoordinate pupilRight, LandmarkCoordinate noseTip, + LandmarkCoordinate mouthLeft, LandmarkCoordinate mouthRight, LandmarkCoordinate eyebrowLeftOuter, + LandmarkCoordinate eyebrowLeftInner, LandmarkCoordinate eyeLeftOuter, LandmarkCoordinate eyeLeftTop, + LandmarkCoordinate eyeLeftBottom, LandmarkCoordinate eyeLeftInner, LandmarkCoordinate eyebrowRightInner, + LandmarkCoordinate eyebrowRightOuter, LandmarkCoordinate eyeRightInner, LandmarkCoordinate eyeRightTop, + LandmarkCoordinate eyeRightBottom, LandmarkCoordinate eyeRightOuter, LandmarkCoordinate noseRootLeft, + LandmarkCoordinate noseRootRight, LandmarkCoordinate noseLeftAlarTop, LandmarkCoordinate noseRightAlarTop, + LandmarkCoordinate noseLeftAlarOutTip, LandmarkCoordinate noseRightAlarOutTip, LandmarkCoordinate upperLipTop, + LandmarkCoordinate upperLipBottom, LandmarkCoordinate underLipTop, LandmarkCoordinate underLipBottom) { this.pupilLeft = pupilLeft; this.pupilRight = pupilRight; this.noseTip = noseTip; @@ -561,4 +518,149 @@ public LandmarkCoordinate getUnderLipTop() { public LandmarkCoordinate getUnderLipBottom() { return this.underLipBottom; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("pupilLeft", this.pupilLeft); + jsonWriter.writeJsonField("pupilRight", this.pupilRight); + jsonWriter.writeJsonField("noseTip", this.noseTip); + jsonWriter.writeJsonField("mouthLeft", this.mouthLeft); + jsonWriter.writeJsonField("mouthRight", this.mouthRight); + jsonWriter.writeJsonField("eyebrowLeftOuter", this.eyebrowLeftOuter); + jsonWriter.writeJsonField("eyebrowLeftInner", this.eyebrowLeftInner); + jsonWriter.writeJsonField("eyeLeftOuter", this.eyeLeftOuter); + jsonWriter.writeJsonField("eyeLeftTop", this.eyeLeftTop); + jsonWriter.writeJsonField("eyeLeftBottom", this.eyeLeftBottom); + jsonWriter.writeJsonField("eyeLeftInner", this.eyeLeftInner); + jsonWriter.writeJsonField("eyebrowRightInner", this.eyebrowRightInner); + jsonWriter.writeJsonField("eyebrowRightOuter", this.eyebrowRightOuter); + jsonWriter.writeJsonField("eyeRightInner", this.eyeRightInner); + jsonWriter.writeJsonField("eyeRightTop", this.eyeRightTop); + jsonWriter.writeJsonField("eyeRightBottom", this.eyeRightBottom); + jsonWriter.writeJsonField("eyeRightOuter", this.eyeRightOuter); + jsonWriter.writeJsonField("noseRootLeft", this.noseRootLeft); + jsonWriter.writeJsonField("noseRootRight", this.noseRootRight); + jsonWriter.writeJsonField("noseLeftAlarTop", this.noseLeftAlarTop); + jsonWriter.writeJsonField("noseRightAlarTop", this.noseRightAlarTop); + jsonWriter.writeJsonField("noseLeftAlarOutTip", this.noseLeftAlarOutTip); + jsonWriter.writeJsonField("noseRightAlarOutTip", this.noseRightAlarOutTip); + jsonWriter.writeJsonField("upperLipTop", this.upperLipTop); + jsonWriter.writeJsonField("upperLipBottom", this.upperLipBottom); + jsonWriter.writeJsonField("underLipTop", this.underLipTop); + jsonWriter.writeJsonField("underLipBottom", this.underLipBottom); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FaceLandmarks from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FaceLandmarks if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FaceLandmarks. + */ + @Generated + public static FaceLandmarks fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + LandmarkCoordinate pupilLeft = null; + LandmarkCoordinate pupilRight = null; + LandmarkCoordinate noseTip = null; + LandmarkCoordinate mouthLeft = null; + LandmarkCoordinate mouthRight = null; + LandmarkCoordinate eyebrowLeftOuter = null; + LandmarkCoordinate eyebrowLeftInner = null; + LandmarkCoordinate eyeLeftOuter = null; + LandmarkCoordinate eyeLeftTop = null; + LandmarkCoordinate eyeLeftBottom = null; + LandmarkCoordinate eyeLeftInner = null; + LandmarkCoordinate eyebrowRightInner = null; + LandmarkCoordinate eyebrowRightOuter = null; + LandmarkCoordinate eyeRightInner = null; + LandmarkCoordinate eyeRightTop = null; + LandmarkCoordinate eyeRightBottom = null; + LandmarkCoordinate eyeRightOuter = null; + LandmarkCoordinate noseRootLeft = null; + LandmarkCoordinate noseRootRight = null; + LandmarkCoordinate noseLeftAlarTop = null; + LandmarkCoordinate noseRightAlarTop = null; + LandmarkCoordinate noseLeftAlarOutTip = null; + LandmarkCoordinate noseRightAlarOutTip = null; + LandmarkCoordinate upperLipTop = null; + LandmarkCoordinate upperLipBottom = null; + LandmarkCoordinate underLipTop = null; + LandmarkCoordinate underLipBottom = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("pupilLeft".equals(fieldName)) { + pupilLeft = LandmarkCoordinate.fromJson(reader); + } else if ("pupilRight".equals(fieldName)) { + pupilRight = LandmarkCoordinate.fromJson(reader); + } else if ("noseTip".equals(fieldName)) { + noseTip = LandmarkCoordinate.fromJson(reader); + } else if ("mouthLeft".equals(fieldName)) { + mouthLeft = LandmarkCoordinate.fromJson(reader); + } else if ("mouthRight".equals(fieldName)) { + mouthRight = LandmarkCoordinate.fromJson(reader); + } else if ("eyebrowLeftOuter".equals(fieldName)) { + eyebrowLeftOuter = LandmarkCoordinate.fromJson(reader); + } else if ("eyebrowLeftInner".equals(fieldName)) { + eyebrowLeftInner = LandmarkCoordinate.fromJson(reader); + } else if ("eyeLeftOuter".equals(fieldName)) { + eyeLeftOuter = LandmarkCoordinate.fromJson(reader); + } else if ("eyeLeftTop".equals(fieldName)) { + eyeLeftTop = LandmarkCoordinate.fromJson(reader); + } else if ("eyeLeftBottom".equals(fieldName)) { + eyeLeftBottom = LandmarkCoordinate.fromJson(reader); + } else if ("eyeLeftInner".equals(fieldName)) { + eyeLeftInner = LandmarkCoordinate.fromJson(reader); + } else if ("eyebrowRightInner".equals(fieldName)) { + eyebrowRightInner = LandmarkCoordinate.fromJson(reader); + } else if ("eyebrowRightOuter".equals(fieldName)) { + eyebrowRightOuter = LandmarkCoordinate.fromJson(reader); + } else if ("eyeRightInner".equals(fieldName)) { + eyeRightInner = LandmarkCoordinate.fromJson(reader); + } else if ("eyeRightTop".equals(fieldName)) { + eyeRightTop = LandmarkCoordinate.fromJson(reader); + } else if ("eyeRightBottom".equals(fieldName)) { + eyeRightBottom = LandmarkCoordinate.fromJson(reader); + } else if ("eyeRightOuter".equals(fieldName)) { + eyeRightOuter = LandmarkCoordinate.fromJson(reader); + } else if ("noseRootLeft".equals(fieldName)) { + noseRootLeft = LandmarkCoordinate.fromJson(reader); + } else if ("noseRootRight".equals(fieldName)) { + noseRootRight = LandmarkCoordinate.fromJson(reader); + } else if ("noseLeftAlarTop".equals(fieldName)) { + noseLeftAlarTop = LandmarkCoordinate.fromJson(reader); + } else if ("noseRightAlarTop".equals(fieldName)) { + noseRightAlarTop = LandmarkCoordinate.fromJson(reader); + } else if ("noseLeftAlarOutTip".equals(fieldName)) { + noseLeftAlarOutTip = LandmarkCoordinate.fromJson(reader); + } else if ("noseRightAlarOutTip".equals(fieldName)) { + noseRightAlarOutTip = LandmarkCoordinate.fromJson(reader); + } else if ("upperLipTop".equals(fieldName)) { + upperLipTop = LandmarkCoordinate.fromJson(reader); + } else if ("upperLipBottom".equals(fieldName)) { + upperLipBottom = LandmarkCoordinate.fromJson(reader); + } else if ("underLipTop".equals(fieldName)) { + underLipTop = LandmarkCoordinate.fromJson(reader); + } else if ("underLipBottom".equals(fieldName)) { + underLipBottom = LandmarkCoordinate.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new FaceLandmarks(pupilLeft, pupilRight, noseTip, mouthLeft, mouthRight, eyebrowLeftOuter, + eyebrowLeftInner, eyeLeftOuter, eyeLeftTop, eyeLeftBottom, eyeLeftInner, eyebrowRightInner, + eyebrowRightOuter, eyeRightInner, eyeRightTop, eyeRightBottom, eyeRightOuter, noseRootLeft, + noseRootRight, noseLeftAlarTop, noseRightAlarTop, noseLeftAlarOutTip, noseRightAlarOutTip, upperLipTop, + upperLipBottom, underLipTop, underLipBottom); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceLivenessDecision.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceLivenessDecision.java index 4da58b5f8c7be..ef3e7f7baae56 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceLivenessDecision.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceLivenessDecision.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -48,7 +47,6 @@ public FaceLivenessDecision() { * @return the corresponding FaceLivenessDecision. */ @Generated - @JsonCreator public static FaceLivenessDecision fromString(String name) { return fromString(name, FaceLivenessDecision.class); } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceRecognitionModel.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceRecognitionModel.java index 32ba1556aa453..bcc6e8f44a1a7 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceRecognitionModel.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceRecognitionModel.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -56,7 +55,6 @@ public FaceRecognitionModel() { * @return the corresponding FaceRecognitionModel. */ @Generated - @JsonCreator public static FaceRecognitionModel fromString(String name) { return fromString(name, FaceRecognitionModel.class); } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceRectangle.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceRectangle.java index 845ccba653f6f..1af03859d0fe9 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceRectangle.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceRectangle.java @@ -5,41 +5,40 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * A rectangle within which a face can be found. */ @Immutable -public final class FaceRectangle { +public final class FaceRectangle implements JsonSerializable { /* * The distance from the top edge if the image to the top edge of the rectangle, in pixels. */ @Generated - @JsonProperty(value = "top") private final int top; /* * The distance from the left edge if the image to the left edge of the rectangle, in pixels. */ @Generated - @JsonProperty(value = "left") private final int left; /* * The width of the rectangle, in pixels. */ @Generated - @JsonProperty(value = "width") private final int width; /* * The height of the rectangle, in pixels. */ @Generated - @JsonProperty(value = "height") private final int height; /** @@ -51,9 +50,7 @@ public final class FaceRectangle { * @param height the height value to set. */ @Generated - @JsonCreator - private FaceRectangle(@JsonProperty(value = "top") int top, @JsonProperty(value = "left") int left, - @JsonProperty(value = "width") int width, @JsonProperty(value = "height") int height) { + private FaceRectangle(int top, int left, int width, int height) { this.top = top; this.left = left; this.width = width; @@ -99,4 +96,53 @@ public int getWidth() { public int getHeight() { return this.height; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("top", this.top); + jsonWriter.writeIntField("left", this.left); + jsonWriter.writeIntField("width", this.width); + jsonWriter.writeIntField("height", this.height); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FaceRectangle from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FaceRectangle if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FaceRectangle. + */ + @Generated + public static FaceRectangle fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int top = 0; + int left = 0; + int width = 0; + int height = 0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("top".equals(fieldName)) { + top = reader.getInt(); + } else if ("left".equals(fieldName)) { + left = reader.getInt(); + } else if ("width".equals(fieldName)) { + width = reader.getInt(); + } else if ("height".equals(fieldName)) { + height = reader.getInt(); + } else { + reader.skipChildren(); + } + } + return new FaceRectangle(top, left, width, height); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceSessionStatus.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceSessionStatus.java index 3dc04958f5b05..a51cf1b8789b7 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceSessionStatus.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceSessionStatus.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -48,7 +47,6 @@ public FaceSessionStatus() { * @return the corresponding FaceSessionStatus. */ @Generated - @JsonCreator public static FaceSessionStatus fromString(String name) { return fromString(name, FaceSessionStatus.class); } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceVerificationResult.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceVerificationResult.java index 4cdbcc08cb8d2..b49c6be76d67f 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceVerificationResult.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FaceVerificationResult.java @@ -5,20 +5,22 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * Verify result. */ @Immutable -public final class FaceVerificationResult { +public final class FaceVerificationResult implements JsonSerializable { /* * True if the two faces belong to the same person or the face belongs to the person, otherwise false. */ @Generated - @JsonProperty(value = "isIdentical") private final boolean isIdentical; /* @@ -27,7 +29,6 @@ public final class FaceVerificationResult { * to 0.5. This is useful for advanced users to override 'isIdentical' and fine-tune the result on their own data. */ @Generated - @JsonProperty(value = "confidence") private final double confidence; /** @@ -37,9 +38,7 @@ public final class FaceVerificationResult { * @param confidence the confidence value to set. */ @Generated - @JsonCreator - private FaceVerificationResult(@JsonProperty(value = "isIdentical") boolean isIdentical, - @JsonProperty(value = "confidence") double confidence) { + private FaceVerificationResult(boolean isIdentical, double confidence) { this.isIdentical = isIdentical; this.confidence = confidence; } @@ -67,4 +66,45 @@ public boolean isIdentical() { public double getConfidence() { return this.confidence; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("isIdentical", this.isIdentical); + jsonWriter.writeDoubleField("confidence", this.confidence); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FaceVerificationResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FaceVerificationResult if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FaceVerificationResult. + */ + @Generated + public static FaceVerificationResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean isIdentical = false; + double confidence = 0.0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("isIdentical".equals(fieldName)) { + isIdentical = reader.getBoolean(); + } else if ("confidence".equals(fieldName)) { + confidence = reader.getDouble(); + } else { + reader.skipChildren(); + } + } + return new FaceVerificationResult(isIdentical, confidence); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FacialHair.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FacialHair.java index a4d9dfa7004f0..55ceb264319dd 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FacialHair.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FacialHair.java @@ -5,34 +5,34 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * Properties describing facial hair attributes. */ @Immutable -public final class FacialHair { +public final class FacialHair implements JsonSerializable { /* * A number ranging from 0 to 1 indicating a level of confidence associated with a property. */ @Generated - @JsonProperty(value = "moustache") private final double moustache; /* * A number ranging from 0 to 1 indicating a level of confidence associated with a property. */ @Generated - @JsonProperty(value = "beard") private final double beard; /* * A number ranging from 0 to 1 indicating a level of confidence associated with a property. */ @Generated - @JsonProperty(value = "sideburns") private final double sideburns; /** @@ -43,9 +43,7 @@ public final class FacialHair { * @param sideburns the sideburns value to set. */ @Generated - @JsonCreator - private FacialHair(@JsonProperty(value = "moustache") double moustache, @JsonProperty(value = "beard") double beard, - @JsonProperty(value = "sideburns") double sideburns) { + private FacialHair(double moustache, double beard, double sideburns) { this.moustache = moustache; this.beard = beard; this.sideburns = sideburns; @@ -82,4 +80,49 @@ public double getBeard() { public double getSideburns() { return this.sideburns; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("moustache", this.moustache); + jsonWriter.writeDoubleField("beard", this.beard); + jsonWriter.writeDoubleField("sideburns", this.sideburns); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FacialHair from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FacialHair if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FacialHair. + */ + @Generated + public static FacialHair fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + double moustache = 0.0; + double beard = 0.0; + double sideburns = 0.0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("moustache".equals(fieldName)) { + moustache = reader.getDouble(); + } else if ("beard".equals(fieldName)) { + beard = reader.getDouble(); + } else if ("sideburns".equals(fieldName)) { + sideburns = reader.getDouble(); + } else { + reader.skipChildren(); + } + } + return new FacialHair(moustache, beard, sideburns); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FindSimilarMatchMode.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FindSimilarMatchMode.java index cd808371f2f7e..5e4f9e5435fa8 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FindSimilarMatchMode.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/FindSimilarMatchMode.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -42,7 +41,6 @@ public FindSimilarMatchMode() { * @return the corresponding FindSimilarMatchMode. */ @Generated - @JsonCreator public static FindSimilarMatchMode fromString(String name) { return fromString(name, FindSimilarMatchMode.class); } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/GlassesType.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/GlassesType.java index dc231f8def8c9..cb06d59043df5 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/GlassesType.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/GlassesType.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -54,7 +53,6 @@ public GlassesType() { * @return the corresponding GlassesType. */ @Generated - @JsonCreator public static GlassesType fromString(String name) { return fromString(name, GlassesType.class); } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/HairColor.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/HairColor.java index 9eac484b75e71..38b9c91d2f9fb 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/HairColor.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/HairColor.java @@ -5,27 +5,28 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * An array of candidate colors and confidence level in the presence of each. */ @Immutable -public final class HairColor { +public final class HairColor implements JsonSerializable { /* * Name of the hair color. */ @Generated - @JsonProperty(value = "color") private final HairColorType color; /* * Confidence level of the color. Range between [0,1]. */ @Generated - @JsonProperty(value = "confidence") private final double confidence; /** @@ -35,9 +36,7 @@ public final class HairColor { * @param confidence the confidence value to set. */ @Generated - @JsonCreator - private HairColor(@JsonProperty(value = "color") HairColorType color, - @JsonProperty(value = "confidence") double confidence) { + private HairColor(HairColorType color, double confidence) { this.color = color; this.confidence = confidence; } @@ -61,4 +60,45 @@ public HairColorType getColor() { public double getConfidence() { return this.confidence; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("color", this.color == null ? null : this.color.toString()); + jsonWriter.writeDoubleField("confidence", this.confidence); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of HairColor from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of HairColor if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the HairColor. + */ + @Generated + public static HairColor fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + HairColorType color = null; + double confidence = 0.0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("color".equals(fieldName)) { + color = HairColorType.fromString(reader.getString()); + } else if ("confidence".equals(fieldName)) { + confidence = reader.getDouble(); + } else { + reader.skipChildren(); + } + } + return new HairColor(color, confidence); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/HairColorType.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/HairColorType.java index 38c8822231d1f..5985538fc7096 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/HairColorType.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/HairColorType.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -78,7 +77,6 @@ public HairColorType() { * @return the corresponding HairColorType. */ @Generated - @JsonCreator public static HairColorType fromString(String name) { return fromString(name, HairColorType.class); } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/HairProperties.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/HairProperties.java index 3cf7dcbefb5d1..9b422040366af 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/HairProperties.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/HairProperties.java @@ -5,35 +5,35 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; import java.util.List; /** * Properties describing hair attributes. */ @Immutable -public final class HairProperties { +public final class HairProperties implements JsonSerializable { /* * A number describing confidence level of whether the person is bald. */ @Generated - @JsonProperty(value = "bald") private final double bald; /* * A boolean value describing whether the hair is visible in the image. */ @Generated - @JsonProperty(value = "invisible") private final boolean invisible; /* * An array of candidate colors and confidence level in the presence of each. */ @Generated - @JsonProperty(value = "hairColor") private final List hairColor; /** @@ -44,10 +44,7 @@ public final class HairProperties { * @param hairColor the hairColor value to set. */ @Generated - @JsonCreator - private HairProperties(@JsonProperty(value = "bald") double bald, - @JsonProperty(value = "invisible") boolean invisible, - @JsonProperty(value = "hairColor") List hairColor) { + private HairProperties(double bald, boolean invisible, List hairColor) { this.bald = bald; this.invisible = invisible; this.hairColor = hairColor; @@ -82,4 +79,49 @@ public boolean isInvisible() { public List getHairColor() { return this.hairColor; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("bald", this.bald); + jsonWriter.writeBooleanField("invisible", this.invisible); + jsonWriter.writeArrayField("hairColor", this.hairColor, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of HairProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of HairProperties if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the HairProperties. + */ + @Generated + public static HairProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + double bald = 0.0; + boolean invisible = false; + List hairColor = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("bald".equals(fieldName)) { + bald = reader.getDouble(); + } else if ("invisible".equals(fieldName)) { + invisible = reader.getBoolean(); + } else if ("hairColor".equals(fieldName)) { + hairColor = reader.readArray(reader1 -> HairColor.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new HairProperties(bald, invisible, hairColor); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/HeadPose.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/HeadPose.java index 2a7736fab7b12..76fbc62f44500 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/HeadPose.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/HeadPose.java @@ -5,34 +5,34 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * 3-D roll/yaw/pitch angles for face direction. */ @Immutable -public final class HeadPose { +public final class HeadPose implements JsonSerializable { /* * Value of angles. */ @Generated - @JsonProperty(value = "pitch") private final double pitch; /* * Value of angles. */ @Generated - @JsonProperty(value = "roll") private final double roll; /* * Value of angles. */ @Generated - @JsonProperty(value = "yaw") private final double yaw; /** @@ -43,9 +43,7 @@ public final class HeadPose { * @param yaw the yaw value to set. */ @Generated - @JsonCreator - private HeadPose(@JsonProperty(value = "pitch") double pitch, @JsonProperty(value = "roll") double roll, - @JsonProperty(value = "yaw") double yaw) { + private HeadPose(double pitch, double roll, double yaw) { this.pitch = pitch; this.roll = roll; this.yaw = yaw; @@ -80,4 +78,49 @@ public double getRoll() { public double getYaw() { return this.yaw; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("pitch", this.pitch); + jsonWriter.writeDoubleField("roll", this.roll); + jsonWriter.writeDoubleField("yaw", this.yaw); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of HeadPose from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of HeadPose if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the HeadPose. + */ + @Generated + public static HeadPose fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + double pitch = 0.0; + double roll = 0.0; + double yaw = 0.0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("pitch".equals(fieldName)) { + pitch = reader.getDouble(); + } else if ("roll".equals(fieldName)) { + roll = reader.getDouble(); + } else if ("yaw".equals(fieldName)) { + yaw = reader.getDouble(); + } else { + reader.skipChildren(); + } + } + return new HeadPose(pitch, roll, yaw); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LandmarkCoordinate.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LandmarkCoordinate.java index 9d5ddc5320c61..26a4cb2be3cc8 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LandmarkCoordinate.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LandmarkCoordinate.java @@ -5,27 +5,28 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * Landmark coordinates within an image. */ @Immutable -public final class LandmarkCoordinate { +public final class LandmarkCoordinate implements JsonSerializable { /* * The horizontal component, in pixels. */ @Generated - @JsonProperty(value = "x") private final double x; /* * The vertical component, in pixels. */ @Generated - @JsonProperty(value = "y") private final double y; /** @@ -35,8 +36,7 @@ public final class LandmarkCoordinate { * @param y the y value to set. */ @Generated - @JsonCreator - private LandmarkCoordinate(@JsonProperty(value = "x") double x, @JsonProperty(value = "y") double y) { + private LandmarkCoordinate(double x, double y) { this.x = x; this.y = y; } @@ -60,4 +60,45 @@ public double getX() { public double getY() { return this.y; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("x", this.x); + jsonWriter.writeDoubleField("y", this.y); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of LandmarkCoordinate from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of LandmarkCoordinate if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the LandmarkCoordinate. + */ + @Generated + public static LandmarkCoordinate fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + double x = 0.0; + double y = 0.0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("x".equals(fieldName)) { + x = reader.getDouble(); + } else if ("y".equals(fieldName)) { + y = reader.getDouble(); + } else { + reader.skipChildren(); + } + } + return new LandmarkCoordinate(x, y); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessModel.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessModel.java index 0c1967c78f6bd..bd0069c4dd474 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessModel.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessModel.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -54,7 +53,6 @@ public LivenessModel() { * @return the corresponding LivenessModel. */ @Generated - @JsonCreator public static LivenessModel fromString(String name) { return fromString(name, LivenessModel.class); } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessOperationMode.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessOperationMode.java index 300acc0bb4fd9..6adcd4f8141d8 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessOperationMode.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessOperationMode.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -49,7 +48,6 @@ public LivenessOperationMode() { * @return the corresponding LivenessOperationMode. */ @Generated - @JsonCreator public static LivenessOperationMode fromString(String name) { return fromString(name, LivenessOperationMode.class); } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessOutputsTarget.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessOutputsTarget.java index e30bcb28b7f9f..84aa94c55ba91 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessOutputsTarget.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessOutputsTarget.java @@ -5,27 +5,28 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * The liveness classification for target face. */ @Immutable -public final class LivenessOutputsTarget { +public final class LivenessOutputsTarget implements JsonSerializable { /* * The face region where the liveness classification was made on. */ @Generated - @JsonProperty(value = "faceRectangle") private final FaceRectangle faceRectangle; /* * The file name which contains the face rectangle where the liveness classification was made on. */ @Generated - @JsonProperty(value = "fileName") private final String fileName; /* @@ -33,14 +34,12 @@ public final class LivenessOutputsTarget { * was made on. */ @Generated - @JsonProperty(value = "timeOffsetWithinFile") private final int timeOffsetWithinFile; /* * The image type which contains the face rectangle where the liveness classification was made on. */ @Generated - @JsonProperty(value = "imageType") private final FaceImageType imageType; /** @@ -52,11 +51,8 @@ public final class LivenessOutputsTarget { * @param imageType the imageType value to set. */ @Generated - @JsonCreator - private LivenessOutputsTarget(@JsonProperty(value = "faceRectangle") FaceRectangle faceRectangle, - @JsonProperty(value = "fileName") String fileName, - @JsonProperty(value = "timeOffsetWithinFile") int timeOffsetWithinFile, - @JsonProperty(value = "imageType") FaceImageType imageType) { + private LivenessOutputsTarget(FaceRectangle faceRectangle, String fileName, int timeOffsetWithinFile, + FaceImageType imageType) { this.faceRectangle = faceRectangle; this.fileName = fileName; this.timeOffsetWithinFile = timeOffsetWithinFile; @@ -105,4 +101,53 @@ public int getTimeOffsetWithinFile() { public FaceImageType getImageType() { return this.imageType; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("faceRectangle", this.faceRectangle); + jsonWriter.writeStringField("fileName", this.fileName); + jsonWriter.writeIntField("timeOffsetWithinFile", this.timeOffsetWithinFile); + jsonWriter.writeStringField("imageType", this.imageType == null ? null : this.imageType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of LivenessOutputsTarget from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of LivenessOutputsTarget if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the LivenessOutputsTarget. + */ + @Generated + public static LivenessOutputsTarget fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FaceRectangle faceRectangle = null; + String fileName = null; + int timeOffsetWithinFile = 0; + FaceImageType imageType = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("faceRectangle".equals(fieldName)) { + faceRectangle = FaceRectangle.fromJson(reader); + } else if ("fileName".equals(fieldName)) { + fileName = reader.getString(); + } else if ("timeOffsetWithinFile".equals(fieldName)) { + timeOffsetWithinFile = reader.getInt(); + } else if ("imageType".equals(fieldName)) { + imageType = FaceImageType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new LivenessOutputsTarget(faceRectangle, fileName, timeOffsetWithinFile, imageType); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessResponseBody.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessResponseBody.java index 1913d86e432b7..86d57207958a5 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessResponseBody.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessResponseBody.java @@ -5,10 +5,11 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; import java.util.LinkedHashMap; import java.util.Map; @@ -16,41 +17,36 @@ * The response body of detect liveness API call. */ @Immutable -public final class LivenessResponseBody { +public final class LivenessResponseBody implements JsonSerializable { /* * The liveness classification for the target face. */ @Generated - @JsonProperty(value = "livenessDecision") private FaceLivenessDecision livenessDecision; /* * Specific targets used for liveness classification. */ @Generated - @JsonProperty(value = "target") private LivenessOutputsTarget target; /* * The model version used for liveness classification. */ @Generated - @JsonProperty(value = "modelVersionUsed") private LivenessModel modelVersionUsed; /* * The face verification output. Only available when the request is liveness with verify. */ @Generated - @JsonProperty(value = "verifyResult") private LivenessWithVerifyOutputs verifyResult; /* * Additional properties */ @Generated - @JsonIgnore private Map additionalProperties; /** @@ -107,17 +103,65 @@ public LivenessWithVerifyOutputs getVerifyResult() { * @return the additionalProperties value. */ @Generated - @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; } + /** + * {@inheritDoc} + */ @Generated - @JsonAnySetter - void setAdditionalProperties(String key, Object value) { - if (additionalProperties == null) { - additionalProperties = new LinkedHashMap<>(); + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("livenessDecision", + this.livenessDecision == null ? null : this.livenessDecision.toString()); + jsonWriter.writeJsonField("target", this.target); + jsonWriter.writeStringField("modelVersionUsed", + this.modelVersionUsed == null ? null : this.modelVersionUsed.toString()); + jsonWriter.writeJsonField("verifyResult", this.verifyResult); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } } - additionalProperties.put(key, value); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of LivenessResponseBody from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of LivenessResponseBody 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 LivenessResponseBody. + */ + @Generated + public static LivenessResponseBody fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + LivenessResponseBody deserializedLivenessResponseBody = new LivenessResponseBody(); + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("livenessDecision".equals(fieldName)) { + deserializedLivenessResponseBody.livenessDecision + = FaceLivenessDecision.fromString(reader.getString()); + } else if ("target".equals(fieldName)) { + deserializedLivenessResponseBody.target = LivenessOutputsTarget.fromJson(reader); + } else if ("modelVersionUsed".equals(fieldName)) { + deserializedLivenessResponseBody.modelVersionUsed = LivenessModel.fromString(reader.getString()); + } else if ("verifyResult".equals(fieldName)) { + deserializedLivenessResponseBody.verifyResult = LivenessWithVerifyOutputs.fromJson(reader); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + additionalProperties.put(fieldName, reader.readUntyped()); + } + } + deserializedLivenessResponseBody.additionalProperties = additionalProperties; + return deserializedLivenessResponseBody; + }); } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessSession.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessSession.java index daeb5e1046756..79f5a40e7a434 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessSession.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessSession.java @@ -5,42 +5,43 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; /** * Session result of detect liveness. */ @Immutable -public final class LivenessSession { +public final class LivenessSession implements JsonSerializable { /* * The unique ID to reference this session. */ @Generated - @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) private String id; /* * DateTime when this session was created. */ @Generated - @JsonProperty(value = "createdDateTime") private final OffsetDateTime createdDateTime; /* * DateTime when this session was started by the client. */ @Generated - @JsonProperty(value = "sessionStartDateTime") private OffsetDateTime sessionStartDateTime; /* * Whether or not the session is expired. */ @Generated - @JsonProperty(value = "sessionExpired") private final boolean sessionExpired; /* @@ -48,28 +49,24 @@ public final class LivenessSession { * 'deviceCorrelationIdSetInClient' is true in this request, this 'deviceCorrelationId' must be null. */ @Generated - @JsonProperty(value = "deviceCorrelationId") private String deviceCorrelationId; /* * Seconds the session should last for. Range is 60 to 86400 seconds. Default value is 600. */ @Generated - @JsonProperty(value = "authTokenTimeToLiveInSeconds") private Integer authTokenTimeToLiveInSeconds; /* * The current status of the session. */ @Generated - @JsonProperty(value = "status") private final FaceSessionStatus status; /* * The latest session audit result only populated if status == 'ResultAvailable'. */ @Generated - @JsonProperty(value = "result") private LivenessSessionAuditEntry result; /** @@ -80,10 +77,7 @@ public final class LivenessSession { * @param status the status value to set. */ @Generated - @JsonCreator - private LivenessSession(@JsonProperty(value = "createdDateTime") OffsetDateTime createdDateTime, - @JsonProperty(value = "sessionExpired") boolean sessionExpired, - @JsonProperty(value = "status") FaceSessionStatus status) { + private LivenessSession(OffsetDateTime createdDateTime, boolean sessionExpired, FaceSessionStatus status) { this.createdDateTime = createdDateTime; this.sessionExpired = sessionExpired; this.status = status; @@ -171,4 +165,80 @@ public FaceSessionStatus getStatus() { public LivenessSessionAuditEntry getResult() { return this.result; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("createdDateTime", + this.createdDateTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.createdDateTime)); + jsonWriter.writeBooleanField("sessionExpired", this.sessionExpired); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeStringField("sessionStartDateTime", + this.sessionStartDateTime == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.sessionStartDateTime)); + jsonWriter.writeStringField("deviceCorrelationId", this.deviceCorrelationId); + jsonWriter.writeNumberField("authTokenTimeToLiveInSeconds", this.authTokenTimeToLiveInSeconds); + jsonWriter.writeJsonField("result", this.result); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of LivenessSession from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of LivenessSession if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the LivenessSession. + */ + @Generated + public static LivenessSession fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + OffsetDateTime createdDateTime = null; + boolean sessionExpired = false; + FaceSessionStatus status = null; + OffsetDateTime sessionStartDateTime = null; + String deviceCorrelationId = null; + Integer authTokenTimeToLiveInSeconds = null; + LivenessSessionAuditEntry result = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("createdDateTime".equals(fieldName)) { + createdDateTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("sessionExpired".equals(fieldName)) { + sessionExpired = reader.getBoolean(); + } else if ("status".equals(fieldName)) { + status = FaceSessionStatus.fromString(reader.getString()); + } else if ("sessionStartDateTime".equals(fieldName)) { + sessionStartDateTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("deviceCorrelationId".equals(fieldName)) { + deviceCorrelationId = reader.getString(); + } else if ("authTokenTimeToLiveInSeconds".equals(fieldName)) { + authTokenTimeToLiveInSeconds = reader.getNullable(JsonReader::getInt); + } else if ("result".equals(fieldName)) { + result = LivenessSessionAuditEntry.fromJson(reader); + } else { + reader.skipChildren(); + } + } + LivenessSession deserializedLivenessSession = new LivenessSession(createdDateTime, sessionExpired, status); + deserializedLivenessSession.id = id; + deserializedLivenessSession.sessionStartDateTime = sessionStartDateTime; + deserializedLivenessSession.deviceCorrelationId = deviceCorrelationId; + deserializedLivenessSession.authTokenTimeToLiveInSeconds = authTokenTimeToLiveInSeconds; + deserializedLivenessSession.result = result; + return deserializedLivenessSession; + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessSessionAuditEntry.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessSessionAuditEntry.java index 8f812b5c275e5..e535de357e5b1 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessSessionAuditEntry.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessSessionAuditEntry.java @@ -5,22 +5,26 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; /** * Audit entry for a request in session. */ @Immutable -public final class LivenessSessionAuditEntry { +public final class LivenessSessionAuditEntry implements JsonSerializable { /* * The unique id to refer to this audit request. Use this id with the 'start' query parameter to continue on to the * next page of audit results. */ @Generated - @JsonProperty(value = "id") private final long id; /* @@ -28,42 +32,36 @@ public final class LivenessSessionAuditEntry { * sooner using the corresponding session DELETE operation. */ @Generated - @JsonProperty(value = "sessionId") private final String sessionId; /* * The unique requestId that is returned by the service to the client in the 'apim-request-id' header. */ @Generated - @JsonProperty(value = "requestId") private final String requestId; /* * The unique clientRequestId that is sent by the client in the 'client-request-id' header. */ @Generated - @JsonProperty(value = "clientRequestId") private final String clientRequestId; /* * The UTC DateTime that the request was received. */ @Generated - @JsonProperty(value = "receivedDateTime") private final OffsetDateTime receivedDateTime; /* * The request of this entry. */ @Generated - @JsonProperty(value = "request") private final AuditRequestInfo request; /* * The response of this entry. */ @Generated - @JsonProperty(value = "response") private final AuditLivenessResponseInfo response; /* @@ -73,7 +71,6 @@ public final class LivenessSessionAuditEntry { * solution. */ @Generated - @JsonProperty(value = "digest") private final String digest; /** @@ -89,14 +86,8 @@ public final class LivenessSessionAuditEntry { * @param digest the digest value to set. */ @Generated - @JsonCreator - private LivenessSessionAuditEntry(@JsonProperty(value = "id") long id, - @JsonProperty(value = "sessionId") String sessionId, @JsonProperty(value = "requestId") String requestId, - @JsonProperty(value = "clientRequestId") String clientRequestId, - @JsonProperty(value = "receivedDateTime") OffsetDateTime receivedDateTime, - @JsonProperty(value = "request") AuditRequestInfo request, - @JsonProperty(value = "response") AuditLivenessResponseInfo response, - @JsonProperty(value = "digest") String digest) { + private LivenessSessionAuditEntry(long id, String sessionId, String requestId, String clientRequestId, + OffsetDateTime receivedDateTime, AuditRequestInfo request, AuditLivenessResponseInfo response, String digest) { this.id = id; this.sessionId = sessionId; this.requestId = requestId; @@ -193,4 +184,74 @@ public AuditLivenessResponseInfo getResponse() { public String getDigest() { return this.digest; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeLongField("id", this.id); + jsonWriter.writeStringField("sessionId", this.sessionId); + jsonWriter.writeStringField("requestId", this.requestId); + jsonWriter.writeStringField("clientRequestId", this.clientRequestId); + jsonWriter.writeStringField("receivedDateTime", + this.receivedDateTime == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.receivedDateTime)); + jsonWriter.writeJsonField("request", this.request); + jsonWriter.writeJsonField("response", this.response); + jsonWriter.writeStringField("digest", this.digest); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of LivenessSessionAuditEntry from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of LivenessSessionAuditEntry if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the LivenessSessionAuditEntry. + */ + @Generated + public static LivenessSessionAuditEntry fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + long id = 0L; + String sessionId = null; + String requestId = null; + String clientRequestId = null; + OffsetDateTime receivedDateTime = null; + AuditRequestInfo request = null; + AuditLivenessResponseInfo response = null; + String digest = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getLong(); + } else if ("sessionId".equals(fieldName)) { + sessionId = reader.getString(); + } else if ("requestId".equals(fieldName)) { + requestId = reader.getString(); + } else if ("clientRequestId".equals(fieldName)) { + clientRequestId = reader.getString(); + } else if ("receivedDateTime".equals(fieldName)) { + receivedDateTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("request".equals(fieldName)) { + request = AuditRequestInfo.fromJson(reader); + } else if ("response".equals(fieldName)) { + response = AuditLivenessResponseInfo.fromJson(reader); + } else if ("digest".equals(fieldName)) { + digest = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new LivenessSessionAuditEntry(id, sessionId, requestId, clientRequestId, receivedDateTime, request, + response, digest); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessSessionItem.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessSessionItem.java index 016929cab7ac5..e66463f0ca517 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessSessionItem.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessSessionItem.java @@ -5,42 +5,43 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; /** * Session data returned for enumeration. */ @Immutable -public final class LivenessSessionItem { +public final class LivenessSessionItem implements JsonSerializable { /* * The unique ID to reference this session. */ @Generated - @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) private String id; /* * DateTime when this session was created. */ @Generated - @JsonProperty(value = "createdDateTime") private final OffsetDateTime createdDateTime; /* * DateTime when this session was started by the client. */ @Generated - @JsonProperty(value = "sessionStartDateTime") private OffsetDateTime sessionStartDateTime; /* * Whether or not the session is expired. */ @Generated - @JsonProperty(value = "sessionExpired") private final boolean sessionExpired; /* @@ -48,14 +49,12 @@ public final class LivenessSessionItem { * 'deviceCorrelationIdSetInClient' is true in this request, this 'deviceCorrelationId' must be null. */ @Generated - @JsonProperty(value = "deviceCorrelationId") private String deviceCorrelationId; /* * Seconds the session should last for. Range is 60 to 86400 seconds. Default value is 600. */ @Generated - @JsonProperty(value = "authTokenTimeToLiveInSeconds") private Integer authTokenTimeToLiveInSeconds; /** @@ -65,9 +64,7 @@ public final class LivenessSessionItem { * @param sessionExpired the sessionExpired value to set. */ @Generated - @JsonCreator - private LivenessSessionItem(@JsonProperty(value = "createdDateTime") OffsetDateTime createdDateTime, - @JsonProperty(value = "sessionExpired") boolean sessionExpired) { + private LivenessSessionItem(OffsetDateTime createdDateTime, boolean sessionExpired) { this.createdDateTime = createdDateTime; this.sessionExpired = sessionExpired; } @@ -134,4 +131,72 @@ public String getDeviceCorrelationId() { public Integer getAuthTokenTimeToLiveInSeconds() { return this.authTokenTimeToLiveInSeconds; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("createdDateTime", + this.createdDateTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.createdDateTime)); + jsonWriter.writeBooleanField("sessionExpired", this.sessionExpired); + jsonWriter.writeStringField("sessionStartDateTime", + this.sessionStartDateTime == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.sessionStartDateTime)); + jsonWriter.writeStringField("deviceCorrelationId", this.deviceCorrelationId); + jsonWriter.writeNumberField("authTokenTimeToLiveInSeconds", this.authTokenTimeToLiveInSeconds); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of LivenessSessionItem from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of LivenessSessionItem if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the LivenessSessionItem. + */ + @Generated + public static LivenessSessionItem fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + OffsetDateTime createdDateTime = null; + boolean sessionExpired = false; + OffsetDateTime sessionStartDateTime = null; + String deviceCorrelationId = null; + Integer authTokenTimeToLiveInSeconds = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("createdDateTime".equals(fieldName)) { + createdDateTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("sessionExpired".equals(fieldName)) { + sessionExpired = reader.getBoolean(); + } else if ("sessionStartDateTime".equals(fieldName)) { + sessionStartDateTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("deviceCorrelationId".equals(fieldName)) { + deviceCorrelationId = reader.getString(); + } else if ("authTokenTimeToLiveInSeconds".equals(fieldName)) { + authTokenTimeToLiveInSeconds = reader.getNullable(JsonReader::getInt); + } else { + reader.skipChildren(); + } + } + LivenessSessionItem deserializedLivenessSessionItem + = new LivenessSessionItem(createdDateTime, sessionExpired); + deserializedLivenessSessionItem.id = id; + deserializedLivenessSessionItem.sessionStartDateTime = sessionStartDateTime; + deserializedLivenessSessionItem.deviceCorrelationId = deviceCorrelationId; + deserializedLivenessSessionItem.authTokenTimeToLiveInSeconds = authTokenTimeToLiveInSeconds; + return deserializedLivenessSessionItem; + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessWithVerifyImage.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessWithVerifyImage.java index ecfbedb8e8b44..4784c4932adde 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessWithVerifyImage.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessWithVerifyImage.java @@ -5,27 +5,28 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * The detail of face for verification. */ @Immutable -public final class LivenessWithVerifyImage { +public final class LivenessWithVerifyImage implements JsonSerializable { /* * The face region where the comparison image's classification was made. */ @Generated - @JsonProperty(value = "faceRectangle") private final FaceRectangle faceRectangle; /* * Quality of face image for recognition. */ @Generated - @JsonProperty(value = "qualityForRecognition") private final QualityForRecognition qualityForRecognition; /** @@ -35,9 +36,7 @@ public final class LivenessWithVerifyImage { * @param qualityForRecognition the qualityForRecognition value to set. */ @Generated - @JsonCreator - private LivenessWithVerifyImage(@JsonProperty(value = "faceRectangle") FaceRectangle faceRectangle, - @JsonProperty(value = "qualityForRecognition") QualityForRecognition qualityForRecognition) { + private LivenessWithVerifyImage(FaceRectangle faceRectangle, QualityForRecognition qualityForRecognition) { this.faceRectangle = faceRectangle; this.qualityForRecognition = qualityForRecognition; } @@ -61,4 +60,46 @@ public FaceRectangle getFaceRectangle() { public QualityForRecognition getQualityForRecognition() { return this.qualityForRecognition; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("faceRectangle", this.faceRectangle); + jsonWriter.writeStringField("qualityForRecognition", + this.qualityForRecognition == null ? null : this.qualityForRecognition.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of LivenessWithVerifyImage from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of LivenessWithVerifyImage if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the LivenessWithVerifyImage. + */ + @Generated + public static LivenessWithVerifyImage fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FaceRectangle faceRectangle = null; + QualityForRecognition qualityForRecognition = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("faceRectangle".equals(fieldName)) { + faceRectangle = FaceRectangle.fromJson(reader); + } else if ("qualityForRecognition".equals(fieldName)) { + qualityForRecognition = QualityForRecognition.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new LivenessWithVerifyImage(faceRectangle, qualityForRecognition); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessWithVerifyOutputs.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessWithVerifyOutputs.java index 14cd6ac585c9f..155cd96c2565a 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessWithVerifyOutputs.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessWithVerifyOutputs.java @@ -5,34 +5,34 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * The face verification output. */ @Immutable -public final class LivenessWithVerifyOutputs { +public final class LivenessWithVerifyOutputs implements JsonSerializable { /* * The detail of face for verification. */ @Generated - @JsonProperty(value = "verifyImage") private final LivenessWithVerifyImage verifyImage; /* * The target face liveness face and comparison image face verification confidence. */ @Generated - @JsonProperty(value = "matchConfidence") private final double matchConfidence; /* * Whether the target liveness face and comparison image face match. */ @Generated - @JsonProperty(value = "isIdentical") private final boolean isIdentical; /** @@ -43,10 +43,8 @@ public final class LivenessWithVerifyOutputs { * @param isIdentical the isIdentical value to set. */ @Generated - @JsonCreator - private LivenessWithVerifyOutputs(@JsonProperty(value = "verifyImage") LivenessWithVerifyImage verifyImage, - @JsonProperty(value = "matchConfidence") double matchConfidence, - @JsonProperty(value = "isIdentical") boolean isIdentical) { + private LivenessWithVerifyOutputs(LivenessWithVerifyImage verifyImage, double matchConfidence, + boolean isIdentical) { this.verifyImage = verifyImage; this.matchConfidence = matchConfidence; this.isIdentical = isIdentical; @@ -82,4 +80,49 @@ public double getMatchConfidence() { public boolean isIdentical() { return this.isIdentical; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("verifyImage", this.verifyImage); + jsonWriter.writeDoubleField("matchConfidence", this.matchConfidence); + jsonWriter.writeBooleanField("isIdentical", this.isIdentical); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of LivenessWithVerifyOutputs from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of LivenessWithVerifyOutputs if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the LivenessWithVerifyOutputs. + */ + @Generated + public static LivenessWithVerifyOutputs fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + LivenessWithVerifyImage verifyImage = null; + double matchConfidence = 0.0; + boolean isIdentical = false; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("verifyImage".equals(fieldName)) { + verifyImage = LivenessWithVerifyImage.fromJson(reader); + } else if ("matchConfidence".equals(fieldName)) { + matchConfidence = reader.getDouble(); + } else if ("isIdentical".equals(fieldName)) { + isIdentical = reader.getBoolean(); + } else { + reader.skipChildren(); + } + } + return new LivenessWithVerifyOutputs(verifyImage, matchConfidence, isIdentical); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessWithVerifySession.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessWithVerifySession.java index e0cc7cdcab07c..e4f177a95cf82 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessWithVerifySession.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/LivenessWithVerifySession.java @@ -5,42 +5,43 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; /** * Session result of detect liveness with verify. */ @Immutable -public final class LivenessWithVerifySession { +public final class LivenessWithVerifySession implements JsonSerializable { /* * The unique ID to reference this session. */ @Generated - @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) private String id; /* * DateTime when this session was created. */ @Generated - @JsonProperty(value = "createdDateTime") private final OffsetDateTime createdDateTime; /* * DateTime when this session was started by the client. */ @Generated - @JsonProperty(value = "sessionStartDateTime") private OffsetDateTime sessionStartDateTime; /* * Whether or not the session is expired. */ @Generated - @JsonProperty(value = "sessionExpired") private final boolean sessionExpired; /* @@ -48,28 +49,24 @@ public final class LivenessWithVerifySession { * 'deviceCorrelationIdSetInClient' is true in this request, this 'deviceCorrelationId' must be null. */ @Generated - @JsonProperty(value = "deviceCorrelationId") private String deviceCorrelationId; /* * Seconds the session should last for. Range is 60 to 86400 seconds. Default value is 600. */ @Generated - @JsonProperty(value = "authTokenTimeToLiveInSeconds") private Integer authTokenTimeToLiveInSeconds; /* * The current status of the session. */ @Generated - @JsonProperty(value = "status") private final FaceSessionStatus status; /* * The latest session audit result only populated if status == 'ResultAvailable'. */ @Generated - @JsonProperty(value = "result") private LivenessSessionAuditEntry result; /** @@ -80,10 +77,8 @@ public final class LivenessWithVerifySession { * @param status the status value to set. */ @Generated - @JsonCreator - private LivenessWithVerifySession(@JsonProperty(value = "createdDateTime") OffsetDateTime createdDateTime, - @JsonProperty(value = "sessionExpired") boolean sessionExpired, - @JsonProperty(value = "status") FaceSessionStatus status) { + private LivenessWithVerifySession(OffsetDateTime createdDateTime, boolean sessionExpired, + FaceSessionStatus status) { this.createdDateTime = createdDateTime; this.sessionExpired = sessionExpired; this.status = status; @@ -171,4 +166,81 @@ public FaceSessionStatus getStatus() { public LivenessSessionAuditEntry getResult() { return this.result; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("createdDateTime", + this.createdDateTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.createdDateTime)); + jsonWriter.writeBooleanField("sessionExpired", this.sessionExpired); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeStringField("sessionStartDateTime", + this.sessionStartDateTime == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.sessionStartDateTime)); + jsonWriter.writeStringField("deviceCorrelationId", this.deviceCorrelationId); + jsonWriter.writeNumberField("authTokenTimeToLiveInSeconds", this.authTokenTimeToLiveInSeconds); + jsonWriter.writeJsonField("result", this.result); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of LivenessWithVerifySession from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of LivenessWithVerifySession if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the LivenessWithVerifySession. + */ + @Generated + public static LivenessWithVerifySession fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + OffsetDateTime createdDateTime = null; + boolean sessionExpired = false; + FaceSessionStatus status = null; + OffsetDateTime sessionStartDateTime = null; + String deviceCorrelationId = null; + Integer authTokenTimeToLiveInSeconds = null; + LivenessSessionAuditEntry result = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("createdDateTime".equals(fieldName)) { + createdDateTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("sessionExpired".equals(fieldName)) { + sessionExpired = reader.getBoolean(); + } else if ("status".equals(fieldName)) { + status = FaceSessionStatus.fromString(reader.getString()); + } else if ("sessionStartDateTime".equals(fieldName)) { + sessionStartDateTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("deviceCorrelationId".equals(fieldName)) { + deviceCorrelationId = reader.getString(); + } else if ("authTokenTimeToLiveInSeconds".equals(fieldName)) { + authTokenTimeToLiveInSeconds = reader.getNullable(JsonReader::getInt); + } else if ("result".equals(fieldName)) { + result = LivenessSessionAuditEntry.fromJson(reader); + } else { + reader.skipChildren(); + } + } + LivenessWithVerifySession deserializedLivenessWithVerifySession + = new LivenessWithVerifySession(createdDateTime, sessionExpired, status); + deserializedLivenessWithVerifySession.id = id; + deserializedLivenessWithVerifySession.sessionStartDateTime = sessionStartDateTime; + deserializedLivenessWithVerifySession.deviceCorrelationId = deviceCorrelationId; + deserializedLivenessWithVerifySession.authTokenTimeToLiveInSeconds = authTokenTimeToLiveInSeconds; + deserializedLivenessWithVerifySession.result = result; + return deserializedLivenessWithVerifySession; + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/MaskProperties.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/MaskProperties.java index 7e18fd901bcec..e5ea002e7d0ac 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/MaskProperties.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/MaskProperties.java @@ -5,27 +5,28 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * Properties describing the presence of a mask on a given face. */ @Immutable -public final class MaskProperties { +public final class MaskProperties implements JsonSerializable { /* * A boolean value indicating whether nose and mouth are covered. */ @Generated - @JsonProperty(value = "noseAndMouthCovered") private final boolean noseAndMouthCovered; /* * Type of the mask. */ @Generated - @JsonProperty(value = "type") private final MaskType type; /** @@ -35,9 +36,7 @@ public final class MaskProperties { * @param type the type value to set. */ @Generated - @JsonCreator - private MaskProperties(@JsonProperty(value = "noseAndMouthCovered") boolean noseAndMouthCovered, - @JsonProperty(value = "type") MaskType type) { + private MaskProperties(boolean noseAndMouthCovered, MaskType type) { this.noseAndMouthCovered = noseAndMouthCovered; this.type = type; } @@ -61,4 +60,45 @@ public boolean isNoseAndMouthCovered() { public MaskType getType() { return this.type; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("noseAndMouthCovered", this.noseAndMouthCovered); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MaskProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MaskProperties if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MaskProperties. + */ + @Generated + public static MaskProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean noseAndMouthCovered = false; + MaskType type = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("noseAndMouthCovered".equals(fieldName)) { + noseAndMouthCovered = reader.getBoolean(); + } else if ("type".equals(fieldName)) { + type = MaskType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new MaskProperties(noseAndMouthCovered, type); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/MaskType.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/MaskType.java index f06707c4818bc..4746aa2c1b6fa 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/MaskType.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/MaskType.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -54,7 +53,6 @@ public MaskType() { * @return the corresponding MaskType. */ @Generated - @JsonCreator public static MaskType fromString(String name) { return fromString(name, MaskType.class); } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/NoiseLevel.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/NoiseLevel.java index f04310c164596..c0c738deffaba 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/NoiseLevel.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/NoiseLevel.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -48,7 +47,6 @@ public NoiseLevel() { * @return the corresponding NoiseLevel. */ @Generated - @JsonCreator public static NoiseLevel fromString(String name) { return fromString(name, NoiseLevel.class); } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/NoiseProperties.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/NoiseProperties.java index c1ccfb5cdacdc..55c6615e505f1 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/NoiseProperties.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/NoiseProperties.java @@ -5,20 +5,22 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * Properties describing noise level of the image. */ @Immutable -public final class NoiseProperties { +public final class NoiseProperties implements JsonSerializable { /* * An enum value indicating level of noise. */ @Generated - @JsonProperty(value = "noiseLevel") private final NoiseLevel noiseLevel; /* @@ -27,7 +29,6 @@ public final class NoiseProperties { * high noise level. */ @Generated - @JsonProperty(value = "value") private final double value; /** @@ -37,9 +38,7 @@ public final class NoiseProperties { * @param value the value value to set. */ @Generated - @JsonCreator - private NoiseProperties(@JsonProperty(value = "noiseLevel") NoiseLevel noiseLevel, - @JsonProperty(value = "value") double value) { + private NoiseProperties(NoiseLevel noiseLevel, double value) { this.noiseLevel = noiseLevel; this.value = value; } @@ -65,4 +64,45 @@ public NoiseLevel getNoiseLevel() { public double getValue() { return this.value; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("noiseLevel", this.noiseLevel == null ? null : this.noiseLevel.toString()); + jsonWriter.writeDoubleField("value", this.value); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of NoiseProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of NoiseProperties if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the NoiseProperties. + */ + @Generated + public static NoiseProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + NoiseLevel noiseLevel = null; + double value = 0.0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("noiseLevel".equals(fieldName)) { + noiseLevel = NoiseLevel.fromString(reader.getString()); + } else if ("value".equals(fieldName)) { + value = reader.getDouble(); + } else { + reader.skipChildren(); + } + } + return new NoiseProperties(noiseLevel, value); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/OcclusionProperties.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/OcclusionProperties.java index 76370c67a8c2c..d89d07bbee5d6 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/OcclusionProperties.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/OcclusionProperties.java @@ -5,34 +5,34 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * Properties describing occlusions on a given face. */ @Immutable -public final class OcclusionProperties { +public final class OcclusionProperties implements JsonSerializable { /* * A boolean value indicating whether forehead is occluded. */ @Generated - @JsonProperty(value = "foreheadOccluded") private final boolean foreheadOccluded; /* * A boolean value indicating whether eyes are occluded. */ @Generated - @JsonProperty(value = "eyeOccluded") private final boolean eyeOccluded; /* * A boolean value indicating whether the mouth is occluded. */ @Generated - @JsonProperty(value = "mouthOccluded") private final boolean mouthOccluded; /** @@ -43,10 +43,7 @@ public final class OcclusionProperties { * @param mouthOccluded the mouthOccluded value to set. */ @Generated - @JsonCreator - private OcclusionProperties(@JsonProperty(value = "foreheadOccluded") boolean foreheadOccluded, - @JsonProperty(value = "eyeOccluded") boolean eyeOccluded, - @JsonProperty(value = "mouthOccluded") boolean mouthOccluded) { + private OcclusionProperties(boolean foreheadOccluded, boolean eyeOccluded, boolean mouthOccluded) { this.foreheadOccluded = foreheadOccluded; this.eyeOccluded = eyeOccluded; this.mouthOccluded = mouthOccluded; @@ -81,4 +78,49 @@ public boolean isEyeOccluded() { public boolean isMouthOccluded() { return this.mouthOccluded; } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("foreheadOccluded", this.foreheadOccluded); + jsonWriter.writeBooleanField("eyeOccluded", this.eyeOccluded); + jsonWriter.writeBooleanField("mouthOccluded", this.mouthOccluded); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OcclusionProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OcclusionProperties if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the OcclusionProperties. + */ + @Generated + public static OcclusionProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean foreheadOccluded = false; + boolean eyeOccluded = false; + boolean mouthOccluded = false; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("foreheadOccluded".equals(fieldName)) { + foreheadOccluded = reader.getBoolean(); + } else if ("eyeOccluded".equals(fieldName)) { + eyeOccluded = reader.getBoolean(); + } else if ("mouthOccluded".equals(fieldName)) { + mouthOccluded = reader.getBoolean(); + } else { + reader.skipChildren(); + } + } + return new OcclusionProperties(foreheadOccluded, eyeOccluded, mouthOccluded); + }); + } } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/QualityForRecognition.java b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/QualityForRecognition.java index 83f56956db8a7..6247a5d38afcb 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/QualityForRecognition.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/com/azure/ai/vision/face/models/QualityForRecognition.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -48,7 +47,6 @@ public QualityForRecognition() { * @return the corresponding QualityForRecognition. */ @Generated - @JsonCreator public static QualityForRecognition fromString(String name) { return fromString(name, QualityForRecognition.class); } diff --git a/sdk/face/azure-ai-vision-face/src/main/java/module-info.java b/sdk/face/azure-ai-vision-face/src/main/java/module-info.java index 96d9239add9aa..5f89d71fec9c8 100644 --- a/sdk/face/azure-ai-vision-face/src/main/java/module-info.java +++ b/sdk/face/azure-ai-vision-face/src/main/java/module-info.java @@ -6,6 +6,6 @@ requires transitive com.azure.core; exports com.azure.ai.vision.face; exports com.azure.ai.vision.face.models; - opens com.azure.ai.vision.face.implementation.models to com.azure.core, com.fasterxml.jackson.databind; - opens com.azure.ai.vision.face.models to com.azure.core, com.fasterxml.jackson.databind; + opens com.azure.ai.vision.face.implementation.models to com.azure.core; + opens com.azure.ai.vision.face.models to com.azure.core; } diff --git a/sdk/face/azure-ai-vision-face/src/samples/java/com/azure/ai/vision/face/samples/utils/Utils.java b/sdk/face/azure-ai-vision-face/src/samples/java/com/azure/ai/vision/face/samples/utils/Utils.java index 87f27973970fc..8a00f8bd61c95 100644 --- a/sdk/face/azure-ai-vision-face/src/samples/java/com/azure/ai/vision/face/samples/utils/Utils.java +++ b/sdk/face/azure-ai-vision-face/src/samples/java/com/azure/ai/vision/face/samples/utils/Utils.java @@ -4,12 +4,6 @@ package com.azure.ai.vision.face.samples.utils; import com.azure.core.util.BinaryData; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.databind.json.JsonMapper; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import java.nio.file.Path; import java.nio.file.Paths; @@ -20,18 +14,6 @@ public final class Utils { private static final SimpleDateFormat LOG_DATE_FORMAT = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss.SSS"); - private static final ObjectMapper OBJECT_MAPPER = JsonMapper - .builder() - .addModule(new JavaTimeModule()) - .build() - .setSerializationInclusion(JsonInclude.Include.NON_NULL); - - private static final ObjectMapper BEAUTIFY_OBJECT_MAPPER = JsonMapper - .builder() - .addModule(new JavaTimeModule()) - .build() - .enable(SerializationFeature.INDENT_OUTPUT) - .setSerializationInclusion(JsonInclude.Include.NON_NULL); private Utils() {} @@ -66,11 +48,7 @@ public static String toString(Object object) { } public static String toString(Object object, boolean indentOutput) { - try { - return (indentOutput ? BEAUTIFY_OBJECT_MAPPER : OBJECT_MAPPER).writeValueAsString(object); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } + return BinaryData.fromObject(object).toString(); } public static BinaryData loadFromFile(String pathString) { diff --git a/sdk/face/azure-ai-vision-face/tsp-location.yaml b/sdk/face/azure-ai-vision-face/tsp-location.yaml index 799b092c9ba5c..2c62f2c0b27b2 100644 --- a/sdk/face/azure-ai-vision-face/tsp-location.yaml +++ b/sdk/face/azure-ai-vision-face/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/ai/Face -commit: df3cd3e3d50eec1d1da593750e1ea3a4db3f541d +commit: 876c4ba5af4413894802dc9de8f7a9cf3ead76aa repo: Azure/azure-rest-api-specs additionalDirectories: null