|
1 | 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
2 | 2 | // Licensed under the MIT License. |
3 | 3 | // Code generated by Microsoft (R) AutoRest Code Generator. |
4 | | - |
5 | 4 | package com.azure.ai.personalizer.administration.models; |
6 | 5 |
|
7 | 6 | import com.azure.ai.personalizer.models.EvaluationJobStatus; |
8 | 7 | import com.azure.ai.personalizer.models.EvaluationType; |
9 | 8 | import com.azure.core.annotation.Fluent; |
10 | | -import com.fasterxml.jackson.annotation.JsonProperty; |
| 9 | +import com.azure.core.util.CoreUtils; |
| 10 | +import com.azure.json.JsonReader; |
| 11 | +import com.azure.json.JsonSerializable; |
| 12 | +import com.azure.json.JsonToken; |
| 13 | +import com.azure.json.JsonWriter; |
| 14 | +import java.io.IOException; |
11 | 15 | import java.time.OffsetDateTime; |
| 16 | +import java.time.format.DateTimeFormatter; |
12 | 17 | import java.util.List; |
13 | 18 |
|
14 | | -/** A counterfactual evaluation. */ |
| 19 | +/** |
| 20 | + * A counterfactual evaluation. |
| 21 | + */ |
15 | 22 | @Fluent |
16 | | -public final class PersonalizerEvaluation { |
| 23 | +public final class PersonalizerEvaluation implements JsonSerializable<PersonalizerEvaluation> { |
| 24 | + |
17 | 25 | /* |
18 | 26 | * The ID of the evaluation. |
19 | 27 | */ |
20 | | - @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) |
21 | 28 | private String id; |
22 | 29 |
|
23 | 30 | /* |
24 | 31 | * The name of the evaluation. |
25 | 32 | */ |
26 | | - @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) |
27 | 33 | private String name; |
28 | 34 |
|
29 | 35 | /* |
30 | 36 | * The start time of the evaluation. |
31 | 37 | */ |
32 | | - @JsonProperty(value = "startTime", access = JsonProperty.Access.WRITE_ONLY) |
33 | 38 | private OffsetDateTime startTime; |
34 | 39 |
|
35 | 40 | /* |
36 | 41 | * The end time of the evaluation. |
37 | 42 | */ |
38 | | - @JsonProperty(value = "endTime", access = JsonProperty.Access.WRITE_ONLY) |
39 | 43 | private OffsetDateTime endTime; |
40 | 44 |
|
41 | 45 | /* |
42 | 46 | * The ID of the job processing the evaluation. |
43 | 47 | */ |
44 | | - @JsonProperty(value = "jobId", access = JsonProperty.Access.WRITE_ONLY) |
45 | 48 | private String jobId; |
46 | 49 |
|
47 | 50 | /* |
48 | 51 | * The status of the job processing the evaluation. |
49 | 52 | */ |
50 | | - @JsonProperty(value = "status", access = JsonProperty.Access.WRITE_ONLY) |
51 | 53 | private EvaluationJobStatus status; |
52 | 54 |
|
53 | 55 | /* |
54 | 56 | * The results of the evaluation. |
55 | 57 | */ |
56 | | - @JsonProperty(value = "policyResults") |
57 | 58 | private List<PersonalizerPolicyResult> policyResults; |
58 | 59 |
|
59 | 60 | /* |
60 | 61 | * Feature Importance. |
61 | 62 | */ |
62 | | - @JsonProperty(value = "featureImportance") |
63 | 63 | private List<List<String>> featureImportance; |
64 | 64 |
|
65 | 65 | /* |
66 | 66 | * Evaluation type (manual or through Automatic Optimization). |
67 | 67 | */ |
68 | | - @JsonProperty(value = "evaluationType") |
69 | 68 | private EvaluationType evaluationType; |
70 | 69 |
|
71 | 70 | /* |
72 | 71 | * Thr optimal policy. |
73 | 72 | */ |
74 | | - @JsonProperty(value = "optimalPolicy") |
75 | 73 | private String optimalPolicy; |
76 | 74 |
|
77 | 75 | /* |
78 | 76 | * Creation time. |
79 | 77 | */ |
80 | | - @JsonProperty(value = "creationTime") |
81 | 78 | private OffsetDateTime creationTime; |
82 | 79 |
|
| 80 | + /** |
| 81 | + * Creates an instance of PersonalizerEvaluation class. |
| 82 | + */ |
| 83 | + public PersonalizerEvaluation() { |
| 84 | + } |
| 85 | + |
83 | 86 | /** |
84 | 87 | * Get the id property: The ID of the evaluation. |
85 | 88 | * |
@@ -233,4 +236,72 @@ PersonalizerEvaluation setCreationTime(OffsetDateTime creationTime) { |
233 | 236 | this.creationTime = creationTime; |
234 | 237 | return this; |
235 | 238 | } |
| 239 | + |
| 240 | + /** |
| 241 | + * {@inheritDoc} |
| 242 | + */ |
| 243 | + @Override |
| 244 | + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { |
| 245 | + jsonWriter.writeStartObject(); |
| 246 | + jsonWriter.writeArrayField("policyResults", this.policyResults, (writer, element) -> writer.writeJson(element)); |
| 247 | + jsonWriter.writeArrayField("featureImportance", this.featureImportance, |
| 248 | + (writer, element) -> writer.writeArray(element, (writer1, element1) -> writer1.writeString(element1))); |
| 249 | + jsonWriter.writeStringField("evaluationType", |
| 250 | + this.evaluationType == null ? null : this.evaluationType.toString()); |
| 251 | + jsonWriter.writeStringField("optimalPolicy", this.optimalPolicy); |
| 252 | + jsonWriter.writeStringField("creationTime", |
| 253 | + this.creationTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.creationTime)); |
| 254 | + return jsonWriter.writeEndObject(); |
| 255 | + } |
| 256 | + |
| 257 | + /** |
| 258 | + * Reads an instance of PersonalizerEvaluation from the JsonReader. |
| 259 | + * |
| 260 | + * @param jsonReader The JsonReader being read. |
| 261 | + * @return An instance of PersonalizerEvaluation if the JsonReader was pointing to an instance of it, or null if it |
| 262 | + * was pointing to JSON null. |
| 263 | + * @throws IOException If an error occurs while reading the PersonalizerEvaluation. |
| 264 | + */ |
| 265 | + public static PersonalizerEvaluation fromJson(JsonReader jsonReader) throws IOException { |
| 266 | + return jsonReader.readObject(reader -> { |
| 267 | + PersonalizerEvaluation deserializedPersonalizerEvaluation = new PersonalizerEvaluation(); |
| 268 | + while (reader.nextToken() != JsonToken.END_OBJECT) { |
| 269 | + String fieldName = reader.getFieldName(); |
| 270 | + reader.nextToken(); |
| 271 | + if ("id".equals(fieldName)) { |
| 272 | + deserializedPersonalizerEvaluation.id = reader.getString(); |
| 273 | + } else if ("name".equals(fieldName)) { |
| 274 | + deserializedPersonalizerEvaluation.name = reader.getString(); |
| 275 | + } else if ("startTime".equals(fieldName)) { |
| 276 | + deserializedPersonalizerEvaluation.startTime = reader |
| 277 | + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); |
| 278 | + } else if ("endTime".equals(fieldName)) { |
| 279 | + deserializedPersonalizerEvaluation.endTime = reader |
| 280 | + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); |
| 281 | + } else if ("jobId".equals(fieldName)) { |
| 282 | + deserializedPersonalizerEvaluation.jobId = reader.getString(); |
| 283 | + } else if ("status".equals(fieldName)) { |
| 284 | + deserializedPersonalizerEvaluation.status = EvaluationJobStatus.fromString(reader.getString()); |
| 285 | + } else if ("policyResults".equals(fieldName)) { |
| 286 | + List<PersonalizerPolicyResult> policyResults |
| 287 | + = reader.readArray(reader1 -> PersonalizerPolicyResult.fromJson(reader1)); |
| 288 | + deserializedPersonalizerEvaluation.policyResults = policyResults; |
| 289 | + } else if ("featureImportance".equals(fieldName)) { |
| 290 | + List<List<String>> featureImportance |
| 291 | + = reader.readArray(reader1 -> reader1.readArray(reader2 -> reader2.getString())); |
| 292 | + deserializedPersonalizerEvaluation.featureImportance = featureImportance; |
| 293 | + } else if ("evaluationType".equals(fieldName)) { |
| 294 | + deserializedPersonalizerEvaluation.evaluationType = EvaluationType.fromString(reader.getString()); |
| 295 | + } else if ("optimalPolicy".equals(fieldName)) { |
| 296 | + deserializedPersonalizerEvaluation.optimalPolicy = reader.getString(); |
| 297 | + } else if ("creationTime".equals(fieldName)) { |
| 298 | + deserializedPersonalizerEvaluation.creationTime = reader |
| 299 | + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); |
| 300 | + } else { |
| 301 | + reader.skipChildren(); |
| 302 | + } |
| 303 | + } |
| 304 | + return deserializedPersonalizerEvaluation; |
| 305 | + }); |
| 306 | + } |
236 | 307 | } |
0 commit comments