diff --git a/sdk/textanalytics/azure-ai-textanalytics/assets.json b/sdk/textanalytics/azure-ai-textanalytics/assets.json index e890d97cd4c6..55b1d7fbafa0 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/assets.json +++ b/sdk/textanalytics/azure-ai-textanalytics/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "java", "TagPrefix": "java/textanalytics/azure-ai-textanalytics", - "Tag": "java/textanalytics/azure-ai-textanalytics_fbd1568119" + "Tag": "java/textanalytics/azure-ai-textanalytics_15b7c8efde" } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/AnalyzeTextsImpl.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/AnalyzeTextsImpl.java index 04e7d3e4e7e3..057c04389596 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/AnalyzeTextsImpl.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/AnalyzeTextsImpl.java @@ -4,8 +4,8 @@ package com.azure.ai.textanalytics.implementation; -import com.azure.ai.textanalytics.implementation.models.AnalyzeTextJobState; import com.azure.ai.textanalytics.implementation.models.AnalyzeTextJobsInput; +import com.azure.ai.textanalytics.implementation.models.AnalyzeTextJobState; import com.azure.ai.textanalytics.implementation.models.AnalyzeTextsCancelJobHeaders; import com.azure.ai.textanalytics.implementation.models.AnalyzeTextsSubmitJobHeaders; import com.azure.ai.textanalytics.implementation.models.ErrorResponseException; @@ -30,22 +30,28 @@ import java.util.UUID; import reactor.core.publisher.Mono; -/** An instance of this class provides access to all the operations defined in AnalyzeTexts. */ +/** + * An instance of this class provides access to all the operations defined in AnalyzeTexts. + */ public final class AnalyzeTextsImpl { - /** The proxy service used to perform REST calls. */ + /** + * The proxy service used to perform REST calls. + */ private final AnalyzeTextsService service; - /** The service client containing this operation class. */ + /** + * The service client containing this operation class. + */ private final MicrosoftCognitiveLanguageServiceTextAnalysisImpl client; /** * Initializes an instance of AnalyzeTextsImpl. - * + * * @param client the instance of the service client containing this operation class. */ AnalyzeTextsImpl(MicrosoftCognitiveLanguageServiceTextAnalysisImpl client) { - this.service = - RestProxy.create(AnalyzeTextsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.service + = RestProxy.create(AnalyzeTextsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); this.client = client; } @@ -57,78 +63,56 @@ public final class AnalyzeTextsImpl { @ServiceInterface(name = "MicrosoftCognitiveLa") public interface AnalyzeTextsService { @Post("/analyze-text/jobs") - @ExpectedResponses({202}) + @ExpectedResponses({ 202 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> submitJob( - @HostParam("Endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") AnalyzeTextJobsInput body, - @HeaderParam("Accept") String accept, - Context context); + Mono> submitJob(@HostParam("Endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @BodyParam("application/json") AnalyzeTextJobsInput body, + @HeaderParam("Accept") String accept, Context context); @Post("/analyze-text/jobs") - @ExpectedResponses({202}) + @ExpectedResponses({ 202 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - ResponseBase submitJobSync( - @HostParam("Endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") AnalyzeTextJobsInput body, - @HeaderParam("Accept") String accept, - Context context); + ResponseBase submitJobSync(@HostParam("Endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @BodyParam("application/json") AnalyzeTextJobsInput body, + @HeaderParam("Accept") String accept, Context context); @Get("/analyze-text/jobs/{jobId}") - @ExpectedResponses({200}) + @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> jobStatus( - @HostParam("Endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @PathParam("jobId") UUID jobId, - @QueryParam("showStats") Boolean showStats, - @QueryParam("top") Integer top, - @QueryParam("skip") Integer skip, - @HeaderParam("Accept") String accept, - Context context); + Mono> jobStatus(@HostParam("Endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("jobId") UUID jobId, + @QueryParam("showStats") Boolean showStats, @QueryParam("top") Integer top, + @QueryParam("skip") Integer skip, @HeaderParam("Accept") String accept, Context context); @Get("/analyze-text/jobs/{jobId}") - @ExpectedResponses({200}) + @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Response jobStatusSync( - @HostParam("Endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @PathParam("jobId") UUID jobId, - @QueryParam("showStats") Boolean showStats, - @QueryParam("top") Integer top, - @QueryParam("skip") Integer skip, - @HeaderParam("Accept") String accept, - Context context); + Response jobStatusSync(@HostParam("Endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("jobId") UUID jobId, + @QueryParam("showStats") Boolean showStats, @QueryParam("top") Integer top, + @QueryParam("skip") Integer skip, @HeaderParam("Accept") String accept, Context context); @Post("/analyze-text/jobs/{jobId}:cancel") - @ExpectedResponses({202}) + @ExpectedResponses({ 202 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> cancelJob( - @HostParam("Endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @PathParam("jobId") UUID jobId, - @HeaderParam("Accept") String accept, - Context context); + Mono> cancelJob(@HostParam("Endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("jobId") UUID jobId, + @HeaderParam("Accept") String accept, Context context); @Post("/analyze-text/jobs/{jobId}:cancel") - @ExpectedResponses({202}) + @ExpectedResponses({ 202 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - ResponseBase cancelJobSync( - @HostParam("Endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @PathParam("jobId") UUID jobId, - @HeaderParam("Accept") String accept, - Context context); + ResponseBase cancelJobSync(@HostParam("Endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("jobId") UUID jobId, + @HeaderParam("Accept") String accept, Context context); } /** * Submit text analysis job - * - *

Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed as a + * + * Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed as a * long-running operation. - * + * * @param body Collection of documents to analyze and one or more tasks to execute. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -136,21 +120,19 @@ ResponseBase cancelJobSync( * @return the {@link ResponseBase} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> submitJobWithResponseAsync( - AnalyzeTextJobsInput body) { + public Mono> + submitJobWithResponseAsync(AnalyzeTextJobsInput body) { final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.submitJob( - this.client.getEndpoint(), this.client.getApiVersion(), body, accept, context)); + return FluxUtil.withContext(context -> service.submitJob(this.client.getEndpoint(), this.client.getApiVersion(), + body, accept, context)); } /** * Submit text analysis job - * - *

Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed as a + * + * Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed as a * long-running operation. - * + * * @param body Collection of documents to analyze and one or more tasks to execute. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -159,18 +141,18 @@ public Mono> submitJobWithRespo * @return the {@link ResponseBase} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> submitJobWithResponseAsync( - AnalyzeTextJobsInput body, Context context) { + public Mono> submitJobWithResponseAsync(AnalyzeTextJobsInput body, + Context context) { final String accept = "application/json"; return service.submitJob(this.client.getEndpoint(), this.client.getApiVersion(), body, accept, context); } /** * Submit text analysis job - * - *

Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed as a + * + * Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed as a * long-running operation. - * + * * @param body Collection of documents to analyze and one or more tasks to execute. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -184,10 +166,10 @@ public Mono submitJobAsync(AnalyzeTextJobsInput body) { /** * Submit text analysis job - * - *

Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed as a + * + * Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed as a * long-running operation. - * + * * @param body Collection of documents to analyze and one or more tasks to execute. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -202,10 +184,10 @@ public Mono submitJobAsync(AnalyzeTextJobsInput body, Context context) { /** * Submit text analysis job - * - *

Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed as a + * + * Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed as a * long-running operation. - * + * * @param body Collection of documents to analyze and one or more tasks to execute. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -214,18 +196,18 @@ public Mono submitJobAsync(AnalyzeTextJobsInput body, Context context) { * @return the {@link ResponseBase}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase submitJobWithResponse( - AnalyzeTextJobsInput body, Context context) { + public ResponseBase submitJobWithResponse(AnalyzeTextJobsInput body, + Context context) { final String accept = "application/json"; return service.submitJobSync(this.client.getEndpoint(), this.client.getApiVersion(), body, accept, context); } /** * Submit text analysis job - * - *

Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed as a + * + * Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed as a * long-running operation. - * + * * @param body Collection of documents to analyze and one or more tasks to execute. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -238,10 +220,10 @@ public void submitJob(AnalyzeTextJobsInput body) { /** * Get analysis status and results - * - *

Get the status of an analysis job. A job may consist of one or more tasks. Once all tasks are succeeded, the - * job will transition to the succeeded state and results will be available for each task. - * + * + * Get the status of an analysis job. A job may consist of one or more tasks. Once all tasks are succeeded, the job + * will transition to the succeeded state and results will be available for each task. + * * @param jobId Job ID. * @param showStats (Optional) if set to true, response will contain request and document level statistics. * @param top The maximum number of resources to return from the collection. @@ -252,28 +234,19 @@ public void submitJob(AnalyzeTextJobsInput body) { * @return the status of an analysis job along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> jobStatusWithResponseAsync( - UUID jobId, Boolean showStats, Integer top, Integer skip) { + public Mono> jobStatusWithResponseAsync(UUID jobId, Boolean showStats, Integer top, + Integer skip) { final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.jobStatus( - this.client.getEndpoint(), - this.client.getApiVersion(), - jobId, - showStats, - top, - skip, - accept, - context)); + return FluxUtil.withContext(context -> service.jobStatus(this.client.getEndpoint(), this.client.getApiVersion(), + jobId, showStats, top, skip, accept, context)); } /** * Get analysis status and results - * - *

Get the status of an analysis job. A job may consist of one or more tasks. Once all tasks are succeeded, the - * job will transition to the succeeded state and results will be available for each task. - * + * + * Get the status of an analysis job. A job may consist of one or more tasks. Once all tasks are succeeded, the job + * will transition to the succeeded state and results will be available for each task. + * * @param jobId Job ID. * @param showStats (Optional) if set to true, response will contain request and document level statistics. * @param top The maximum number of resources to return from the collection. @@ -285,19 +258,19 @@ public Mono> jobStatusWithResponseAsync( * @return the status of an analysis job along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> jobStatusWithResponseAsync( - UUID jobId, Boolean showStats, Integer top, Integer skip, Context context) { + public Mono> jobStatusWithResponseAsync(UUID jobId, Boolean showStats, Integer top, + Integer skip, Context context) { final String accept = "application/json"; - return service.jobStatus( - this.client.getEndpoint(), this.client.getApiVersion(), jobId, showStats, top, skip, accept, context); + return service.jobStatus(this.client.getEndpoint(), this.client.getApiVersion(), jobId, showStats, top, skip, + accept, context); } /** * Get analysis status and results - * - *

Get the status of an analysis job. A job may consist of one or more tasks. Once all tasks are succeeded, the - * job will transition to the succeeded state and results will be available for each task. - * + * + * Get the status of an analysis job. A job may consist of one or more tasks. Once all tasks are succeeded, the job + * will transition to the succeeded state and results will be available for each task. + * * @param jobId Job ID. * @param showStats (Optional) if set to true, response will contain request and document level statistics. * @param top The maximum number of resources to return from the collection. @@ -314,10 +287,10 @@ public Mono jobStatusAsync(UUID jobId, Boolean showStats, I /** * Get analysis status and results - * - *

Get the status of an analysis job. A job may consist of one or more tasks. Once all tasks are succeeded, the - * job will transition to the succeeded state and results will be available for each task. - * + * + * Get the status of an analysis job. A job may consist of one or more tasks. Once all tasks are succeeded, the job + * will transition to the succeeded state and results will be available for each task. + * * @param jobId Job ID. * @param showStats (Optional) if set to true, response will contain request and document level statistics. * @param top The maximum number of resources to return from the collection. @@ -329,18 +302,18 @@ public Mono jobStatusAsync(UUID jobId, Boolean showStats, I * @return the status of an analysis job on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono jobStatusAsync( - UUID jobId, Boolean showStats, Integer top, Integer skip, Context context) { + public Mono jobStatusAsync(UUID jobId, Boolean showStats, Integer top, Integer skip, + Context context) { return jobStatusWithResponseAsync(jobId, showStats, top, skip, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); + .flatMap(res -> Mono.justOrEmpty(res.getValue())); } /** * Get analysis status and results - * - *

Get the status of an analysis job. A job may consist of one or more tasks. Once all tasks are succeeded, the - * job will transition to the succeeded state and results will be available for each task. - * + * + * Get the status of an analysis job. A job may consist of one or more tasks. Once all tasks are succeeded, the job + * will transition to the succeeded state and results will be available for each task. + * * @param jobId Job ID. * @param showStats (Optional) if set to true, response will contain request and document level statistics. * @param top The maximum number of resources to return from the collection. @@ -352,19 +325,19 @@ public Mono jobStatusAsync( * @return the status of an analysis job along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response jobStatusWithResponse( - UUID jobId, Boolean showStats, Integer top, Integer skip, Context context) { + public Response jobStatusWithResponse(UUID jobId, Boolean showStats, Integer top, Integer skip, + Context context) { final String accept = "application/json"; - return service.jobStatusSync( - this.client.getEndpoint(), this.client.getApiVersion(), jobId, showStats, top, skip, accept, context); + return service.jobStatusSync(this.client.getEndpoint(), this.client.getApiVersion(), jobId, showStats, top, + skip, accept, context); } /** * Get analysis status and results - * - *

Get the status of an analysis job. A job may consist of one or more tasks. Once all tasks are succeeded, the - * job will transition to the succeeded state and results will be available for each task. - * + * + * Get the status of an analysis job. A job may consist of one or more tasks. Once all tasks are succeeded, the job + * will transition to the succeeded state and results will be available for each task. + * * @param jobId Job ID. * @param showStats (Optional) if set to true, response will contain request and document level statistics. * @param top The maximum number of resources to return from the collection. @@ -381,9 +354,9 @@ public AnalyzeTextJobState jobStatus(UUID jobId, Boolean showStats, Integer top, /** * Cancel a long-running Text Analysis job - * - *

Cancel a long-running Text Analysis job. - * + * + * Cancel a long-running Text Analysis job. + * * @param jobId Job ID. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -393,17 +366,15 @@ public AnalyzeTextJobState jobStatus(UUID jobId, Boolean showStats, Integer top, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> cancelJobWithResponseAsync(UUID jobId) { final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.cancelJob( - this.client.getEndpoint(), this.client.getApiVersion(), jobId, accept, context)); + return FluxUtil.withContext(context -> service.cancelJob(this.client.getEndpoint(), this.client.getApiVersion(), + jobId, accept, context)); } /** * Cancel a long-running Text Analysis job - * - *

Cancel a long-running Text Analysis job. - * + * + * Cancel a long-running Text Analysis job. + * * @param jobId Job ID. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -412,17 +383,17 @@ public Mono> cancelJobWithRespo * @return the {@link ResponseBase} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> cancelJobWithResponseAsync( - UUID jobId, Context context) { + public Mono> cancelJobWithResponseAsync(UUID jobId, + Context context) { final String accept = "application/json"; return service.cancelJob(this.client.getEndpoint(), this.client.getApiVersion(), jobId, accept, context); } /** * Cancel a long-running Text Analysis job - * - *

Cancel a long-running Text Analysis job. - * + * + * Cancel a long-running Text Analysis job. + * * @param jobId Job ID. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. @@ -436,9 +407,9 @@ public Mono cancelJobAsync(UUID jobId) { /** * Cancel a long-running Text Analysis job - * - *

Cancel a long-running Text Analysis job. - * + * + * Cancel a long-running Text Analysis job. + * * @param jobId Job ID. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -453,9 +424,9 @@ public Mono cancelJobAsync(UUID jobId, Context context) { /** * Cancel a long-running Text Analysis job - * - *

Cancel a long-running Text Analysis job. - * + * + * Cancel a long-running Text Analysis job. + * * @param jobId Job ID. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -471,9 +442,9 @@ public ResponseBase cancelJobWithResponse(UU /** * Cancel a long-running Text Analysis job - * - *

Cancel a long-running Text Analysis job. - * + * + * Cancel a long-running Text Analysis job. + * * @param jobId Job ID. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorResponseException thrown if the request is rejected by server. diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/MicrosoftCognitiveLanguageServiceTextAnalysisImpl.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/MicrosoftCognitiveLanguageServiceTextAnalysisImpl.java index f1fe4cd2eed1..8e0d1449f15d 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/MicrosoftCognitiveLanguageServiceTextAnalysisImpl.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/MicrosoftCognitiveLanguageServiceTextAnalysisImpl.java @@ -30,65 +30,79 @@ import com.azure.core.util.serializer.SerializerAdapter; import reactor.core.publisher.Mono; -/** Initializes a new instance of the MicrosoftCognitiveLanguageServiceTextAnalysis type. */ +/** + * Initializes a new instance of the MicrosoftCognitiveLanguageServiceTextAnalysis type. + */ public final class MicrosoftCognitiveLanguageServiceTextAnalysisImpl { - /** The proxy service used to perform REST calls. */ + /** + * The proxy service used to perform REST calls. + */ private final MicrosoftCognitiveLanguageServiceTextAnalysisService service; - /** Supported Cognitive Services endpoint (e.g., https://<resource-name>.api.cognitiveservices.azure.com). */ + /** + * Supported Cognitive Services endpoint (e.g., https://<resource-name>.api.cognitiveservices.azure.com). + */ private final String endpoint; /** * Gets Supported Cognitive Services endpoint (e.g., https://<resource-name>.api.cognitiveservices.azure.com). - * + * * @return the endpoint value. */ public String getEndpoint() { return this.endpoint; } - /** Api Version. */ + /** + * Api Version. + */ private final String apiVersion; /** * Gets Api Version. - * + * * @return the apiVersion value. */ public String getApiVersion() { return this.apiVersion; } - /** The HTTP pipeline to send requests through. */ + /** + * The HTTP pipeline to send requests through. + */ private final HttpPipeline httpPipeline; /** * Gets The HTTP pipeline to send requests through. - * + * * @return the httpPipeline value. */ public HttpPipeline getHttpPipeline() { return this.httpPipeline; } - /** The serializer to serialize an object into a string. */ + /** + * The serializer to serialize an object into a string. + */ private final SerializerAdapter serializerAdapter; /** * Gets The serializer to serialize an object into a string. - * + * * @return the serializerAdapter value. */ public SerializerAdapter getSerializerAdapter() { return this.serializerAdapter; } - /** The AnalyzeTextsImpl object to access its operations. */ + /** + * The AnalyzeTextsImpl object to access its operations. + */ private final AnalyzeTextsImpl analyzeTexts; /** * Gets the AnalyzeTextsImpl object to access its operations. - * + * * @return the AnalyzeTextsImpl object. */ public AnalyzeTextsImpl getAnalyzeTexts() { @@ -97,25 +111,22 @@ public AnalyzeTextsImpl getAnalyzeTexts() { /** * Initializes an instance of MicrosoftCognitiveLanguageServiceTextAnalysis client. - * + * * @param endpoint Supported Cognitive Services endpoint (e.g., - * https://<resource-name>.api.cognitiveservices.azure.com). + * https://<resource-name>.api.cognitiveservices.azure.com). * @param apiVersion Api Version. */ MicrosoftCognitiveLanguageServiceTextAnalysisImpl(String endpoint, String apiVersion) { - this( - new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), - endpoint, - apiVersion); + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, apiVersion); } /** * Initializes an instance of MicrosoftCognitiveLanguageServiceTextAnalysis client. - * + * * @param httpPipeline The HTTP pipeline to send requests through. * @param endpoint Supported Cognitive Services endpoint (e.g., - * https://<resource-name>.api.cognitiveservices.azure.com). + * https://<resource-name>.api.cognitiveservices.azure.com). * @param apiVersion Api Version. */ MicrosoftCognitiveLanguageServiceTextAnalysisImpl(HttpPipeline httpPipeline, String endpoint, String apiVersion) { @@ -124,25 +135,22 @@ public AnalyzeTextsImpl getAnalyzeTexts() { /** * Initializes an instance of MicrosoftCognitiveLanguageServiceTextAnalysis client. - * + * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. * @param endpoint Supported Cognitive Services endpoint (e.g., - * https://<resource-name>.api.cognitiveservices.azure.com). + * https://<resource-name>.api.cognitiveservices.azure.com). * @param apiVersion Api Version. */ - MicrosoftCognitiveLanguageServiceTextAnalysisImpl( - HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, String apiVersion) { + MicrosoftCognitiveLanguageServiceTextAnalysisImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint, String apiVersion) { this.httpPipeline = httpPipeline; this.serializerAdapter = serializerAdapter; this.endpoint = endpoint; this.apiVersion = apiVersion; this.analyzeTexts = new AnalyzeTextsImpl(this); - this.service = - RestProxy.create( - MicrosoftCognitiveLanguageServiceTextAnalysisService.class, - this.httpPipeline, - this.getSerializerAdapter()); + this.service = RestProxy.create(MicrosoftCognitiveLanguageServiceTextAnalysisService.class, this.httpPipeline, + this.getSerializerAdapter()); } /** @@ -153,33 +161,25 @@ public AnalyzeTextsImpl getAnalyzeTexts() { @ServiceInterface(name = "MicrosoftCognitiveLa") public interface MicrosoftCognitiveLanguageServiceTextAnalysisService { @Post("/:analyze-text") - @ExpectedResponses({200}) + @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Mono> analyzeText( - @HostParam("Endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @QueryParam("showStats") Boolean showStats, - @BodyParam("application/json") AnalyzeTextTask body, - @HeaderParam("Accept") String accept, - Context context); + Mono> analyzeText(@HostParam("Endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @QueryParam("showStats") Boolean showStats, + @BodyParam("application/json") AnalyzeTextTask body, @HeaderParam("Accept") String accept, Context context); @Post("/:analyze-text") - @ExpectedResponses({200}) + @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ErrorResponseException.class) - Response analyzeTextSync( - @HostParam("Endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @QueryParam("showStats") Boolean showStats, - @BodyParam("application/json") AnalyzeTextTask body, - @HeaderParam("Accept") String accept, - Context context); + Response analyzeTextSync(@HostParam("Endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @QueryParam("showStats") Boolean showStats, + @BodyParam("application/json") AnalyzeTextTask body, @HeaderParam("Accept") String accept, Context context); } /** * Request text analysis over a collection of documents. - * - *

Submit a collection of text documents for analysis. Specify a single unique task to be executed immediately. - * + * + * Submit a collection of text documents for analysis. Specify a single unique task to be executed immediately. + * * @param body Collection of documents to analyze and a single task to execute. * @param showStats (Optional) if set to true, response will contain request and document level statistics. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -191,16 +191,14 @@ Response analyzeTextSync( public Mono> analyzeTextWithResponseAsync(AnalyzeTextTask body, Boolean showStats) { final String accept = "application/json"; return FluxUtil.withContext( - context -> - service.analyzeText( - this.getEndpoint(), this.getApiVersion(), showStats, body, accept, context)); + context -> service.analyzeText(this.getEndpoint(), this.getApiVersion(), showStats, body, accept, context)); } /** * Request text analysis over a collection of documents. - * - *

Submit a collection of text documents for analysis. Specify a single unique task to be executed immediately. - * + * + * Submit a collection of text documents for analysis. Specify a single unique task to be executed immediately. + * * @param body Collection of documents to analyze and a single task to execute. * @param showStats (Optional) if set to true, response will contain request and document level statistics. * @param context The context to associate with this operation. @@ -210,17 +208,17 @@ public Mono> analyzeTextWithResponseAsync(Analyz * @return the response body along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> analyzeTextWithResponseAsync( - AnalyzeTextTask body, Boolean showStats, Context context) { + public Mono> analyzeTextWithResponseAsync(AnalyzeTextTask body, Boolean showStats, + Context context) { final String accept = "application/json"; return service.analyzeText(this.getEndpoint(), this.getApiVersion(), showStats, body, accept, context); } /** * Request text analysis over a collection of documents. - * - *

Submit a collection of text documents for analysis. Specify a single unique task to be executed immediately. - * + * + * Submit a collection of text documents for analysis. Specify a single unique task to be executed immediately. + * * @param body Collection of documents to analyze and a single task to execute. * @param showStats (Optional) if set to true, response will contain request and document level statistics. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -235,9 +233,9 @@ public Mono analyzeTextAsync(AnalyzeTextTask body, Boolea /** * Request text analysis over a collection of documents. - * - *

Submit a collection of text documents for analysis. Specify a single unique task to be executed immediately. - * + * + * Submit a collection of text documents for analysis. Specify a single unique task to be executed immediately. + * * @param body Collection of documents to analyze and a single task to execute. * @param showStats (Optional) if set to true, response will contain request and document level statistics. * @param context The context to associate with this operation. @@ -253,9 +251,9 @@ public Mono analyzeTextAsync(AnalyzeTextTask body, Boolea /** * Request text analysis over a collection of documents. - * - *

Submit a collection of text documents for analysis. Specify a single unique task to be executed immediately. - * + * + * Submit a collection of text documents for analysis. Specify a single unique task to be executed immediately. + * * @param body Collection of documents to analyze and a single task to execute. * @param showStats (Optional) if set to true, response will contain request and document level statistics. * @param context The context to associate with this operation. @@ -265,17 +263,17 @@ public Mono analyzeTextAsync(AnalyzeTextTask body, Boolea * @return the response body along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response analyzeTextWithResponse( - AnalyzeTextTask body, Boolean showStats, Context context) { + public Response analyzeTextWithResponse(AnalyzeTextTask body, Boolean showStats, + Context context) { final String accept = "application/json"; return service.analyzeTextSync(this.getEndpoint(), this.getApiVersion(), showStats, body, accept, context); } /** * Request text analysis over a collection of documents. - * - *

Submit a collection of text documents for analysis. Specify a single unique task to be executed immediately. - * + * + * Submit a collection of text documents for analysis. Specify a single unique task to be executed immediately. + * * @param body Collection of documents to analyze and a single task to execute. * @param showStats (Optional) if set to true, response will contain request and document level statistics. * @throws IllegalArgumentException thrown if parameters fail the validation. diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder.java index 70738b4ce1c3..b916662bb558 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder.java @@ -24,8 +24,8 @@ import com.azure.core.http.policy.AddHeadersPolicy; import com.azure.core.http.policy.AzureKeyCredentialPolicy; import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; -import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.HttpPipelinePolicy; import com.azure.core.http.policy.HttpPolicyProviders; import com.azure.core.http.policy.RequestIdPolicy; @@ -44,26 +44,34 @@ import java.util.Map; import java.util.Objects; -/** A builder for creating a new instance of the MicrosoftCognitiveLanguageServiceTextAnalysis type. */ -@ServiceClientBuilder(serviceClients = {MicrosoftCognitiveLanguageServiceTextAnalysisImpl.class}) +/** + * A builder for creating a new instance of the MicrosoftCognitiveLanguageServiceTextAnalysis type. + */ +@ServiceClientBuilder(serviceClients = { MicrosoftCognitiveLanguageServiceTextAnalysisImpl.class }) public final class MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder - implements HttpTrait, - ConfigurationTrait, - TokenCredentialTrait, - AzureKeyCredentialTrait, - EndpointTrait { - @Generated private static final String SDK_NAME = "name"; + implements HttpTrait, + ConfigurationTrait, + TokenCredentialTrait, + AzureKeyCredentialTrait, + EndpointTrait { + @Generated + private static final String SDK_NAME = "name"; - @Generated private static final String SDK_VERSION = "version"; + @Generated + private static final String SDK_VERSION = "version"; @Generated - private static final String[] DEFAULT_SCOPES = new String[] {"https://cognitiveservices.azure.com/.default"}; + private static final String[] DEFAULT_SCOPES = new String[] { "https://cognitiveservices.azure.com/.default" }; - @Generated private static final Map PROPERTIES = new HashMap<>(); + @Generated + private static final Map PROPERTIES = new HashMap<>(); - @Generated private final List pipelinePolicies; + @Generated + private final List pipelinePolicies; - /** Create an instance of the MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder. */ + /** + * Create an instance of the MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder. + */ @Generated public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder() { this.pipelinePolicies = new ArrayList<>(); @@ -72,9 +80,12 @@ public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder() { /* * The HTTP pipeline to send requests through. */ - @Generated private HttpPipeline pipeline; + @Generated + private HttpPipeline pipeline; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder pipeline(HttpPipeline pipeline) { @@ -85,9 +96,12 @@ public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder pipeline(HttpPip /* * The HTTP client used to send the request. */ - @Generated private HttpClient httpClient; + @Generated + private HttpClient httpClient; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder httpClient(HttpClient httpClient) { @@ -98,9 +112,12 @@ public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder httpClient(HttpC /* * The logging configuration for HTTP requests and responses. */ - @Generated private HttpLogOptions httpLogOptions; + @Generated + private HttpLogOptions httpLogOptions; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder httpLogOptions(HttpLogOptions httpLogOptions) { @@ -111,9 +128,12 @@ public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder httpLogOptions(H /* * The client options such as application ID and custom headers to set on a request. */ - @Generated private ClientOptions clientOptions; + @Generated + private ClientOptions clientOptions; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder clientOptions(ClientOptions clientOptions) { @@ -124,9 +144,12 @@ public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder clientOptions(Cl /* * The retry options to configure retry policy for failed requests. */ - @Generated private RetryOptions retryOptions; + @Generated + private RetryOptions retryOptions; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder retryOptions(RetryOptions retryOptions) { @@ -134,7 +157,9 @@ public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder retryOptions(Ret return this; } - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder addPolicy(HttpPipelinePolicy customPolicy) { @@ -146,9 +171,12 @@ public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder addPolicy(HttpPi /* * The configuration store that is used during construction of the service client. */ - @Generated private Configuration configuration; + @Generated + private Configuration configuration; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder configuration(Configuration configuration) { @@ -159,9 +187,12 @@ public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder configuration(Co /* * The TokenCredential used for authentication. */ - @Generated private TokenCredential tokenCredential; + @Generated + private TokenCredential tokenCredential; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder credential(TokenCredential tokenCredential) { @@ -172,9 +203,12 @@ public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder credential(Token /* * The AzureKeyCredential used for authentication. */ - @Generated private AzureKeyCredential azureKeyCredential; + @Generated + private AzureKeyCredential azureKeyCredential; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder credential(AzureKeyCredential azureKeyCredential) { @@ -185,9 +219,12 @@ public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder credential(Azure /* * The service endpoint */ - @Generated private String endpoint; + @Generated + private String endpoint; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder endpoint(String endpoint) { @@ -198,11 +235,12 @@ public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder endpoint(String /* * Api Version */ - @Generated private String apiVersion; + @Generated + private String apiVersion; /** * Sets Api Version. - * + * * @param apiVersion the apiVersion value. * @return the MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder. */ @@ -215,17 +253,18 @@ public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder apiVersion(Strin /* * The serializer to serialize an object into a string */ - @Generated private SerializerAdapter serializerAdapter; + @Generated + private SerializerAdapter serializerAdapter; /** * Sets The serializer to serialize an object into a string. - * + * * @param serializerAdapter the serializerAdapter value. * @return the MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder. */ @Generated - public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder serializerAdapter( - SerializerAdapter serializerAdapter) { + public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder + serializerAdapter(SerializerAdapter serializerAdapter) { this.serializerAdapter = serializerAdapter; return this; } @@ -233,11 +272,12 @@ public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder serializerAdapte /* * The retry policy that will attempt to retry failed requests, if applicable. */ - @Generated private RetryPolicy retryPolicy; + @Generated + private RetryPolicy retryPolicy; /** * Sets The retry policy that will attempt to retry failed requests, if applicable. - * + * * @param retryPolicy the retryPolicy value. * @return the MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder. */ @@ -249,25 +289,25 @@ public MicrosoftCognitiveLanguageServiceTextAnalysisImplBuilder retryPolicy(Retr /** * Builds an instance of MicrosoftCognitiveLanguageServiceTextAnalysisImpl with the provided parameters. - * + * * @return an instance of MicrosoftCognitiveLanguageServiceTextAnalysisImpl. */ @Generated public MicrosoftCognitiveLanguageServiceTextAnalysisImpl buildClient() { HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); String localApiVersion = (apiVersion != null) ? apiVersion : "2023-04-01"; - SerializerAdapter localSerializerAdapter = - (serializerAdapter != null) ? serializerAdapter : JacksonAdapter.createDefaultSerializerAdapter(); - MicrosoftCognitiveLanguageServiceTextAnalysisImpl client = - new MicrosoftCognitiveLanguageServiceTextAnalysisImpl( - localPipeline, localSerializerAdapter, this.endpoint, localApiVersion); + SerializerAdapter localSerializerAdapter + = (serializerAdapter != null) ? serializerAdapter : JacksonAdapter.createDefaultSerializerAdapter(); + MicrosoftCognitiveLanguageServiceTextAnalysisImpl client + = new MicrosoftCognitiveLanguageServiceTextAnalysisImpl(localPipeline, localSerializerAdapter, + this.endpoint, localApiVersion); return client; } @Generated private HttpPipeline createHttpPipeline() { - Configuration buildConfiguration = - (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; List policies = new ArrayList<>(); @@ -278,15 +318,14 @@ private HttpPipeline createHttpPipeline() { policies.add(new RequestIdPolicy()); policies.add(new AddHeadersFromContextPolicy()); HttpHeaders headers = new HttpHeaders(); - localClientOptions - .getHeaders() - .forEach(header -> headers.set(HttpHeaderName.fromString(header.getName()), header.getValue())); + localClientOptions.getHeaders() + .forEach(header -> headers.set(HttpHeaderName.fromString(header.getName()), header.getValue())); if (headers.getSize() > 0) { policies.add(new AddHeadersPolicy(headers)); } this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) - .forEach(p -> policies.add(p)); + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .forEach(p -> policies.add(p)); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); policies.add(new AddDatePolicy()); @@ -297,16 +336,14 @@ private HttpPipeline createHttpPipeline() { policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES)); } this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) - .forEach(p -> policies.add(p)); + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .forEach(p -> policies.add(p)); HttpPolicyProviders.addAfterRetryPolicies(policies); - policies.add(new HttpLoggingPolicy(httpLogOptions)); - HttpPipeline httpPipeline = - new HttpPipelineBuilder() - .policies(policies.toArray(new HttpPipelinePolicy[0])) - .httpClient(httpClient) - .clientOptions(localClientOptions) - .build(); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient) + .clientOptions(localClientOptions) + .build(); return httpPipeline; } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationLROResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationLROResult.java index d788af7c4eca..ae11e650ced3 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationLROResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationLROResult.java @@ -10,22 +10,42 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.time.OffsetDateTime; -import java.util.Objects; +import java.time.format.DateTimeFormatter; -/** An object representing the results for an Abstractive Summarization task. */ +/** + * An object representing the results for an Abstractive Summarization task. + */ @Fluent public final class AbstractiveSummarizationLROResult extends AnalyzeTextLROResult { + /* + * Enumeration of supported Text Analysis long-running operation task results. + */ + private AnalyzeTextLROResultsKind kind = AnalyzeTextLROResultsKind.ABSTRACTIVE_SUMMARIZATION_LRORESULTS; + /* * An object representing the pre-build summarization results of each document. */ private AbstractiveSummarizationResult results; - /** Creates an instance of AbstractiveSummarizationLROResult class. */ - public AbstractiveSummarizationLROResult() {} + /** + * Creates an instance of AbstractiveSummarizationLROResult class. + */ + public AbstractiveSummarizationLROResult() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis long-running operation task results. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROResultsKind getKind() { + return this.kind; + } /** * Get the results property: An object representing the pre-build summarization results of each document. - * + * * @return the results value. */ public AbstractiveSummarizationResult getResults() { @@ -34,7 +54,7 @@ public AbstractiveSummarizationResult getResults() { /** * Set the results property: An object representing the pre-build summarization results of each document. - * + * * @param results the results value to set. * @return the AbstractiveSummarizationLROResult object itself. */ @@ -43,84 +63,86 @@ public AbstractiveSummarizationLROResult setResults(AbstractiveSummarizationResu return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public AbstractiveSummarizationLROResult setTaskName(String taskName) { super.setTaskName(taskName); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public AbstractiveSummarizationLROResult setLastUpdateDateTime(OffsetDateTime lastUpdateDateTime) { super.setLastUpdateDateTime(lastUpdateDateTime); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public AbstractiveSummarizationLROResult setStatus(State status) { super.setStatus(status); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField( - "kind", Objects.toString(AnalyzeTextLROResultsKind.ABSTRACTIVE_SUMMARIZATION_LRORESULTS, null)); - jsonWriter.writeStringField("lastUpdateDateTime", Objects.toString(getLastUpdateDateTime(), null)); - jsonWriter.writeStringField("status", Objects.toString(getStatus(), null)); + jsonWriter.writeStringField("lastUpdateDateTime", + getLastUpdateDateTime() == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(getLastUpdateDateTime())); + jsonWriter.writeStringField("status", getStatus() == null ? null : getStatus().toString()); jsonWriter.writeStringField("taskName", getTaskName()); jsonWriter.writeJsonField("results", this.results); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of AbstractiveSummarizationLROResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of AbstractiveSummarizationLROResult 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 or the - * polymorphic discriminator. + * 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 AbstractiveSummarizationLROResult. */ public static AbstractiveSummarizationLROResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - AbstractiveSummarizationLROResult deserializedAbstractiveSummarizationLROResult = - new AbstractiveSummarizationLROResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + AbstractiveSummarizationLROResult deserializedAbstractiveSummarizationLROResult + = new AbstractiveSummarizationLROResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"AbstractiveSummarizationLROResults".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'AbstractiveSummarizationLROResults'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("lastUpdateDateTime".equals(fieldName)) { - deserializedAbstractiveSummarizationLROResult.setLastUpdateDateTime( - reader.getNullable( - nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); - } else if ("status".equals(fieldName)) { - deserializedAbstractiveSummarizationLROResult.setStatus( - State.fromString(reader.getString())); - } else if ("taskName".equals(fieldName)) { - deserializedAbstractiveSummarizationLROResult.setTaskName(reader.getString()); - } else if ("results".equals(fieldName)) { - deserializedAbstractiveSummarizationLROResult.results = - AbstractiveSummarizationResult.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("lastUpdateDateTime".equals(fieldName)) { + deserializedAbstractiveSummarizationLROResult.setLastUpdateDateTime( + reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); + } else if ("status".equals(fieldName)) { + deserializedAbstractiveSummarizationLROResult.setStatus(State.fromString(reader.getString())); + } else if ("taskName".equals(fieldName)) { + deserializedAbstractiveSummarizationLROResult.setTaskName(reader.getString()); + } else if ("results".equals(fieldName)) { + deserializedAbstractiveSummarizationLROResult.results + = AbstractiveSummarizationResult.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedAbstractiveSummarizationLROResult.kind + = AnalyzeTextLROResultsKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedAbstractiveSummarizationLROResult; - }); + return deserializedAbstractiveSummarizationLROResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationLROTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationLROTask.java index 3a1b27d61ef7..cc88de64049b 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationLROTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationLROTask.java @@ -9,22 +9,41 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** An object representing the task definition for an Abstractive Summarization task. */ +/** + * An object representing the task definition for an Abstractive Summarization task. + */ @Fluent public final class AbstractiveSummarizationLROTask extends AnalyzeTextLROTask { + /* + * Enumeration of supported long-running Text Analysis tasks. + */ + private AnalyzeTextLROTaskKind kind = AnalyzeTextLROTaskKind.ABSTRACTIVE_SUMMARIZATION; + /* * Supported parameters for the pre-build Abstractive Summarization task. */ private AbstractiveSummarizationTaskParameters parameters; - /** Creates an instance of AbstractiveSummarizationLROTask class. */ - public AbstractiveSummarizationLROTask() {} + /** + * Creates an instance of AbstractiveSummarizationLROTask class. + */ + public AbstractiveSummarizationLROTask() { + } + + /** + * Get the kind property: Enumeration of supported long-running Text Analysis tasks. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROTaskKind getKind() { + return this.kind; + } /** * Get the parameters property: Supported parameters for the pre-build Abstractive Summarization task. - * + * * @return the parameters value. */ public AbstractiveSummarizationTaskParameters getParameters() { @@ -33,7 +52,7 @@ public AbstractiveSummarizationTaskParameters getParameters() { /** * Set the parameters property: Supported parameters for the pre-build Abstractive Summarization task. - * + * * @param parameters the parameters value to set. * @return the AbstractiveSummarizationLROTask object itself. */ @@ -42,60 +61,58 @@ public AbstractiveSummarizationLROTask setParameters(AbstractiveSummarizationTas return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public AbstractiveSummarizationLROTask setTaskName(String taskName) { super.setTaskName(taskName); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("kind", Objects.toString(AnalyzeTextLROTaskKind.ABSTRACTIVE_SUMMARIZATION, null)); jsonWriter.writeStringField("taskName", getTaskName()); jsonWriter.writeJsonField("parameters", this.parameters); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of AbstractiveSummarizationLROTask from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of AbstractiveSummarizationLROTask 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 or the - * polymorphic discriminator. + * 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 AbstractiveSummarizationLROTask. */ public static AbstractiveSummarizationLROTask fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - AbstractiveSummarizationLROTask deserializedAbstractiveSummarizationLROTask = - new AbstractiveSummarizationLROTask(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + AbstractiveSummarizationLROTask deserializedAbstractiveSummarizationLROTask + = new AbstractiveSummarizationLROTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"AbstractiveSummarization".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'AbstractiveSummarization'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("taskName".equals(fieldName)) { - deserializedAbstractiveSummarizationLROTask.setTaskName(reader.getString()); - } else if ("parameters".equals(fieldName)) { - deserializedAbstractiveSummarizationLROTask.parameters = - AbstractiveSummarizationTaskParameters.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("taskName".equals(fieldName)) { + deserializedAbstractiveSummarizationLROTask.setTaskName(reader.getString()); + } else if ("parameters".equals(fieldName)) { + deserializedAbstractiveSummarizationLROTask.parameters + = AbstractiveSummarizationTaskParameters.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedAbstractiveSummarizationLROTask.kind + = AnalyzeTextLROTaskKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedAbstractiveSummarizationLROTask; - }); + return deserializedAbstractiveSummarizationLROTask; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationResult.java index e6e432606f8b..7c80d00b8b23 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationResult.java @@ -11,7 +11,9 @@ import java.io.IOException; import java.util.List; -/** An object representing the pre-build summarization results of each document. */ +/** + * An object representing the pre-build summarization results of each document. + */ @Fluent public final class AbstractiveSummarizationResult extends AbstractiveSummarizationResultBase { /* @@ -29,12 +31,15 @@ public final class AbstractiveSummarizationResult extends AbstractiveSummarizati */ private String modelVersion; - /** Creates an instance of AbstractiveSummarizationResult class. */ - public AbstractiveSummarizationResult() {} + /** + * Creates an instance of AbstractiveSummarizationResult class. + */ + public AbstractiveSummarizationResult() { + } /** * Get the errors property: Errors by document id. - * + * * @return the errors value. */ public List getErrors() { @@ -43,7 +48,7 @@ public List getErrors() { /** * Set the errors property: Errors by document id. - * + * * @param errors the errors value to set. * @return the AbstractiveSummarizationResult object itself. */ @@ -55,7 +60,7 @@ public AbstractiveSummarizationResult setErrors(List errors) { /** * Get the statistics property: if showStats=true was specified in the request this field will contain information * about the request payload. - * + * * @return the statistics value. */ public RequestStatistics getStatistics() { @@ -65,7 +70,7 @@ public RequestStatistics getStatistics() { /** * Set the statistics property: if showStats=true was specified in the request this field will contain information * about the request payload. - * + * * @param statistics the statistics value to set. * @return the AbstractiveSummarizationResult object itself. */ @@ -76,7 +81,7 @@ public AbstractiveSummarizationResult setStatistics(RequestStatistics statistics /** * Get the modelVersion property: This field indicates which model is used for scoring. - * + * * @return the modelVersion value. */ public String getModelVersion() { @@ -85,7 +90,7 @@ public String getModelVersion() { /** * Set the modelVersion property: This field indicates which model is used for scoring. - * + * * @param modelVersion the modelVersion value to set. * @return the AbstractiveSummarizationResult object itself. */ @@ -94,13 +99,18 @@ public AbstractiveSummarizationResult setModelVersion(String modelVersion) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public AbstractiveSummarizationResult setDocuments(List documents) { super.setDocuments(documents); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -113,39 +123,38 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of AbstractiveSummarizationResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of AbstractiveSummarizationResult if the JsonReader was pointing to an instance of it, or - * null if it was pointing to JSON null. + * 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 AbstractiveSummarizationResult. */ public static AbstractiveSummarizationResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - AbstractiveSummarizationResult deserializedAbstractiveSummarizationResult = - new AbstractiveSummarizationResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("documents".equals(fieldName)) { - List documents = - reader.readArray(reader1 -> AbstractiveSummaryDocumentResult.fromJson(reader1)); - deserializedAbstractiveSummarizationResult.setDocuments(documents); - } else if ("errors".equals(fieldName)) { - List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); - deserializedAbstractiveSummarizationResult.errors = errors; - } else if ("modelVersion".equals(fieldName)) { - deserializedAbstractiveSummarizationResult.modelVersion = reader.getString(); - } else if ("statistics".equals(fieldName)) { - deserializedAbstractiveSummarizationResult.statistics = RequestStatistics.fromJson(reader); - } else { - reader.skipChildren(); - } - } - - return deserializedAbstractiveSummarizationResult; - }); + return jsonReader.readObject(reader -> { + AbstractiveSummarizationResult deserializedAbstractiveSummarizationResult + = new AbstractiveSummarizationResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("documents".equals(fieldName)) { + List documents + = reader.readArray(reader1 -> AbstractiveSummaryDocumentResult.fromJson(reader1)); + deserializedAbstractiveSummarizationResult.setDocuments(documents); + } else if ("errors".equals(fieldName)) { + List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); + deserializedAbstractiveSummarizationResult.errors = errors; + } else if ("modelVersion".equals(fieldName)) { + deserializedAbstractiveSummarizationResult.modelVersion = reader.getString(); + } else if ("statistics".equals(fieldName)) { + deserializedAbstractiveSummarizationResult.statistics = RequestStatistics.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedAbstractiveSummarizationResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationResultBase.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationResultBase.java index c73b1ee8e987..90578a3ee745 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationResultBase.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationResultBase.java @@ -12,7 +12,9 @@ import java.io.IOException; import java.util.List; -/** An object representing the summarization results of each document. */ +/** + * An object representing the summarization results of each document. + */ @Fluent public class AbstractiveSummarizationResultBase implements JsonSerializable { /* @@ -20,12 +22,15 @@ public class AbstractiveSummarizationResultBase implements JsonSerializable documents; - /** Creates an instance of AbstractiveSummarizationResultBase class. */ - public AbstractiveSummarizationResultBase() {} + /** + * Creates an instance of AbstractiveSummarizationResultBase class. + */ + public AbstractiveSummarizationResultBase() { + } /** * Get the documents property: Response by document. - * + * * @return the documents value. */ public List getDocuments() { @@ -34,7 +39,7 @@ public List getDocuments() { /** * Set the documents property: Response by document. - * + * * @param documents the documents value to set. * @return the AbstractiveSummarizationResultBase object itself. */ @@ -43,6 +48,9 @@ public AbstractiveSummarizationResultBase setDocuments(List { - AbstractiveSummarizationResultBase deserializedAbstractiveSummarizationResultBase = - new AbstractiveSummarizationResultBase(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + AbstractiveSummarizationResultBase deserializedAbstractiveSummarizationResultBase + = new AbstractiveSummarizationResultBase(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("documents".equals(fieldName)) { - List documents = - reader.readArray(reader1 -> AbstractiveSummaryDocumentResult.fromJson(reader1)); - deserializedAbstractiveSummarizationResultBase.documents = documents; - } else { - reader.skipChildren(); - } - } + if ("documents".equals(fieldName)) { + List documents + = reader.readArray(reader1 -> AbstractiveSummaryDocumentResult.fromJson(reader1)); + deserializedAbstractiveSummarizationResultBase.documents = documents; + } else { + reader.skipChildren(); + } + } - return deserializedAbstractiveSummarizationResultBase; - }); + return deserializedAbstractiveSummarizationResultBase; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationTaskParameters.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationTaskParameters.java index 69b52d6ebd35..3115bd5105db 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationTaskParameters.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationTaskParameters.java @@ -9,9 +9,10 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** Supported parameters for the pre-build Abstractive Summarization task. */ +/** + * Supported parameters for the pre-build Abstractive Summarization task. + */ @Fluent public final class AbstractiveSummarizationTaskParameters extends AbstractiveSummarizationTaskParametersBase { /* @@ -24,12 +25,15 @@ public final class AbstractiveSummarizationTaskParameters extends AbstractiveSum */ private Boolean loggingOptOut; - /** Creates an instance of AbstractiveSummarizationTaskParameters class. */ - public AbstractiveSummarizationTaskParameters() {} + /** + * Creates an instance of AbstractiveSummarizationTaskParameters class. + */ + public AbstractiveSummarizationTaskParameters() { + } /** * Get the modelVersion property: The modelVersion property. - * + * * @return the modelVersion value. */ public String getModelVersion() { @@ -38,7 +42,7 @@ public String getModelVersion() { /** * Set the modelVersion property: The modelVersion property. - * + * * @param modelVersion the modelVersion value to set. * @return the AbstractiveSummarizationTaskParameters object itself. */ @@ -49,7 +53,7 @@ public AbstractiveSummarizationTaskParameters setModelVersion(String modelVersio /** * Get the loggingOptOut property: The loggingOptOut property. - * + * * @return the loggingOptOut value. */ public Boolean isLoggingOptOut() { @@ -58,7 +62,7 @@ public Boolean isLoggingOptOut() { /** * Set the loggingOptOut property: The loggingOptOut property. - * + * * @param loggingOptOut the loggingOptOut value to set. * @return the AbstractiveSummarizationTaskParameters object itself. */ @@ -67,25 +71,33 @@ public AbstractiveSummarizationTaskParameters setLoggingOptOut(Boolean loggingOp return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public AbstractiveSummarizationTaskParameters setSentenceCount(Integer sentenceCount) { super.setSentenceCount(sentenceCount); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public AbstractiveSummarizationTaskParameters setStringIndexType(StringIndexType stringIndexType) { super.setStringIndexType(stringIndexType); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); jsonWriter.writeNumberField("sentenceCount", getSentenceCount()); - jsonWriter.writeStringField("stringIndexType", Objects.toString(getStringIndexType(), null)); + jsonWriter.writeStringField("stringIndexType", + getStringIndexType() == null ? null : getStringIndexType().toString()); jsonWriter.writeStringField("modelVersion", this.modelVersion); jsonWriter.writeBooleanField("loggingOptOut", this.loggingOptOut); return jsonWriter.writeEndObject(); @@ -93,38 +105,37 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of AbstractiveSummarizationTaskParameters from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of AbstractiveSummarizationTaskParameters if the JsonReader was pointing to an instance of - * it, or null if it was pointing to JSON null. + * it, or null if it was pointing to JSON null. * @throws IOException If an error occurs while reading the AbstractiveSummarizationTaskParameters. */ public static AbstractiveSummarizationTaskParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - AbstractiveSummarizationTaskParameters deserializedAbstractiveSummarizationTaskParameters = - new AbstractiveSummarizationTaskParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + AbstractiveSummarizationTaskParameters deserializedAbstractiveSummarizationTaskParameters + = new AbstractiveSummarizationTaskParameters(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("sentenceCount".equals(fieldName)) { - deserializedAbstractiveSummarizationTaskParameters.setSentenceCount( - reader.getNullable(JsonReader::getInt)); - } else if ("stringIndexType".equals(fieldName)) { - deserializedAbstractiveSummarizationTaskParameters.setStringIndexType( - StringIndexType.fromString(reader.getString())); - } else if ("modelVersion".equals(fieldName)) { - deserializedAbstractiveSummarizationTaskParameters.modelVersion = reader.getString(); - } else if ("loggingOptOut".equals(fieldName)) { - deserializedAbstractiveSummarizationTaskParameters.loggingOptOut = - reader.getNullable(JsonReader::getBoolean); - } else { - reader.skipChildren(); - } - } + if ("sentenceCount".equals(fieldName)) { + deserializedAbstractiveSummarizationTaskParameters + .setSentenceCount(reader.getNullable(JsonReader::getInt)); + } else if ("stringIndexType".equals(fieldName)) { + deserializedAbstractiveSummarizationTaskParameters + .setStringIndexType(StringIndexType.fromString(reader.getString())); + } else if ("modelVersion".equals(fieldName)) { + deserializedAbstractiveSummarizationTaskParameters.modelVersion = reader.getString(); + } else if ("loggingOptOut".equals(fieldName)) { + deserializedAbstractiveSummarizationTaskParameters.loggingOptOut + = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } - return deserializedAbstractiveSummarizationTaskParameters; - }); + return deserializedAbstractiveSummarizationTaskParameters; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationTaskParametersBase.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationTaskParametersBase.java index 6c13682133b6..1b0640a159f3 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationTaskParametersBase.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummarizationTaskParametersBase.java @@ -10,29 +10,32 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** Supported parameters for an Abstractive Summarization task. */ +/** + * Supported parameters for an Abstractive Summarization task. + */ @Fluent public class AbstractiveSummarizationTaskParametersBase - implements JsonSerializable { + implements JsonSerializable { /* * It controls the approximate number of sentences in the output summaries. */ private Integer sentenceCount; /* - * Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to - * Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. + * Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. */ private StringIndexType stringIndexType; - /** Creates an instance of AbstractiveSummarizationTaskParametersBase class. */ - public AbstractiveSummarizationTaskParametersBase() {} + /** + * Creates an instance of AbstractiveSummarizationTaskParametersBase class. + */ + public AbstractiveSummarizationTaskParametersBase() { + } /** * Get the sentenceCount property: It controls the approximate number of sentences in the output summaries. - * + * * @return the sentenceCount value. */ public Integer getSentenceCount() { @@ -41,7 +44,7 @@ public Integer getSentenceCount() { /** * Set the sentenceCount property: It controls the approximate number of sentences in the output summaries. - * + * * @param sentenceCount the sentenceCount value to set. * @return the AbstractiveSummarizationTaskParametersBase object itself. */ @@ -54,7 +57,7 @@ public AbstractiveSummarizationTaskParametersBase setSentenceCount(Integer sente * Get the stringIndexType property: Specifies the method used to interpret string offsets. Defaults to Text * Elements (Graphemes) according to Unicode v8.0.0. For additional information see * https://aka.ms/text-analytics-offsets. - * + * * @return the stringIndexType value. */ public StringIndexType getStringIndexType() { @@ -65,7 +68,7 @@ public StringIndexType getStringIndexType() { * Set the stringIndexType property: Specifies the method used to interpret string offsets. Defaults to Text * Elements (Graphemes) according to Unicode v8.0.0. For additional information see * https://aka.ms/text-analytics-offsets. - * + * * @param stringIndexType the stringIndexType value to set. * @return the AbstractiveSummarizationTaskParametersBase object itself. */ @@ -74,43 +77,46 @@ public AbstractiveSummarizationTaskParametersBase setStringIndexType(StringIndex return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); jsonWriter.writeNumberField("sentenceCount", this.sentenceCount); - jsonWriter.writeStringField("stringIndexType", Objects.toString(this.stringIndexType, null)); + jsonWriter.writeStringField("stringIndexType", + this.stringIndexType == null ? null : this.stringIndexType.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of AbstractiveSummarizationTaskParametersBase from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of AbstractiveSummarizationTaskParametersBase if the JsonReader was pointing to an instance - * of it, or null if it was pointing to JSON null. + * of it, or null if it was pointing to JSON null. * @throws IOException If an error occurs while reading the AbstractiveSummarizationTaskParametersBase. */ public static AbstractiveSummarizationTaskParametersBase fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - AbstractiveSummarizationTaskParametersBase deserializedAbstractiveSummarizationTaskParametersBase = - new AbstractiveSummarizationTaskParametersBase(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + AbstractiveSummarizationTaskParametersBase deserializedAbstractiveSummarizationTaskParametersBase + = new AbstractiveSummarizationTaskParametersBase(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("sentenceCount".equals(fieldName)) { - deserializedAbstractiveSummarizationTaskParametersBase.sentenceCount = - reader.getNullable(JsonReader::getInt); - } else if ("stringIndexType".equals(fieldName)) { - deserializedAbstractiveSummarizationTaskParametersBase.stringIndexType = - StringIndexType.fromString(reader.getString()); - } else { - reader.skipChildren(); - } - } + if ("sentenceCount".equals(fieldName)) { + deserializedAbstractiveSummarizationTaskParametersBase.sentenceCount + = reader.getNullable(JsonReader::getInt); + } else if ("stringIndexType".equals(fieldName)) { + deserializedAbstractiveSummarizationTaskParametersBase.stringIndexType + = StringIndexType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedAbstractiveSummarizationTaskParametersBase; - }); + return deserializedAbstractiveSummarizationTaskParametersBase; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummary.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummary.java index 75377cbf1d7e..b20958ccbd05 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummary.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummary.java @@ -12,7 +12,9 @@ import java.io.IOException; import java.util.List; -/** An object representing a single summary with context for given document. */ +/** + * An object representing a single summary with context for given document. + */ @Fluent public final class AbstractiveSummary implements JsonSerializable { /* @@ -25,12 +27,15 @@ public final class AbstractiveSummary implements JsonSerializable contexts; - /** Creates an instance of AbstractiveSummary class. */ - public AbstractiveSummary() {} + /** + * Creates an instance of AbstractiveSummary class. + */ + public AbstractiveSummary() { + } /** * Get the text property: The text of the summary. - * + * * @return the text value. */ public String getText() { @@ -39,7 +44,7 @@ public String getText() { /** * Set the text property: The text of the summary. - * + * * @param text the text value to set. * @return the AbstractiveSummary object itself. */ @@ -50,7 +55,7 @@ public AbstractiveSummary setText(String text) { /** * Get the contexts property: The context list of the summary. - * + * * @return the contexts value. */ public List getContexts() { @@ -59,7 +64,7 @@ public List getContexts() { /** * Set the contexts property: The context list of the summary. - * + * * @param contexts the contexts value to set. * @return the AbstractiveSummary object itself. */ @@ -68,6 +73,9 @@ public AbstractiveSummary setContexts(List contexts) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -78,33 +86,31 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of AbstractiveSummary from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of AbstractiveSummary if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 AbstractiveSummary. */ public static AbstractiveSummary fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - AbstractiveSummary deserializedAbstractiveSummary = new AbstractiveSummary(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + AbstractiveSummary deserializedAbstractiveSummary = new AbstractiveSummary(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("text".equals(fieldName)) { - deserializedAbstractiveSummary.text = reader.getString(); - } else if ("contexts".equals(fieldName)) { - List contexts = - reader.readArray(reader1 -> SummaryContext.fromJson(reader1)); - deserializedAbstractiveSummary.contexts = contexts; - } else { - reader.skipChildren(); - } - } + if ("text".equals(fieldName)) { + deserializedAbstractiveSummary.text = reader.getString(); + } else if ("contexts".equals(fieldName)) { + List contexts = reader.readArray(reader1 -> SummaryContext.fromJson(reader1)); + deserializedAbstractiveSummary.contexts = contexts; + } else { + reader.skipChildren(); + } + } - return deserializedAbstractiveSummary; - }); + return deserializedAbstractiveSummary; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummaryDocumentResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummaryDocumentResult.java index c6c8b5ac62e4..778a9634801d 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummaryDocumentResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AbstractiveSummaryDocumentResult.java @@ -11,7 +11,9 @@ import java.io.IOException; import java.util.List; -/** An object representing the summarization result of a single document. */ +/** + * An object representing the summarization result of a single document. + */ @Fluent public final class AbstractiveSummaryDocumentResult extends DocumentResult { /* @@ -19,12 +21,15 @@ public final class AbstractiveSummaryDocumentResult extends DocumentResult { */ private List summaries; - /** Creates an instance of AbstractiveSummaryDocumentResult class. */ - public AbstractiveSummaryDocumentResult() {} + /** + * Creates an instance of AbstractiveSummaryDocumentResult class. + */ + public AbstractiveSummaryDocumentResult() { + } /** * Get the summaries property: A list of abstractive summaries. - * + * * @return the summaries value. */ public List getSummaries() { @@ -33,7 +38,7 @@ public List getSummaries() { /** * Set the summaries property: A list of abstractive summaries. - * + * * @param summaries the summaries value to set. * @return the AbstractiveSummaryDocumentResult object itself. */ @@ -42,27 +47,36 @@ public AbstractiveSummaryDocumentResult setSummaries(List su return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public AbstractiveSummaryDocumentResult setId(String id) { super.setId(id); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public AbstractiveSummaryDocumentResult setWarnings(List warnings) { super.setWarnings(warnings); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public AbstractiveSummaryDocumentResult setStatistics(DocumentStatistics statistics) { super.setStatistics(statistics); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -75,41 +89,38 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of AbstractiveSummaryDocumentResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of AbstractiveSummaryDocumentResult if the JsonReader was pointing to an instance of it, or - * null if it was pointing to JSON null. + * 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 AbstractiveSummaryDocumentResult. */ public static AbstractiveSummaryDocumentResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - AbstractiveSummaryDocumentResult deserializedAbstractiveSummaryDocumentResult = - new AbstractiveSummaryDocumentResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + AbstractiveSummaryDocumentResult deserializedAbstractiveSummaryDocumentResult + = new AbstractiveSummaryDocumentResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("id".equals(fieldName)) { - deserializedAbstractiveSummaryDocumentResult.setId(reader.getString()); - } else if ("warnings".equals(fieldName)) { - List warnings = - reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); - deserializedAbstractiveSummaryDocumentResult.setWarnings(warnings); - } else if ("statistics".equals(fieldName)) { - deserializedAbstractiveSummaryDocumentResult.setStatistics( - DocumentStatistics.fromJson(reader)); - } else if ("summaries".equals(fieldName)) { - List summaries = - reader.readArray(reader1 -> AbstractiveSummary.fromJson(reader1)); - deserializedAbstractiveSummaryDocumentResult.summaries = summaries; - } else { - reader.skipChildren(); - } - } + if ("id".equals(fieldName)) { + deserializedAbstractiveSummaryDocumentResult.setId(reader.getString()); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedAbstractiveSummaryDocumentResult.setWarnings(warnings); + } else if ("statistics".equals(fieldName)) { + deserializedAbstractiveSummaryDocumentResult.setStatistics(DocumentStatistics.fromJson(reader)); + } else if ("summaries".equals(fieldName)) { + List summaries + = reader.readArray(reader1 -> AbstractiveSummary.fromJson(reader1)); + deserializedAbstractiveSummaryDocumentResult.summaries = summaries; + } else { + reader.skipChildren(); + } + } - return deserializedAbstractiveSummaryDocumentResult; - }); + return deserializedAbstractiveSummaryDocumentResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeBatchInput.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeBatchInput.java index 0c7241f5f9fc..2a6c4a1d9fc2 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeBatchInput.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeBatchInput.java @@ -1,11 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; + +import java.io.IOException; /** The AnalyzeBatchInput model. */ @Fluent @@ -13,14 +16,12 @@ public final class AnalyzeBatchInput extends JobDescriptor { /* * Contains a set of input documents to be analyzed by the service. */ - @JsonProperty(value = "analysisInput", required = true) private MultiLanguageBatchInput analysisInput; /* * The set of tasks to execute on the input documents. Cannot specify the * same task more than once. */ - @JsonProperty(value = "tasks", required = true) private JobManifestTasks tasks; /** @@ -64,4 +65,44 @@ public AnalyzeBatchInput setTasks(JobManifestTasks tasks) { this.tasks = tasks; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("analysisInput", this.analysisInput); + jsonWriter.writeJsonField("tasks", this.tasks); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AnalyzeBatchInput from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AnalyzeBatchInput 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 AnalyzeBatchInput. + */ + public static AnalyzeBatchInput fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AnalyzeBatchInput deserializedAnalyzeBatchInput = new AnalyzeBatchInput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("analysisInput".equals(fieldName)) { + deserializedAnalyzeBatchInput.analysisInput = MultiLanguageBatchInput.fromJson(reader); + } else if ("tasks".equals(fieldName)) { + deserializedAnalyzeBatchInput.tasks = JobManifestTasks.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedAnalyzeBatchInput; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeHeaders.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeHeaders.java index 92cddc21b7bd..423cb19312d6 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeHeaders.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeHeaders.java @@ -1,19 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 AnalyzeHeaders model. */ @Fluent -public final class AnalyzeHeaders { +public final class AnalyzeHeaders implements JsonSerializable { /* * The Operation-Location property. */ - @JsonProperty(value = "Operation-Location") private String operationLocation; /** @@ -35,4 +38,40 @@ public AnalyzeHeaders setOperationLocation(String operationLocation) { this.operationLocation = operationLocation; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("Operation-Location", this.operationLocation); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AnalyzeHeaders from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AnalyzeHeaders 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 AnalyzeHeaders. + */ + public static AnalyzeHeaders fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String operationLocation = null; + AnalyzeHeaders analyzeHeaders = new AnalyzeHeaders(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("Operation-Location".equals(fieldName)) { + operationLocation = reader.getString(); + } else { + reader.skipChildren(); + } + } + return analyzeHeaders.setOperationLocation(operationLocation); + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeJobDisplayName.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeJobDisplayName.java deleted file mode 100644 index 566388728a8f..000000000000 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeJobDisplayName.java +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.ai.textanalytics.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** The AnalyzeJobDisplayName model. */ -@Fluent -public class AnalyzeJobDisplayName { - /* - * The displayName property. - */ - @JsonProperty(value = "displayName") - private String displayName; - - /** - * Get the displayName property: The displayName property. - * - * @return the displayName value. - */ - public String getDisplayName() { - return this.displayName; - } - - /** - * Set the displayName property: The displayName property. - * - * @param displayName the displayName value to set. - * @return the AnalyzeJobDisplayName object itself. - */ - public AnalyzeJobDisplayName setDisplayName(String displayName) { - this.displayName = displayName; - return this; - } -} diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeJobMetadata.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeJobMetadata.java index cdff344e0961..280b314d9ec1 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeJobMetadata.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeJobMetadata.java @@ -1,11 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; + +import java.io.IOException; /** The AnalyzeJobMetadata model. */ @Fluent @@ -13,7 +16,6 @@ public class AnalyzeJobMetadata extends JobMetadata { /* * The displayName property. */ - @JsonProperty(value = "displayName") private String displayName; /** @@ -35,4 +37,41 @@ public AnalyzeJobMetadata setDisplayName(String displayName) { this.displayName = displayName; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("displayName", this.displayName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AnalyzeJobMetadata from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AnalyzeJobMetadata 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 AnalyzeJobMetadata. + */ + public static AnalyzeJobMetadata fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AnalyzeJobMetadata deserializedAnalyzeJobMetadata = new AnalyzeJobMetadata(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("displayName".equals(fieldName)) { + deserializedAnalyzeJobMetadata.displayName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedAnalyzeJobMetadata; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeJobState.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeJobState.java index 85dab4b8e61f..8405a8dcb93e 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeJobState.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeJobState.java @@ -1,13 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.ai.textanalytics.models.TextAnalyticsError; import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; import java.util.List; /** The AnalyzeJobState model. */ @@ -16,26 +18,22 @@ public final class AnalyzeJobState extends AnalyzeJobMetadata { /* * The tasks property. */ - @JsonProperty(value = "tasks", required = true) private TasksStateTasksOld tasks; /* * The errors property. */ - @JsonProperty(value = "errors") private List errors; /* * if showStats=true was specified in the request this field will contain * information about the request payload. */ - @JsonProperty(value = "statistics") private RequestStatistics statistics; /* * The @nextLink property. */ - @JsonProperty(value = "@nextLink") private String nextLink; /** @@ -119,4 +117,49 @@ public AnalyzeJobState setNextLink(String nextLink) { this.nextLink = nextLink; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("tasks", this.tasks); + jsonWriter.writeArrayField("errors", this.errors, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("statistics", this.statistics); + jsonWriter.writeStringField("@nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AnalyzeJobState from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AnalyzeJobState 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 AnalyzeJobState. + */ + public static AnalyzeJobState fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AnalyzeJobState deserializedAnalyzeJobState = new AnalyzeJobState(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("tasks".equals(fieldName)) { + deserializedAnalyzeJobState.tasks = TasksStateTasksOld.fromJson(reader); + } else if ("errors".equals(fieldName)) { + deserializedAnalyzeJobState.errors = reader.readArray(reader1 -> TextAnalyticsError.fromJson(reader1)); + } else if ("statistics".equals(fieldName)) { + deserializedAnalyzeJobState.statistics = RequestStatistics.fromJson(reader); + } else if ("@nextLink".equals(fieldName)) { + deserializedAnalyzeJobState.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedAnalyzeJobState; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextEntityLinkingInput.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextEntityLinkingInput.java index 61c1bc1ec4c4..fb08d089e4a8 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextEntityLinkingInput.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextEntityLinkingInput.java @@ -9,11 +9,17 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** The AnalyzeTextEntityLinkingInput model. */ +/** + * The AnalyzeTextEntityLinkingInput model. + */ @Fluent public final class AnalyzeTextEntityLinkingInput extends AnalyzeTextTask { + /* + * Enumeration of supported Text Analysis tasks. + */ + private AnalyzeTextTaskKind kind = AnalyzeTextTaskKind.ENTITY_LINKING; + /* * The analysisInput property. */ @@ -24,12 +30,25 @@ public final class AnalyzeTextEntityLinkingInput extends AnalyzeTextTask { */ private EntityLinkingTaskParameters parameters; - /** Creates an instance of AnalyzeTextEntityLinkingInput class. */ - public AnalyzeTextEntityLinkingInput() {} + /** + * Creates an instance of AnalyzeTextEntityLinkingInput class. + */ + public AnalyzeTextEntityLinkingInput() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis tasks. + * + * @return the kind value. + */ + @Override + public AnalyzeTextTaskKind getKind() { + return this.kind; + } /** * Get the analysisInput property: The analysisInput property. - * + * * @return the analysisInput value. */ public MultiLanguageAnalysisInput getAnalysisInput() { @@ -38,7 +57,7 @@ public MultiLanguageAnalysisInput getAnalysisInput() { /** * Set the analysisInput property: The analysisInput property. - * + * * @param analysisInput the analysisInput value to set. * @return the AnalyzeTextEntityLinkingInput object itself. */ @@ -49,7 +68,7 @@ public AnalyzeTextEntityLinkingInput setAnalysisInput(MultiLanguageAnalysisInput /** * Get the parameters property: Supported parameters for an Entity Linking task. - * + * * @return the parameters value. */ public EntityLinkingTaskParameters getParameters() { @@ -58,7 +77,7 @@ public EntityLinkingTaskParameters getParameters() { /** * Set the parameters property: Supported parameters for an Entity Linking task. - * + * * @param parameters the parameters value to set. * @return the AnalyzeTextEntityLinkingInput object itself. */ @@ -67,10 +86,13 @@ public AnalyzeTextEntityLinkingInput setParameters(EntityLinkingTaskParameters p return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("kind", Objects.toString(AnalyzeTextTaskKind.ENTITY_LINKING, null)); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); jsonWriter.writeJsonField("analysisInput", this.analysisInput); jsonWriter.writeJsonField("parameters", this.parameters); return jsonWriter.writeEndObject(); @@ -78,42 +100,33 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of AnalyzeTextEntityLinkingInput from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of AnalyzeTextEntityLinkingInput 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 the polymorphic discriminator. + * if it was pointing to JSON null. * @throws IOException If an error occurs while reading the AnalyzeTextEntityLinkingInput. */ public static AnalyzeTextEntityLinkingInput fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - AnalyzeTextEntityLinkingInput deserializedAnalyzeTextEntityLinkingInput = - new AnalyzeTextEntityLinkingInput(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + AnalyzeTextEntityLinkingInput deserializedAnalyzeTextEntityLinkingInput + = new AnalyzeTextEntityLinkingInput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"EntityLinking".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'EntityLinking'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("analysisInput".equals(fieldName)) { - deserializedAnalyzeTextEntityLinkingInput.analysisInput = - MultiLanguageAnalysisInput.fromJson(reader); - } else if ("parameters".equals(fieldName)) { - deserializedAnalyzeTextEntityLinkingInput.parameters = - EntityLinkingTaskParameters.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("kind".equals(fieldName)) { + deserializedAnalyzeTextEntityLinkingInput.kind = AnalyzeTextTaskKind.fromString(reader.getString()); + } else if ("analysisInput".equals(fieldName)) { + deserializedAnalyzeTextEntityLinkingInput.analysisInput + = MultiLanguageAnalysisInput.fromJson(reader); + } else if ("parameters".equals(fieldName)) { + deserializedAnalyzeTextEntityLinkingInput.parameters = EntityLinkingTaskParameters.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedAnalyzeTextEntityLinkingInput; - }); + return deserializedAnalyzeTextEntityLinkingInput; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextEntityRecognitionInput.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextEntityRecognitionInput.java index f034d30b5992..6afd53ff3db0 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextEntityRecognitionInput.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextEntityRecognitionInput.java @@ -9,11 +9,17 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** The AnalyzeTextEntityRecognitionInput model. */ +/** + * The AnalyzeTextEntityRecognitionInput model. + */ @Fluent public final class AnalyzeTextEntityRecognitionInput extends AnalyzeTextTask { + /* + * Enumeration of supported Text Analysis tasks. + */ + private AnalyzeTextTaskKind kind = AnalyzeTextTaskKind.ENTITY_RECOGNITION; + /* * The analysisInput property. */ @@ -24,12 +30,25 @@ public final class AnalyzeTextEntityRecognitionInput extends AnalyzeTextTask { */ private EntitiesTaskParameters parameters; - /** Creates an instance of AnalyzeTextEntityRecognitionInput class. */ - public AnalyzeTextEntityRecognitionInput() {} + /** + * Creates an instance of AnalyzeTextEntityRecognitionInput class. + */ + public AnalyzeTextEntityRecognitionInput() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis tasks. + * + * @return the kind value. + */ + @Override + public AnalyzeTextTaskKind getKind() { + return this.kind; + } /** * Get the analysisInput property: The analysisInput property. - * + * * @return the analysisInput value. */ public MultiLanguageAnalysisInput getAnalysisInput() { @@ -38,7 +57,7 @@ public MultiLanguageAnalysisInput getAnalysisInput() { /** * Set the analysisInput property: The analysisInput property. - * + * * @param analysisInput the analysisInput value to set. * @return the AnalyzeTextEntityRecognitionInput object itself. */ @@ -49,7 +68,7 @@ public AnalyzeTextEntityRecognitionInput setAnalysisInput(MultiLanguageAnalysisI /** * Get the parameters property: Supported parameters for an Entity Recognition task. - * + * * @return the parameters value. */ public EntitiesTaskParameters getParameters() { @@ -58,7 +77,7 @@ public EntitiesTaskParameters getParameters() { /** * Set the parameters property: Supported parameters for an Entity Recognition task. - * + * * @param parameters the parameters value to set. * @return the AnalyzeTextEntityRecognitionInput object itself. */ @@ -67,10 +86,13 @@ public AnalyzeTextEntityRecognitionInput setParameters(EntitiesTaskParameters pa return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("kind", Objects.toString(AnalyzeTextTaskKind.ENTITY_RECOGNITION, null)); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); jsonWriter.writeJsonField("analysisInput", this.analysisInput); jsonWriter.writeJsonField("parameters", this.parameters); return jsonWriter.writeEndObject(); @@ -78,42 +100,34 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of AnalyzeTextEntityRecognitionInput from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of AnalyzeTextEntityRecognitionInput 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 the polymorphic discriminator. + * null if it was pointing to JSON null. * @throws IOException If an error occurs while reading the AnalyzeTextEntityRecognitionInput. */ public static AnalyzeTextEntityRecognitionInput fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - AnalyzeTextEntityRecognitionInput deserializedAnalyzeTextEntityRecognitionInput = - new AnalyzeTextEntityRecognitionInput(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + AnalyzeTextEntityRecognitionInput deserializedAnalyzeTextEntityRecognitionInput + = new AnalyzeTextEntityRecognitionInput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"EntityRecognition".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'EntityRecognition'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("analysisInput".equals(fieldName)) { - deserializedAnalyzeTextEntityRecognitionInput.analysisInput = - MultiLanguageAnalysisInput.fromJson(reader); - } else if ("parameters".equals(fieldName)) { - deserializedAnalyzeTextEntityRecognitionInput.parameters = - EntitiesTaskParameters.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("kind".equals(fieldName)) { + deserializedAnalyzeTextEntityRecognitionInput.kind + = AnalyzeTextTaskKind.fromString(reader.getString()); + } else if ("analysisInput".equals(fieldName)) { + deserializedAnalyzeTextEntityRecognitionInput.analysisInput + = MultiLanguageAnalysisInput.fromJson(reader); + } else if ("parameters".equals(fieldName)) { + deserializedAnalyzeTextEntityRecognitionInput.parameters = EntitiesTaskParameters.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedAnalyzeTextEntityRecognitionInput; - }); + return deserializedAnalyzeTextEntityRecognitionInput; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextJobState.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextJobState.java index b16fd365056d..30da248eda1a 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextJobState.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextJobState.java @@ -10,10 +10,12 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; import java.util.List; -import java.util.Objects; -/** The AnalyzeTextJobState model. */ +/** + * The AnalyzeTextJobState model. + */ @Fluent public final class AnalyzeTextJobState extends JobState { /* @@ -26,12 +28,15 @@ public final class AnalyzeTextJobState extends JobState { */ private RequestStatistics statistics; - /** Creates an instance of AnalyzeTextJobState class. */ - public AnalyzeTextJobState() {} + /** + * Creates an instance of AnalyzeTextJobState class. + */ + public AnalyzeTextJobState() { + } /** * Get the tasks property: The tasks property. - * + * * @return the tasks value. */ public TasksStateTasks getTasks() { @@ -40,7 +45,7 @@ public TasksStateTasks getTasks() { /** * Set the tasks property: The tasks property. - * + * * @param tasks the tasks value to set. * @return the AnalyzeTextJobState object itself. */ @@ -52,7 +57,7 @@ public AnalyzeTextJobState setTasks(TasksStateTasks tasks) { /** * Get the statistics property: if showStats=true was specified in the request this field will contain information * about the request payload. - * + * * @return the statistics value. */ public RequestStatistics getStatistics() { @@ -62,7 +67,7 @@ public RequestStatistics getStatistics() { /** * Set the statistics property: if showStats=true was specified in the request this field will contain information * about the request payload. - * + * * @param statistics the statistics value to set. * @return the AnalyzeTextJobState object itself. */ @@ -71,71 +76,97 @@ public AnalyzeTextJobState setStatistics(RequestStatistics statistics) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public AnalyzeTextJobState setDisplayName(String displayName) { super.setDisplayName(displayName); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public AnalyzeTextJobState setCreatedDateTime(OffsetDateTime createdDateTime) { super.setCreatedDateTime(createdDateTime); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public AnalyzeTextJobState setExpirationDateTime(OffsetDateTime expirationDateTime) { super.setExpirationDateTime(expirationDateTime); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public AnalyzeTextJobState setJobId(String jobId) { super.setJobId(jobId); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public AnalyzeTextJobState setLastUpdatedDateTime(OffsetDateTime lastUpdatedDateTime) { super.setLastUpdatedDateTime(lastUpdatedDateTime); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public AnalyzeTextJobState setStatus(State status) { super.setStatus(status); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public AnalyzeTextJobState setErrors(List errors) { super.setErrors(errors); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public AnalyzeTextJobState setNextLink(String nextLink) { super.setNextLink(nextLink); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("createdDateTime", Objects.toString(getCreatedDateTime(), null)); + jsonWriter.writeStringField("createdDateTime", + getCreatedDateTime() == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(getCreatedDateTime())); jsonWriter.writeStringField("jobId", getJobId()); - jsonWriter.writeStringField("lastUpdatedDateTime", Objects.toString(getLastUpdatedDateTime(), null)); - jsonWriter.writeStringField("status", Objects.toString(getStatus(), null)); + jsonWriter.writeStringField("lastUpdatedDateTime", + getLastUpdatedDateTime() == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(getLastUpdatedDateTime())); + jsonWriter.writeStringField("status", getStatus() == null ? null : getStatus().toString()); jsonWriter.writeStringField("displayName", getDisplayName()); - jsonWriter.writeStringField("expirationDateTime", Objects.toString(getExpirationDateTime(), null)); + jsonWriter.writeStringField("expirationDateTime", + getExpirationDateTime() == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(getExpirationDateTime())); jsonWriter.writeArrayField("errors", getErrors(), (writer, element) -> writer.writeJson(element)); jsonWriter.writeStringField("nextLink", getNextLink()); jsonWriter.writeJsonField("tasks", this.tasks); @@ -145,54 +176,50 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of AnalyzeTextJobState from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of AnalyzeTextJobState if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 AnalyzeTextJobState. */ public static AnalyzeTextJobState fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - AnalyzeTextJobState deserializedAnalyzeTextJobState = new AnalyzeTextJobState(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("createdDateTime".equals(fieldName)) { - deserializedAnalyzeTextJobState.setCreatedDateTime( - reader.getNullable( - nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); - } else if ("jobId".equals(fieldName)) { - deserializedAnalyzeTextJobState.setJobId(reader.getString()); - } else if ("lastUpdatedDateTime".equals(fieldName)) { - deserializedAnalyzeTextJobState.setLastUpdatedDateTime( - reader.getNullable( - nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); - } else if ("status".equals(fieldName)) { - deserializedAnalyzeTextJobState.setStatus(State.fromString(reader.getString())); - } else if ("displayName".equals(fieldName)) { - deserializedAnalyzeTextJobState.setDisplayName(reader.getString()); - } else if ("expirationDateTime".equals(fieldName)) { - deserializedAnalyzeTextJobState.setExpirationDateTime( - reader.getNullable( - nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); - } else if ("errors".equals(fieldName)) { - List errors = reader.readArray(reader1 -> Error.fromJson(reader1)); - deserializedAnalyzeTextJobState.setErrors(errors); - } else if ("nextLink".equals(fieldName)) { - deserializedAnalyzeTextJobState.setNextLink(reader.getString()); - } else if ("tasks".equals(fieldName)) { - deserializedAnalyzeTextJobState.tasks = TasksStateTasks.fromJson(reader); - } else if ("statistics".equals(fieldName)) { - deserializedAnalyzeTextJobState.statistics = RequestStatistics.fromJson(reader); - } else { - reader.skipChildren(); - } - } - - return deserializedAnalyzeTextJobState; - }); + return jsonReader.readObject(reader -> { + AnalyzeTextJobState deserializedAnalyzeTextJobState = new AnalyzeTextJobState(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("createdDateTime".equals(fieldName)) { + deserializedAnalyzeTextJobState.setCreatedDateTime( + reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); + } else if ("jobId".equals(fieldName)) { + deserializedAnalyzeTextJobState.setJobId(reader.getString()); + } else if ("lastUpdatedDateTime".equals(fieldName)) { + deserializedAnalyzeTextJobState.setLastUpdatedDateTime( + reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); + } else if ("status".equals(fieldName)) { + deserializedAnalyzeTextJobState.setStatus(State.fromString(reader.getString())); + } else if ("displayName".equals(fieldName)) { + deserializedAnalyzeTextJobState.setDisplayName(reader.getString()); + } else if ("expirationDateTime".equals(fieldName)) { + deserializedAnalyzeTextJobState.setExpirationDateTime( + reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); + } else if ("errors".equals(fieldName)) { + List errors = reader.readArray(reader1 -> Error.fromJson(reader1)); + deserializedAnalyzeTextJobState.setErrors(errors); + } else if ("nextLink".equals(fieldName)) { + deserializedAnalyzeTextJobState.setNextLink(reader.getString()); + } else if ("tasks".equals(fieldName)) { + deserializedAnalyzeTextJobState.tasks = TasksStateTasks.fromJson(reader); + } else if ("statistics".equals(fieldName)) { + deserializedAnalyzeTextJobState.statistics = RequestStatistics.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedAnalyzeTextJobState; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextJobStatistics.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextJobStatistics.java index 4115652b17fe..9bcdc8029ea7 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextJobStatistics.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextJobStatistics.java @@ -11,7 +11,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** The AnalyzeTextJobStatistics model. */ +/** + * The AnalyzeTextJobStatistics model. + */ @Fluent public class AnalyzeTextJobStatistics implements JsonSerializable { /* @@ -19,13 +21,16 @@ public class AnalyzeTextJobStatistics implements JsonSerializable { - AnalyzeTextJobStatistics deserializedAnalyzeTextJobStatistics = new AnalyzeTextJobStatistics(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + AnalyzeTextJobStatistics deserializedAnalyzeTextJobStatistics = new AnalyzeTextJobStatistics(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("statistics".equals(fieldName)) { - deserializedAnalyzeTextJobStatistics.statistics = RequestStatistics.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("statistics".equals(fieldName)) { + deserializedAnalyzeTextJobStatistics.statistics = RequestStatistics.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedAnalyzeTextJobStatistics; - }); + return deserializedAnalyzeTextJobStatistics; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextJobsInput.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextJobsInput.java index 6734a2380bb6..1aee23c60d3e 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextJobsInput.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextJobsInput.java @@ -12,7 +12,9 @@ import java.io.IOException; import java.util.List; -/** The AnalyzeTextJobsInput model. */ +/** + * The AnalyzeTextJobsInput model. + */ @Fluent public final class AnalyzeTextJobsInput implements JsonSerializable { /* @@ -30,12 +32,15 @@ public final class AnalyzeTextJobsInput implements JsonSerializable tasks; - /** Creates an instance of AnalyzeTextJobsInput class. */ - public AnalyzeTextJobsInput() {} + /** + * Creates an instance of AnalyzeTextJobsInput class. + */ + public AnalyzeTextJobsInput() { + } /** * Get the displayName property: Optional display name for the analysis job. - * + * * @return the displayName value. */ public String getDisplayName() { @@ -44,7 +49,7 @@ public String getDisplayName() { /** * Set the displayName property: Optional display name for the analysis job. - * + * * @param displayName the displayName value to set. * @return the AnalyzeTextJobsInput object itself. */ @@ -55,7 +60,7 @@ public AnalyzeTextJobsInput setDisplayName(String displayName) { /** * Get the analysisInput property: The analysisInput property. - * + * * @return the analysisInput value. */ public MultiLanguageAnalysisInput getAnalysisInput() { @@ -64,7 +69,7 @@ public MultiLanguageAnalysisInput getAnalysisInput() { /** * Set the analysisInput property: The analysisInput property. - * + * * @param analysisInput the analysisInput value to set. * @return the AnalyzeTextJobsInput object itself. */ @@ -75,7 +80,7 @@ public AnalyzeTextJobsInput setAnalysisInput(MultiLanguageAnalysisInput analysis /** * Get the tasks property: The set of tasks to execute on the input documents. - * + * * @return the tasks value. */ public List getTasks() { @@ -84,7 +89,7 @@ public List getTasks() { /** * Set the tasks property: The set of tasks to execute on the input documents. - * + * * @param tasks the tasks value to set. * @return the AnalyzeTextJobsInput object itself. */ @@ -93,6 +98,9 @@ public AnalyzeTextJobsInput setTasks(List tasks) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -104,36 +112,33 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of AnalyzeTextJobsInput from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of AnalyzeTextJobsInput if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. + * 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 AnalyzeTextJobsInput. */ public static AnalyzeTextJobsInput fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - AnalyzeTextJobsInput deserializedAnalyzeTextJobsInput = new AnalyzeTextJobsInput(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("analysisInput".equals(fieldName)) { - deserializedAnalyzeTextJobsInput.analysisInput = - MultiLanguageAnalysisInput.fromJson(reader); - } else if ("tasks".equals(fieldName)) { - List tasks = - reader.readArray(reader1 -> AnalyzeTextLROTask.fromJson(reader1)); - deserializedAnalyzeTextJobsInput.tasks = tasks; - } else if ("displayName".equals(fieldName)) { - deserializedAnalyzeTextJobsInput.displayName = reader.getString(); - } else { - reader.skipChildren(); - } - } - - return deserializedAnalyzeTextJobsInput; - }); + return jsonReader.readObject(reader -> { + AnalyzeTextJobsInput deserializedAnalyzeTextJobsInput = new AnalyzeTextJobsInput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("analysisInput".equals(fieldName)) { + deserializedAnalyzeTextJobsInput.analysisInput = MultiLanguageAnalysisInput.fromJson(reader); + } else if ("tasks".equals(fieldName)) { + List tasks = reader.readArray(reader1 -> AnalyzeTextLROTask.fromJson(reader1)); + deserializedAnalyzeTextJobsInput.tasks = tasks; + } else if ("displayName".equals(fieldName)) { + deserializedAnalyzeTextJobsInput.displayName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedAnalyzeTextJobsInput; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextKeyPhraseExtractionInput.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextKeyPhraseExtractionInput.java index 5f7f84f2188f..06285224038c 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextKeyPhraseExtractionInput.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextKeyPhraseExtractionInput.java @@ -9,11 +9,17 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** The AnalyzeTextKeyPhraseExtractionInput model. */ +/** + * The AnalyzeTextKeyPhraseExtractionInput model. + */ @Fluent public final class AnalyzeTextKeyPhraseExtractionInput extends AnalyzeTextTask { + /* + * Enumeration of supported Text Analysis tasks. + */ + private AnalyzeTextTaskKind kind = AnalyzeTextTaskKind.KEY_PHRASE_EXTRACTION; + /* * The analysisInput property. */ @@ -24,12 +30,25 @@ public final class AnalyzeTextKeyPhraseExtractionInput extends AnalyzeTextTask { */ private KeyPhraseTaskParameters parameters; - /** Creates an instance of AnalyzeTextKeyPhraseExtractionInput class. */ - public AnalyzeTextKeyPhraseExtractionInput() {} + /** + * Creates an instance of AnalyzeTextKeyPhraseExtractionInput class. + */ + public AnalyzeTextKeyPhraseExtractionInput() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis tasks. + * + * @return the kind value. + */ + @Override + public AnalyzeTextTaskKind getKind() { + return this.kind; + } /** * Get the analysisInput property: The analysisInput property. - * + * * @return the analysisInput value. */ public MultiLanguageAnalysisInput getAnalysisInput() { @@ -38,7 +57,7 @@ public MultiLanguageAnalysisInput getAnalysisInput() { /** * Set the analysisInput property: The analysisInput property. - * + * * @param analysisInput the analysisInput value to set. * @return the AnalyzeTextKeyPhraseExtractionInput object itself. */ @@ -49,7 +68,7 @@ public AnalyzeTextKeyPhraseExtractionInput setAnalysisInput(MultiLanguageAnalysi /** * Get the parameters property: Supported parameters for a Key Phrase Extraction task. - * + * * @return the parameters value. */ public KeyPhraseTaskParameters getParameters() { @@ -58,7 +77,7 @@ public KeyPhraseTaskParameters getParameters() { /** * Set the parameters property: Supported parameters for a Key Phrase Extraction task. - * + * * @param parameters the parameters value to set. * @return the AnalyzeTextKeyPhraseExtractionInput object itself. */ @@ -67,10 +86,13 @@ public AnalyzeTextKeyPhraseExtractionInput setParameters(KeyPhraseTaskParameters return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("kind", Objects.toString(AnalyzeTextTaskKind.KEY_PHRASE_EXTRACTION, null)); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); jsonWriter.writeJsonField("analysisInput", this.analysisInput); jsonWriter.writeJsonField("parameters", this.parameters); return jsonWriter.writeEndObject(); @@ -78,42 +100,35 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of AnalyzeTextKeyPhraseExtractionInput from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of AnalyzeTextKeyPhraseExtractionInput 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 the polymorphic discriminator. + * or null if it was pointing to JSON null. * @throws IOException If an error occurs while reading the AnalyzeTextKeyPhraseExtractionInput. */ public static AnalyzeTextKeyPhraseExtractionInput fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - AnalyzeTextKeyPhraseExtractionInput deserializedAnalyzeTextKeyPhraseExtractionInput = - new AnalyzeTextKeyPhraseExtractionInput(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + AnalyzeTextKeyPhraseExtractionInput deserializedAnalyzeTextKeyPhraseExtractionInput + = new AnalyzeTextKeyPhraseExtractionInput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"KeyPhraseExtraction".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'KeyPhraseExtraction'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("analysisInput".equals(fieldName)) { - deserializedAnalyzeTextKeyPhraseExtractionInput.analysisInput = - MultiLanguageAnalysisInput.fromJson(reader); - } else if ("parameters".equals(fieldName)) { - deserializedAnalyzeTextKeyPhraseExtractionInput.parameters = - KeyPhraseTaskParameters.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("kind".equals(fieldName)) { + deserializedAnalyzeTextKeyPhraseExtractionInput.kind + = AnalyzeTextTaskKind.fromString(reader.getString()); + } else if ("analysisInput".equals(fieldName)) { + deserializedAnalyzeTextKeyPhraseExtractionInput.analysisInput + = MultiLanguageAnalysisInput.fromJson(reader); + } else if ("parameters".equals(fieldName)) { + deserializedAnalyzeTextKeyPhraseExtractionInput.parameters + = KeyPhraseTaskParameters.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedAnalyzeTextKeyPhraseExtractionInput; - }); + return deserializedAnalyzeTextKeyPhraseExtractionInput; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextLROResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextLROResult.java index edfc05f91877..e72093bee195 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextLROResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextLROResult.java @@ -10,22 +10,42 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.time.OffsetDateTime; -import java.util.Objects; +import java.time.format.DateTimeFormatter; -/** The AnalyzeTextLROResult model. */ +/** + * The AnalyzeTextLROResult model. + */ @Fluent public class AnalyzeTextLROResult extends TaskState { + /* + * Enumeration of supported Text Analysis long-running operation task results. + */ + private AnalyzeTextLROResultsKind kind; + /* * The taskName property. */ private String taskName; - /** Creates an instance of AnalyzeTextLROResult class. */ - public AnalyzeTextLROResult() {} + /** + * Creates an instance of AnalyzeTextLROResult class. + */ + public AnalyzeTextLROResult() { + this.kind = AnalyzeTextLROResultsKind.fromString("AnalyzeTextLROResult"); + } + + /** + * Get the kind property: Enumeration of supported Text Analysis long-running operation task results. + * + * @return the kind value. + */ + public AnalyzeTextLROResultsKind getKind() { + return this.kind; + } /** * Get the taskName property: The taskName property. - * + * * @return the taskName value. */ public String getTaskName() { @@ -34,7 +54,7 @@ public String getTaskName() { /** * Set the taskName property: The taskName property. - * + * * @param taskName the taskName value to set. * @return the AnalyzeTextLROResult object itself. */ @@ -43,89 +63,116 @@ public AnalyzeTextLROResult setTaskName(String taskName) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public AnalyzeTextLROResult setLastUpdateDateTime(OffsetDateTime lastUpdateDateTime) { super.setLastUpdateDateTime(lastUpdateDateTime); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public AnalyzeTextLROResult setStatus(State status) { super.setStatus(status); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("lastUpdateDateTime", Objects.toString(getLastUpdateDateTime(), null)); - jsonWriter.writeStringField("status", Objects.toString(getStatus(), null)); + jsonWriter.writeStringField("lastUpdateDateTime", + getLastUpdateDateTime() == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(getLastUpdateDateTime())); + jsonWriter.writeStringField("status", getStatus() == null ? null : getStatus().toString()); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); jsonWriter.writeStringField("taskName", this.taskName); return jsonWriter.writeEndObject(); } /** * Reads an instance of AnalyzeTextLROResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of AnalyzeTextLROResult 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 or the - * polymorphic discriminator. + * 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 AnalyzeTextLROResult. */ public static AnalyzeTextLROResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - String discriminatorValue = null; - JsonReader readerToUse = reader.bufferObject(); - - readerToUse.nextToken(); // Prepare for reading - while (readerToUse.nextToken() != JsonToken.END_OBJECT) { - String fieldName = readerToUse.getFieldName(); - readerToUse.nextToken(); - if ("kind".equals(fieldName)) { - discriminatorValue = readerToUse.getString(); - break; - } else { - readerToUse.skipChildren(); - } - } - - if (discriminatorValue != null) { - readerToUse = readerToUse.reset(); - } - // Use the discriminator value to determine which subtype should be deserialized. - if ("EntityRecognitionLROResults".equals(discriminatorValue)) { - return EntityRecognitionLROResult.fromJson(readerToUse); - } else if ("CustomEntityRecognitionLROResults".equals(discriminatorValue)) { - return CustomEntityRecognitionLROResult.fromJson(readerToUse); - } else if ("CustomSingleLabelClassificationLROResults".equals(discriminatorValue)) { - return CustomSingleLabelClassificationLROResult.fromJson(readerToUse); - } else if ("CustomMultiLabelClassificationLROResults".equals(discriminatorValue)) { - return CustomMultiLabelClassificationLROResult.fromJson(readerToUse); - } else if ("EntityLinkingLROResults".equals(discriminatorValue)) { - return EntityLinkingLROResult.fromJson(readerToUse); - } else if ("PiiEntityRecognitionLROResults".equals(discriminatorValue)) { - return PiiEntityRecognitionLROResult.fromJson(readerToUse); - } else if ("ExtractiveSummarizationLROResults".equals(discriminatorValue)) { - return ExtractiveSummarizationLROResult.fromJson(readerToUse); - } else if ("HealthcareLROResults".equals(discriminatorValue)) { - return HealthcareLROResult.fromJson(readerToUse); - } else if ("SentimentAnalysisLROResults".equals(discriminatorValue)) { - return SentimentLROResult.fromJson(readerToUse); - } else if ("KeyPhraseExtractionLROResults".equals(discriminatorValue)) { - return KeyPhraseExtractionLROResult.fromJson(readerToUse); - } else if ("AbstractiveSummarizationLROResults".equals(discriminatorValue)) { - return AbstractiveSummarizationLROResult.fromJson(readerToUse); + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; } else { - throw new IllegalStateException( - "Discriminator field 'kind' didn't match one of the expected values 'EntityRecognitionLROResults', 'CustomEntityRecognitionLROResults', 'CustomSingleLabelClassificationLROResults', 'CustomMultiLabelClassificationLROResults', 'EntityLinkingLROResults', 'PiiEntityRecognitionLROResults', 'ExtractiveSummarizationLROResults', 'HealthcareLROResults', 'SentimentAnalysisLROResults', 'KeyPhraseExtractionLROResults', or 'AbstractiveSummarizationLROResults'. It was: '" - + discriminatorValue - + "'."); + readerToUse.skipChildren(); } - }); + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("EntityRecognitionLROResults".equals(discriminatorValue)) { + return EntityRecognitionLROResult.fromJson(readerToUse.reset()); + } else if ("CustomEntityRecognitionLROResults".equals(discriminatorValue)) { + return CustomEntityRecognitionLROResult.fromJson(readerToUse.reset()); + } else if ("CustomSingleLabelClassificationLROResults".equals(discriminatorValue)) { + return CustomSingleLabelClassificationLROResult.fromJson(readerToUse.reset()); + } else if ("CustomMultiLabelClassificationLROResults".equals(discriminatorValue)) { + return CustomMultiLabelClassificationLROResult.fromJson(readerToUse.reset()); + } else if ("EntityLinkingLROResults".equals(discriminatorValue)) { + return EntityLinkingLROResult.fromJson(readerToUse.reset()); + } else if ("PiiEntityRecognitionLROResults".equals(discriminatorValue)) { + return PiiEntityRecognitionLROResult.fromJson(readerToUse.reset()); + } else if ("ExtractiveSummarizationLROResults".equals(discriminatorValue)) { + return ExtractiveSummarizationLROResult.fromJson(readerToUse.reset()); + } else if ("HealthcareLROResults".equals(discriminatorValue)) { + return HealthcareLROResult.fromJson(readerToUse.reset()); + } else if ("SentimentAnalysisLROResults".equals(discriminatorValue)) { + return SentimentLROResult.fromJson(readerToUse.reset()); + } else if ("KeyPhraseExtractionLROResults".equals(discriminatorValue)) { + return KeyPhraseExtractionLROResult.fromJson(readerToUse.reset()); + } else if ("AbstractiveSummarizationLROResults".equals(discriminatorValue)) { + return AbstractiveSummarizationLROResult.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + static AnalyzeTextLROResult fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AnalyzeTextLROResult deserializedAnalyzeTextLROResult = new AnalyzeTextLROResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("lastUpdateDateTime".equals(fieldName)) { + deserializedAnalyzeTextLROResult.setLastUpdateDateTime( + reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); + } else if ("status".equals(fieldName)) { + deserializedAnalyzeTextLROResult.setStatus(State.fromString(reader.getString())); + } else if ("kind".equals(fieldName)) { + deserializedAnalyzeTextLROResult.kind = AnalyzeTextLROResultsKind.fromString(reader.getString()); + } else if ("taskName".equals(fieldName)) { + deserializedAnalyzeTextLROResult.taskName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedAnalyzeTextLROResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextLROResultsKind.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextLROResultsKind.java index c572715ad1e4..6503bce793ba 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextLROResultsKind.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextLROResultsKind.java @@ -7,61 +7,86 @@ import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; -/** Enumeration of supported Text Analysis long-running operation task results. */ +/** + * Enumeration of supported Text Analysis long-running operation task results. + */ public final class AnalyzeTextLROResultsKind extends ExpandableStringEnum { - /** Static value SentimentAnalysisLROResults for AnalyzeTextLROResultsKind. */ - public static final AnalyzeTextLROResultsKind SENTIMENT_ANALYSIS_LRORESULTS = - fromString("SentimentAnalysisLROResults"); + /** + * Static value SentimentAnalysisLROResults for AnalyzeTextLROResultsKind. + */ + public static final AnalyzeTextLROResultsKind SENTIMENT_ANALYSIS_LRORESULTS + = fromString("SentimentAnalysisLROResults"); - /** Static value EntityRecognitionLROResults for AnalyzeTextLROResultsKind. */ - public static final AnalyzeTextLROResultsKind ENTITY_RECOGNITION_LRORESULTS = - fromString("EntityRecognitionLROResults"); + /** + * Static value EntityRecognitionLROResults for AnalyzeTextLROResultsKind. + */ + public static final AnalyzeTextLROResultsKind ENTITY_RECOGNITION_LRORESULTS + = fromString("EntityRecognitionLROResults"); - /** Static value PiiEntityRecognitionLROResults for AnalyzeTextLROResultsKind. */ - public static final AnalyzeTextLROResultsKind PII_ENTITY_RECOGNITION_LRORESULTS = - fromString("PiiEntityRecognitionLROResults"); + /** + * Static value PiiEntityRecognitionLROResults for AnalyzeTextLROResultsKind. + */ + public static final AnalyzeTextLROResultsKind PII_ENTITY_RECOGNITION_LRORESULTS + = fromString("PiiEntityRecognitionLROResults"); - /** Static value KeyPhraseExtractionLROResults for AnalyzeTextLROResultsKind. */ - public static final AnalyzeTextLROResultsKind KEY_PHRASE_EXTRACTION_LRORESULTS = - fromString("KeyPhraseExtractionLROResults"); + /** + * Static value KeyPhraseExtractionLROResults for AnalyzeTextLROResultsKind. + */ + public static final AnalyzeTextLROResultsKind KEY_PHRASE_EXTRACTION_LRORESULTS + = fromString("KeyPhraseExtractionLROResults"); - /** Static value EntityLinkingLROResults for AnalyzeTextLROResultsKind. */ + /** + * Static value EntityLinkingLROResults for AnalyzeTextLROResultsKind. + */ public static final AnalyzeTextLROResultsKind ENTITY_LINKING_LRORESULTS = fromString("EntityLinkingLROResults"); - /** Static value HealthcareLROResults for AnalyzeTextLROResultsKind. */ + /** + * Static value HealthcareLROResults for AnalyzeTextLROResultsKind. + */ public static final AnalyzeTextLROResultsKind HEALTHCARE_LRORESULTS = fromString("HealthcareLROResults"); - /** Static value ExtractiveSummarizationLROResults for AnalyzeTextLROResultsKind. */ - public static final AnalyzeTextLROResultsKind EXTRACTIVE_SUMMARIZATION_LRORESULTS = - fromString("ExtractiveSummarizationLROResults"); + /** + * Static value ExtractiveSummarizationLROResults for AnalyzeTextLROResultsKind. + */ + public static final AnalyzeTextLROResultsKind EXTRACTIVE_SUMMARIZATION_LRORESULTS + = fromString("ExtractiveSummarizationLROResults"); - /** Static value CustomEntityRecognitionLROResults for AnalyzeTextLROResultsKind. */ - public static final AnalyzeTextLROResultsKind CUSTOM_ENTITY_RECOGNITION_LRORESULTS = - fromString("CustomEntityRecognitionLROResults"); + /** + * Static value CustomEntityRecognitionLROResults for AnalyzeTextLROResultsKind. + */ + public static final AnalyzeTextLROResultsKind CUSTOM_ENTITY_RECOGNITION_LRORESULTS + = fromString("CustomEntityRecognitionLROResults"); - /** Static value CustomSingleLabelClassificationLROResults for AnalyzeTextLROResultsKind. */ - public static final AnalyzeTextLROResultsKind CUSTOM_SINGLE_LABEL_CLASSIFICATION_LRORESULTS = - fromString("CustomSingleLabelClassificationLROResults"); + /** + * Static value CustomSingleLabelClassificationLROResults for AnalyzeTextLROResultsKind. + */ + public static final AnalyzeTextLROResultsKind CUSTOM_SINGLE_LABEL_CLASSIFICATION_LRORESULTS + = fromString("CustomSingleLabelClassificationLROResults"); - /** Static value CustomMultiLabelClassificationLROResults for AnalyzeTextLROResultsKind. */ - public static final AnalyzeTextLROResultsKind CUSTOM_MULTI_LABEL_CLASSIFICATION_LRORESULTS = - fromString("CustomMultiLabelClassificationLROResults"); + /** + * Static value CustomMultiLabelClassificationLROResults for AnalyzeTextLROResultsKind. + */ + public static final AnalyzeTextLROResultsKind CUSTOM_MULTI_LABEL_CLASSIFICATION_LRORESULTS + = fromString("CustomMultiLabelClassificationLROResults"); - /** Static value AbstractiveSummarizationLROResults for AnalyzeTextLROResultsKind. */ - public static final AnalyzeTextLROResultsKind ABSTRACTIVE_SUMMARIZATION_LRORESULTS = - fromString("AbstractiveSummarizationLROResults"); + /** + * Static value AbstractiveSummarizationLROResults for AnalyzeTextLROResultsKind. + */ + public static final AnalyzeTextLROResultsKind ABSTRACTIVE_SUMMARIZATION_LRORESULTS + = fromString("AbstractiveSummarizationLROResults"); /** * Creates a new instance of AnalyzeTextLROResultsKind value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated - public AnalyzeTextLROResultsKind() {} + public AnalyzeTextLROResultsKind() { + } /** * Creates or finds a AnalyzeTextLROResultsKind from its string representation. - * + * * @param name a name to look for. * @return the corresponding AnalyzeTextLROResultsKind. */ @@ -71,7 +96,7 @@ public static AnalyzeTextLROResultsKind fromString(String name) { /** * Gets known AnalyzeTextLROResultsKind values. - * + * * @return known AnalyzeTextLROResultsKind values. */ public static Collection values() { diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextLROTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextLROTask.java index da7e65bd4142..3b1a46fc5e90 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextLROTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextLROTask.java @@ -10,85 +10,122 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** The AnalyzeTextLROTask model. */ +/** + * The AnalyzeTextLROTask model. + */ @Fluent public class AnalyzeTextLROTask extends TaskIdentifier { - /** Creates an instance of AnalyzeTextLROTask class. */ - public AnalyzeTextLROTask() {} + /* + * Enumeration of supported long-running Text Analysis tasks. + */ + private AnalyzeTextLROTaskKind kind; + + /** + * Creates an instance of AnalyzeTextLROTask class. + */ + public AnalyzeTextLROTask() { + this.kind = AnalyzeTextLROTaskKind.fromString("AnalyzeTextLROTask"); + } - /** {@inheritDoc} */ + /** + * Get the kind property: Enumeration of supported long-running Text Analysis tasks. + * + * @return the kind value. + */ + public AnalyzeTextLROTaskKind getKind() { + return this.kind; + } + + /** + * {@inheritDoc} + */ @Override public AnalyzeTextLROTask setTaskName(String taskName) { super.setTaskName(taskName); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); jsonWriter.writeStringField("taskName", getTaskName()); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of AnalyzeTextLROTask from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of AnalyzeTextLROTask 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 the polymorphic discriminator. + * pointing to JSON null. * @throws IOException If an error occurs while reading the AnalyzeTextLROTask. */ public static AnalyzeTextLROTask fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - String discriminatorValue = null; - JsonReader readerToUse = reader.bufferObject(); - - readerToUse.nextToken(); // Prepare for reading - while (readerToUse.nextToken() != JsonToken.END_OBJECT) { - String fieldName = readerToUse.getFieldName(); - readerToUse.nextToken(); - if ("kind".equals(fieldName)) { - discriminatorValue = readerToUse.getString(); - break; - } else { - readerToUse.skipChildren(); - } - } - - if (discriminatorValue != null) { - readerToUse = readerToUse.reset(); - } - // Use the discriminator value to determine which subtype should be deserialized. - if ("CustomEntityRecognition".equals(discriminatorValue)) { - return CustomEntitiesLROTask.fromJson(readerToUse); - } else if ("CustomSingleLabelClassification".equals(discriminatorValue)) { - return CustomSingleLabelClassificationLROTask.fromJson(readerToUse); - } else if ("CustomMultiLabelClassification".equals(discriminatorValue)) { - return CustomMultiLabelClassificationLROTask.fromJson(readerToUse); - } else if ("Healthcare".equals(discriminatorValue)) { - return HealthcareLROTask.fromJson(readerToUse); - } else if ("SentimentAnalysis".equals(discriminatorValue)) { - return SentimentAnalysisLROTask.fromJson(readerToUse); - } else if ("EntityRecognition".equals(discriminatorValue)) { - return EntitiesLROTask.fromJson(readerToUse); - } else if ("EntityLinking".equals(discriminatorValue)) { - return EntityLinkingLROTask.fromJson(readerToUse); - } else if ("PiiEntityRecognition".equals(discriminatorValue)) { - return PiiLROTask.fromJson(readerToUse); - } else if ("ExtractiveSummarization".equals(discriminatorValue)) { - return ExtractiveSummarizationLROTask.fromJson(readerToUse); - } else if ("KeyPhraseExtraction".equals(discriminatorValue)) { - return KeyPhraseLROTask.fromJson(readerToUse); - } else if ("AbstractiveSummarization".equals(discriminatorValue)) { - return AbstractiveSummarizationLROTask.fromJson(readerToUse); + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; } else { - throw new IllegalStateException( - "Discriminator field 'kind' didn't match one of the expected values 'CustomEntityRecognition', 'CustomSingleLabelClassification', 'CustomMultiLabelClassification', 'Healthcare', 'SentimentAnalysis', 'EntityRecognition', 'EntityLinking', 'PiiEntityRecognition', 'ExtractiveSummarization', 'KeyPhraseExtraction', or 'AbstractiveSummarization'. It was: '" - + discriminatorValue - + "'."); + readerToUse.skipChildren(); } - }); + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("CustomEntityRecognition".equals(discriminatorValue)) { + return CustomEntitiesLROTask.fromJson(readerToUse.reset()); + } else if ("CustomSingleLabelClassification".equals(discriminatorValue)) { + return CustomSingleLabelClassificationLROTask.fromJson(readerToUse.reset()); + } else if ("CustomMultiLabelClassification".equals(discriminatorValue)) { + return CustomMultiLabelClassificationLROTask.fromJson(readerToUse.reset()); + } else if ("Healthcare".equals(discriminatorValue)) { + return HealthcareLROTask.fromJson(readerToUse.reset()); + } else if ("SentimentAnalysis".equals(discriminatorValue)) { + return SentimentAnalysisLROTask.fromJson(readerToUse.reset()); + } else if ("EntityRecognition".equals(discriminatorValue)) { + return EntitiesLROTask.fromJson(readerToUse.reset()); + } else if ("EntityLinking".equals(discriminatorValue)) { + return EntityLinkingLROTask.fromJson(readerToUse.reset()); + } else if ("PiiEntityRecognition".equals(discriminatorValue)) { + return PiiLROTask.fromJson(readerToUse.reset()); + } else if ("ExtractiveSummarization".equals(discriminatorValue)) { + return ExtractiveSummarizationLROTask.fromJson(readerToUse.reset()); + } else if ("KeyPhraseExtraction".equals(discriminatorValue)) { + return KeyPhraseLROTask.fromJson(readerToUse.reset()); + } else if ("AbstractiveSummarization".equals(discriminatorValue)) { + return AbstractiveSummarizationLROTask.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + static AnalyzeTextLROTask fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AnalyzeTextLROTask deserializedAnalyzeTextLROTask = new AnalyzeTextLROTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("taskName".equals(fieldName)) { + deserializedAnalyzeTextLROTask.setTaskName(reader.getString()); + } else if ("kind".equals(fieldName)) { + deserializedAnalyzeTextLROTask.kind = AnalyzeTextLROTaskKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedAnalyzeTextLROTask; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextLROTaskKind.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextLROTaskKind.java index fb5a86b6259a..8fcc88420220 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextLROTaskKind.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextLROTaskKind.java @@ -7,54 +7,79 @@ import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; -/** Enumeration of supported long-running Text Analysis tasks. */ +/** + * Enumeration of supported long-running Text Analysis tasks. + */ public final class AnalyzeTextLROTaskKind extends ExpandableStringEnum { - /** Static value SentimentAnalysis for AnalyzeTextLROTaskKind. */ + /** + * Static value SentimentAnalysis for AnalyzeTextLROTaskKind. + */ public static final AnalyzeTextLROTaskKind SENTIMENT_ANALYSIS = fromString("SentimentAnalysis"); - /** Static value EntityRecognition for AnalyzeTextLROTaskKind. */ + /** + * Static value EntityRecognition for AnalyzeTextLROTaskKind. + */ public static final AnalyzeTextLROTaskKind ENTITY_RECOGNITION = fromString("EntityRecognition"); - /** Static value PiiEntityRecognition for AnalyzeTextLROTaskKind. */ + /** + * Static value PiiEntityRecognition for AnalyzeTextLROTaskKind. + */ public static final AnalyzeTextLROTaskKind PII_ENTITY_RECOGNITION = fromString("PiiEntityRecognition"); - /** Static value KeyPhraseExtraction for AnalyzeTextLROTaskKind. */ + /** + * Static value KeyPhraseExtraction for AnalyzeTextLROTaskKind. + */ public static final AnalyzeTextLROTaskKind KEY_PHRASE_EXTRACTION = fromString("KeyPhraseExtraction"); - /** Static value EntityLinking for AnalyzeTextLROTaskKind. */ + /** + * Static value EntityLinking for AnalyzeTextLROTaskKind. + */ public static final AnalyzeTextLROTaskKind ENTITY_LINKING = fromString("EntityLinking"); - /** Static value Healthcare for AnalyzeTextLROTaskKind. */ + /** + * Static value Healthcare for AnalyzeTextLROTaskKind. + */ public static final AnalyzeTextLROTaskKind HEALTHCARE = fromString("Healthcare"); - /** Static value ExtractiveSummarization for AnalyzeTextLROTaskKind. */ + /** + * Static value ExtractiveSummarization for AnalyzeTextLROTaskKind. + */ public static final AnalyzeTextLROTaskKind EXTRACTIVE_SUMMARIZATION = fromString("ExtractiveSummarization"); - /** Static value CustomEntityRecognition for AnalyzeTextLROTaskKind. */ + /** + * Static value CustomEntityRecognition for AnalyzeTextLROTaskKind. + */ public static final AnalyzeTextLROTaskKind CUSTOM_ENTITY_RECOGNITION = fromString("CustomEntityRecognition"); - /** Static value CustomSingleLabelClassification for AnalyzeTextLROTaskKind. */ - public static final AnalyzeTextLROTaskKind CUSTOM_SINGLE_LABEL_CLASSIFICATION = - fromString("CustomSingleLabelClassification"); + /** + * Static value CustomSingleLabelClassification for AnalyzeTextLROTaskKind. + */ + public static final AnalyzeTextLROTaskKind CUSTOM_SINGLE_LABEL_CLASSIFICATION + = fromString("CustomSingleLabelClassification"); - /** Static value CustomMultiLabelClassification for AnalyzeTextLROTaskKind. */ - public static final AnalyzeTextLROTaskKind CUSTOM_MULTI_LABEL_CLASSIFICATION = - fromString("CustomMultiLabelClassification"); + /** + * Static value CustomMultiLabelClassification for AnalyzeTextLROTaskKind. + */ + public static final AnalyzeTextLROTaskKind CUSTOM_MULTI_LABEL_CLASSIFICATION + = fromString("CustomMultiLabelClassification"); - /** Static value AbstractiveSummarization for AnalyzeTextLROTaskKind. */ + /** + * Static value AbstractiveSummarization for AnalyzeTextLROTaskKind. + */ public static final AnalyzeTextLROTaskKind ABSTRACTIVE_SUMMARIZATION = fromString("AbstractiveSummarization"); /** * Creates a new instance of AnalyzeTextLROTaskKind value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated - public AnalyzeTextLROTaskKind() {} + public AnalyzeTextLROTaskKind() { + } /** * Creates or finds a AnalyzeTextLROTaskKind from its string representation. - * + * * @param name a name to look for. * @return the corresponding AnalyzeTextLROTaskKind. */ @@ -64,7 +89,7 @@ public static AnalyzeTextLROTaskKind fromString(String name) { /** * Gets known AnalyzeTextLROTaskKind values. - * + * * @return known AnalyzeTextLROTaskKind values. */ public static Collection values() { diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextLanguageDetectionInput.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextLanguageDetectionInput.java index e29945bfabe7..458a51a12aae 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextLanguageDetectionInput.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextLanguageDetectionInput.java @@ -9,11 +9,17 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** The AnalyzeTextLanguageDetectionInput model. */ +/** + * The AnalyzeTextLanguageDetectionInput model. + */ @Fluent public final class AnalyzeTextLanguageDetectionInput extends AnalyzeTextTask { + /* + * Enumeration of supported Text Analysis tasks. + */ + private AnalyzeTextTaskKind kind = AnalyzeTextTaskKind.LANGUAGE_DETECTION; + /* * The analysisInput property. */ @@ -24,12 +30,25 @@ public final class AnalyzeTextLanguageDetectionInput extends AnalyzeTextTask { */ private LanguageDetectionTaskParameters parameters; - /** Creates an instance of AnalyzeTextLanguageDetectionInput class. */ - public AnalyzeTextLanguageDetectionInput() {} + /** + * Creates an instance of AnalyzeTextLanguageDetectionInput class. + */ + public AnalyzeTextLanguageDetectionInput() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis tasks. + * + * @return the kind value. + */ + @Override + public AnalyzeTextTaskKind getKind() { + return this.kind; + } /** * Get the analysisInput property: The analysisInput property. - * + * * @return the analysisInput value. */ public LanguageDetectionAnalysisInput getAnalysisInput() { @@ -38,7 +57,7 @@ public LanguageDetectionAnalysisInput getAnalysisInput() { /** * Set the analysisInput property: The analysisInput property. - * + * * @param analysisInput the analysisInput value to set. * @return the AnalyzeTextLanguageDetectionInput object itself. */ @@ -49,7 +68,7 @@ public AnalyzeTextLanguageDetectionInput setAnalysisInput(LanguageDetectionAnaly /** * Get the parameters property: Supported parameters for a Language Detection task. - * + * * @return the parameters value. */ public LanguageDetectionTaskParameters getParameters() { @@ -58,7 +77,7 @@ public LanguageDetectionTaskParameters getParameters() { /** * Set the parameters property: Supported parameters for a Language Detection task. - * + * * @param parameters the parameters value to set. * @return the AnalyzeTextLanguageDetectionInput object itself. */ @@ -67,10 +86,13 @@ public AnalyzeTextLanguageDetectionInput setParameters(LanguageDetectionTaskPara return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("kind", Objects.toString(AnalyzeTextTaskKind.LANGUAGE_DETECTION, null)); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); jsonWriter.writeJsonField("analysisInput", this.analysisInput); jsonWriter.writeJsonField("parameters", this.parameters); return jsonWriter.writeEndObject(); @@ -78,42 +100,35 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of AnalyzeTextLanguageDetectionInput from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of AnalyzeTextLanguageDetectionInput 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 the polymorphic discriminator. + * null if it was pointing to JSON null. * @throws IOException If an error occurs while reading the AnalyzeTextLanguageDetectionInput. */ public static AnalyzeTextLanguageDetectionInput fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - AnalyzeTextLanguageDetectionInput deserializedAnalyzeTextLanguageDetectionInput = - new AnalyzeTextLanguageDetectionInput(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + AnalyzeTextLanguageDetectionInput deserializedAnalyzeTextLanguageDetectionInput + = new AnalyzeTextLanguageDetectionInput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"LanguageDetection".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'LanguageDetection'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("analysisInput".equals(fieldName)) { - deserializedAnalyzeTextLanguageDetectionInput.analysisInput = - LanguageDetectionAnalysisInput.fromJson(reader); - } else if ("parameters".equals(fieldName)) { - deserializedAnalyzeTextLanguageDetectionInput.parameters = - LanguageDetectionTaskParameters.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("kind".equals(fieldName)) { + deserializedAnalyzeTextLanguageDetectionInput.kind + = AnalyzeTextTaskKind.fromString(reader.getString()); + } else if ("analysisInput".equals(fieldName)) { + deserializedAnalyzeTextLanguageDetectionInput.analysisInput + = LanguageDetectionAnalysisInput.fromJson(reader); + } else if ("parameters".equals(fieldName)) { + deserializedAnalyzeTextLanguageDetectionInput.parameters + = LanguageDetectionTaskParameters.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedAnalyzeTextLanguageDetectionInput; - }); + return deserializedAnalyzeTextLanguageDetectionInput; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextPiiEntitiesRecognitionInput.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextPiiEntitiesRecognitionInput.java index 40e22f597331..faed1ed1e7e7 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextPiiEntitiesRecognitionInput.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextPiiEntitiesRecognitionInput.java @@ -9,11 +9,17 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** The AnalyzeTextPiiEntitiesRecognitionInput model. */ +/** + * The AnalyzeTextPiiEntitiesRecognitionInput model. + */ @Fluent public final class AnalyzeTextPiiEntitiesRecognitionInput extends AnalyzeTextTask { + /* + * Enumeration of supported Text Analysis tasks. + */ + private AnalyzeTextTaskKind kind = AnalyzeTextTaskKind.PII_ENTITY_RECOGNITION; + /* * The analysisInput property. */ @@ -24,12 +30,25 @@ public final class AnalyzeTextPiiEntitiesRecognitionInput extends AnalyzeTextTas */ private PiiTaskParameters parameters; - /** Creates an instance of AnalyzeTextPiiEntitiesRecognitionInput class. */ - public AnalyzeTextPiiEntitiesRecognitionInput() {} + /** + * Creates an instance of AnalyzeTextPiiEntitiesRecognitionInput class. + */ + public AnalyzeTextPiiEntitiesRecognitionInput() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis tasks. + * + * @return the kind value. + */ + @Override + public AnalyzeTextTaskKind getKind() { + return this.kind; + } /** * Get the analysisInput property: The analysisInput property. - * + * * @return the analysisInput value. */ public MultiLanguageAnalysisInput getAnalysisInput() { @@ -38,7 +57,7 @@ public MultiLanguageAnalysisInput getAnalysisInput() { /** * Set the analysisInput property: The analysisInput property. - * + * * @param analysisInput the analysisInput value to set. * @return the AnalyzeTextPiiEntitiesRecognitionInput object itself. */ @@ -49,7 +68,7 @@ public AnalyzeTextPiiEntitiesRecognitionInput setAnalysisInput(MultiLanguageAnal /** * Get the parameters property: Supported parameters for a PII Entities Recognition task. - * + * * @return the parameters value. */ public PiiTaskParameters getParameters() { @@ -58,7 +77,7 @@ public PiiTaskParameters getParameters() { /** * Set the parameters property: Supported parameters for a PII Entities Recognition task. - * + * * @param parameters the parameters value to set. * @return the AnalyzeTextPiiEntitiesRecognitionInput object itself. */ @@ -67,10 +86,13 @@ public AnalyzeTextPiiEntitiesRecognitionInput setParameters(PiiTaskParameters pa return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("kind", Objects.toString(AnalyzeTextTaskKind.PII_ENTITY_RECOGNITION, null)); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); jsonWriter.writeJsonField("analysisInput", this.analysisInput); jsonWriter.writeJsonField("parameters", this.parameters); return jsonWriter.writeEndObject(); @@ -78,42 +100,34 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of AnalyzeTextPiiEntitiesRecognitionInput from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of AnalyzeTextPiiEntitiesRecognitionInput 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 the polymorphic discriminator. + * it, or null if it was pointing to JSON null. * @throws IOException If an error occurs while reading the AnalyzeTextPiiEntitiesRecognitionInput. */ public static AnalyzeTextPiiEntitiesRecognitionInput fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - AnalyzeTextPiiEntitiesRecognitionInput deserializedAnalyzeTextPiiEntitiesRecognitionInput = - new AnalyzeTextPiiEntitiesRecognitionInput(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + AnalyzeTextPiiEntitiesRecognitionInput deserializedAnalyzeTextPiiEntitiesRecognitionInput + = new AnalyzeTextPiiEntitiesRecognitionInput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"PiiEntityRecognition".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'PiiEntityRecognition'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("analysisInput".equals(fieldName)) { - deserializedAnalyzeTextPiiEntitiesRecognitionInput.analysisInput = - MultiLanguageAnalysisInput.fromJson(reader); - } else if ("parameters".equals(fieldName)) { - deserializedAnalyzeTextPiiEntitiesRecognitionInput.parameters = - PiiTaskParameters.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("kind".equals(fieldName)) { + deserializedAnalyzeTextPiiEntitiesRecognitionInput.kind + = AnalyzeTextTaskKind.fromString(reader.getString()); + } else if ("analysisInput".equals(fieldName)) { + deserializedAnalyzeTextPiiEntitiesRecognitionInput.analysisInput + = MultiLanguageAnalysisInput.fromJson(reader); + } else if ("parameters".equals(fieldName)) { + deserializedAnalyzeTextPiiEntitiesRecognitionInput.parameters = PiiTaskParameters.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedAnalyzeTextPiiEntitiesRecognitionInput; - }); + return deserializedAnalyzeTextPiiEntitiesRecognitionInput; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextSentimentAnalysisInput.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextSentimentAnalysisInput.java index 9d32afbfed10..d761fd47eaf5 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextSentimentAnalysisInput.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextSentimentAnalysisInput.java @@ -9,11 +9,17 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** The AnalyzeTextSentimentAnalysisInput model. */ +/** + * The AnalyzeTextSentimentAnalysisInput model. + */ @Fluent public final class AnalyzeTextSentimentAnalysisInput extends AnalyzeTextTask { + /* + * Enumeration of supported Text Analysis tasks. + */ + private AnalyzeTextTaskKind kind = AnalyzeTextTaskKind.SENTIMENT_ANALYSIS; + /* * The analysisInput property. */ @@ -24,12 +30,25 @@ public final class AnalyzeTextSentimentAnalysisInput extends AnalyzeTextTask { */ private SentimentAnalysisTaskParameters parameters; - /** Creates an instance of AnalyzeTextSentimentAnalysisInput class. */ - public AnalyzeTextSentimentAnalysisInput() {} + /** + * Creates an instance of AnalyzeTextSentimentAnalysisInput class. + */ + public AnalyzeTextSentimentAnalysisInput() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis tasks. + * + * @return the kind value. + */ + @Override + public AnalyzeTextTaskKind getKind() { + return this.kind; + } /** * Get the analysisInput property: The analysisInput property. - * + * * @return the analysisInput value. */ public MultiLanguageAnalysisInput getAnalysisInput() { @@ -38,7 +57,7 @@ public MultiLanguageAnalysisInput getAnalysisInput() { /** * Set the analysisInput property: The analysisInput property. - * + * * @param analysisInput the analysisInput value to set. * @return the AnalyzeTextSentimentAnalysisInput object itself. */ @@ -49,7 +68,7 @@ public AnalyzeTextSentimentAnalysisInput setAnalysisInput(MultiLanguageAnalysisI /** * Get the parameters property: Supported parameters for a Sentiment Analysis task. - * + * * @return the parameters value. */ public SentimentAnalysisTaskParameters getParameters() { @@ -58,7 +77,7 @@ public SentimentAnalysisTaskParameters getParameters() { /** * Set the parameters property: Supported parameters for a Sentiment Analysis task. - * + * * @param parameters the parameters value to set. * @return the AnalyzeTextSentimentAnalysisInput object itself. */ @@ -67,10 +86,13 @@ public AnalyzeTextSentimentAnalysisInput setParameters(SentimentAnalysisTaskPara return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("kind", Objects.toString(AnalyzeTextTaskKind.SENTIMENT_ANALYSIS, null)); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); jsonWriter.writeJsonField("analysisInput", this.analysisInput); jsonWriter.writeJsonField("parameters", this.parameters); return jsonWriter.writeEndObject(); @@ -78,42 +100,35 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of AnalyzeTextSentimentAnalysisInput from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of AnalyzeTextSentimentAnalysisInput 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 the polymorphic discriminator. + * null if it was pointing to JSON null. * @throws IOException If an error occurs while reading the AnalyzeTextSentimentAnalysisInput. */ public static AnalyzeTextSentimentAnalysisInput fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - AnalyzeTextSentimentAnalysisInput deserializedAnalyzeTextSentimentAnalysisInput = - new AnalyzeTextSentimentAnalysisInput(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + AnalyzeTextSentimentAnalysisInput deserializedAnalyzeTextSentimentAnalysisInput + = new AnalyzeTextSentimentAnalysisInput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"SentimentAnalysis".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'SentimentAnalysis'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("analysisInput".equals(fieldName)) { - deserializedAnalyzeTextSentimentAnalysisInput.analysisInput = - MultiLanguageAnalysisInput.fromJson(reader); - } else if ("parameters".equals(fieldName)) { - deserializedAnalyzeTextSentimentAnalysisInput.parameters = - SentimentAnalysisTaskParameters.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("kind".equals(fieldName)) { + deserializedAnalyzeTextSentimentAnalysisInput.kind + = AnalyzeTextTaskKind.fromString(reader.getString()); + } else if ("analysisInput".equals(fieldName)) { + deserializedAnalyzeTextSentimentAnalysisInput.analysisInput + = MultiLanguageAnalysisInput.fromJson(reader); + } else if ("parameters".equals(fieldName)) { + deserializedAnalyzeTextSentimentAnalysisInput.parameters + = SentimentAnalysisTaskParameters.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedAnalyzeTextSentimentAnalysisInput; - }); + return deserializedAnalyzeTextSentimentAnalysisInput; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextTask.java index 7c0536af2d74..6e72fd362b46 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextTask.java @@ -11,67 +11,100 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** The AnalyzeTextTask model. */ +/** + * The AnalyzeTextTask model. + */ @Immutable public class AnalyzeTextTask implements JsonSerializable { - /** Creates an instance of AnalyzeTextTask class. */ - public AnalyzeTextTask() {} + /* + * Enumeration of supported Text Analysis tasks. + */ + private AnalyzeTextTaskKind kind; + + /** + * Creates an instance of AnalyzeTextTask class. + */ + public AnalyzeTextTask() { + this.kind = AnalyzeTextTaskKind.fromString("AnalyzeTextTask"); + } + /** + * Get the kind property: Enumeration of supported Text Analysis tasks. + * + * @return the kind value. + */ + public AnalyzeTextTaskKind getKind() { + return this.kind; + } + + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of AnalyzeTextTask from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of AnalyzeTextTask 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 the polymorphic discriminator. + * pointing to JSON null. * @throws IOException If an error occurs while reading the AnalyzeTextTask. */ public static AnalyzeTextTask fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - String discriminatorValue = null; - JsonReader readerToUse = reader.bufferObject(); - - readerToUse.nextToken(); // Prepare for reading - while (readerToUse.nextToken() != JsonToken.END_OBJECT) { - String fieldName = readerToUse.getFieldName(); - readerToUse.nextToken(); - if ("kind".equals(fieldName)) { - discriminatorValue = readerToUse.getString(); - break; - } else { - readerToUse.skipChildren(); - } - } - - if (discriminatorValue != null) { - readerToUse = readerToUse.reset(); - } - // Use the discriminator value to determine which subtype should be deserialized. - if ("EntityLinking".equals(discriminatorValue)) { - return AnalyzeTextEntityLinkingInput.fromJson(readerToUse); - } else if ("EntityRecognition".equals(discriminatorValue)) { - return AnalyzeTextEntityRecognitionInput.fromJson(readerToUse); - } else if ("KeyPhraseExtraction".equals(discriminatorValue)) { - return AnalyzeTextKeyPhraseExtractionInput.fromJson(readerToUse); - } else if ("PiiEntityRecognition".equals(discriminatorValue)) { - return AnalyzeTextPiiEntitiesRecognitionInput.fromJson(readerToUse); - } else if ("LanguageDetection".equals(discriminatorValue)) { - return AnalyzeTextLanguageDetectionInput.fromJson(readerToUse); - } else if ("SentimentAnalysis".equals(discriminatorValue)) { - return AnalyzeTextSentimentAnalysisInput.fromJson(readerToUse); + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; } else { - throw new IllegalStateException( - "Discriminator field 'kind' didn't match one of the expected values 'EntityLinking', 'EntityRecognition', 'KeyPhraseExtraction', 'PiiEntityRecognition', 'LanguageDetection', or 'SentimentAnalysis'. It was: '" - + discriminatorValue - + "'."); + readerToUse.skipChildren(); } - }); + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("EntityLinking".equals(discriminatorValue)) { + return AnalyzeTextEntityLinkingInput.fromJson(readerToUse.reset()); + } else if ("EntityRecognition".equals(discriminatorValue)) { + return AnalyzeTextEntityRecognitionInput.fromJson(readerToUse.reset()); + } else if ("KeyPhraseExtraction".equals(discriminatorValue)) { + return AnalyzeTextKeyPhraseExtractionInput.fromJson(readerToUse.reset()); + } else if ("PiiEntityRecognition".equals(discriminatorValue)) { + return AnalyzeTextPiiEntitiesRecognitionInput.fromJson(readerToUse.reset()); + } else if ("LanguageDetection".equals(discriminatorValue)) { + return AnalyzeTextLanguageDetectionInput.fromJson(readerToUse.reset()); + } else if ("SentimentAnalysis".equals(discriminatorValue)) { + return AnalyzeTextSentimentAnalysisInput.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + static AnalyzeTextTask fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AnalyzeTextTask deserializedAnalyzeTextTask = new AnalyzeTextTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("kind".equals(fieldName)) { + deserializedAnalyzeTextTask.kind = AnalyzeTextTaskKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedAnalyzeTextTask; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextTaskKind.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextTaskKind.java index f71f4e9ff850..6ffa2497d617 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextTaskKind.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextTaskKind.java @@ -7,37 +7,52 @@ import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; -/** Enumeration of supported Text Analysis tasks. */ +/** + * Enumeration of supported Text Analysis tasks. + */ public final class AnalyzeTextTaskKind extends ExpandableStringEnum { - /** Static value SentimentAnalysis for AnalyzeTextTaskKind. */ + /** + * Static value SentimentAnalysis for AnalyzeTextTaskKind. + */ public static final AnalyzeTextTaskKind SENTIMENT_ANALYSIS = fromString("SentimentAnalysis"); - /** Static value EntityRecognition for AnalyzeTextTaskKind. */ + /** + * Static value EntityRecognition for AnalyzeTextTaskKind. + */ public static final AnalyzeTextTaskKind ENTITY_RECOGNITION = fromString("EntityRecognition"); - /** Static value PiiEntityRecognition for AnalyzeTextTaskKind. */ + /** + * Static value PiiEntityRecognition for AnalyzeTextTaskKind. + */ public static final AnalyzeTextTaskKind PII_ENTITY_RECOGNITION = fromString("PiiEntityRecognition"); - /** Static value KeyPhraseExtraction for AnalyzeTextTaskKind. */ + /** + * Static value KeyPhraseExtraction for AnalyzeTextTaskKind. + */ public static final AnalyzeTextTaskKind KEY_PHRASE_EXTRACTION = fromString("KeyPhraseExtraction"); - /** Static value LanguageDetection for AnalyzeTextTaskKind. */ + /** + * Static value LanguageDetection for AnalyzeTextTaskKind. + */ public static final AnalyzeTextTaskKind LANGUAGE_DETECTION = fromString("LanguageDetection"); - /** Static value EntityLinking for AnalyzeTextTaskKind. */ + /** + * Static value EntityLinking for AnalyzeTextTaskKind. + */ public static final AnalyzeTextTaskKind ENTITY_LINKING = fromString("EntityLinking"); /** * Creates a new instance of AnalyzeTextTaskKind value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated - public AnalyzeTextTaskKind() {} + public AnalyzeTextTaskKind() { + } /** * Creates or finds a AnalyzeTextTaskKind from its string representation. - * + * * @param name a name to look for. * @return the corresponding AnalyzeTextTaskKind. */ @@ -47,7 +62,7 @@ public static AnalyzeTextTaskKind fromString(String name) { /** * Gets known AnalyzeTextTaskKind values. - * + * * @return known AnalyzeTextTaskKind values. */ public static Collection values() { diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextTaskResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextTaskResult.java index e53e48bf546d..fec382499466 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextTaskResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextTaskResult.java @@ -11,67 +11,100 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** The AnalyzeTextTaskResult model. */ +/** + * The AnalyzeTextTaskResult model. + */ @Immutable public class AnalyzeTextTaskResult implements JsonSerializable { - /** Creates an instance of AnalyzeTextTaskResult class. */ - public AnalyzeTextTaskResult() {} + /* + * Enumeration of supported Text Analysis task results. + */ + private AnalyzeTextTaskResultsKind kind; + + /** + * Creates an instance of AnalyzeTextTaskResult class. + */ + public AnalyzeTextTaskResult() { + this.kind = AnalyzeTextTaskResultsKind.fromString("AnalyzeTextTaskResult"); + } + /** + * Get the kind property: Enumeration of supported Text Analysis task results. + * + * @return the kind value. + */ + public AnalyzeTextTaskResultsKind getKind() { + return this.kind; + } + + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of AnalyzeTextTaskResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of AnalyzeTextTaskResult 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 the polymorphic discriminator. + * was pointing to JSON null. * @throws IOException If an error occurs while reading the AnalyzeTextTaskResult. */ public static AnalyzeTextTaskResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - String discriminatorValue = null; - JsonReader readerToUse = reader.bufferObject(); - - readerToUse.nextToken(); // Prepare for reading - while (readerToUse.nextToken() != JsonToken.END_OBJECT) { - String fieldName = readerToUse.getFieldName(); - readerToUse.nextToken(); - if ("kind".equals(fieldName)) { - discriminatorValue = readerToUse.getString(); - break; - } else { - readerToUse.skipChildren(); - } - } - - if (discriminatorValue != null) { - readerToUse = readerToUse.reset(); - } - // Use the discriminator value to determine which subtype should be deserialized. - if ("SentimentAnalysisResults".equals(discriminatorValue)) { - return SentimentTaskResult.fromJson(readerToUse); - } else if ("EntityRecognitionResults".equals(discriminatorValue)) { - return EntitiesTaskResult.fromJson(readerToUse); - } else if ("EntityLinkingResults".equals(discriminatorValue)) { - return EntityLinkingTaskResult.fromJson(readerToUse); - } else if ("PiiEntityRecognitionResults".equals(discriminatorValue)) { - return PiiTaskResult.fromJson(readerToUse); - } else if ("KeyPhraseExtractionResults".equals(discriminatorValue)) { - return KeyPhraseTaskResult.fromJson(readerToUse); - } else if ("LanguageDetectionResults".equals(discriminatorValue)) { - return LanguageDetectionTaskResult.fromJson(readerToUse); + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; } else { - throw new IllegalStateException( - "Discriminator field 'kind' didn't match one of the expected values 'SentimentAnalysisResults', 'EntityRecognitionResults', 'EntityLinkingResults', 'PiiEntityRecognitionResults', 'KeyPhraseExtractionResults', or 'LanguageDetectionResults'. It was: '" - + discriminatorValue - + "'."); + readerToUse.skipChildren(); } - }); + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("SentimentAnalysisResults".equals(discriminatorValue)) { + return SentimentTaskResult.fromJson(readerToUse.reset()); + } else if ("EntityRecognitionResults".equals(discriminatorValue)) { + return EntitiesTaskResult.fromJson(readerToUse.reset()); + } else if ("EntityLinkingResults".equals(discriminatorValue)) { + return EntityLinkingTaskResult.fromJson(readerToUse.reset()); + } else if ("PiiEntityRecognitionResults".equals(discriminatorValue)) { + return PiiTaskResult.fromJson(readerToUse.reset()); + } else if ("KeyPhraseExtractionResults".equals(discriminatorValue)) { + return KeyPhraseTaskResult.fromJson(readerToUse.reset()); + } else if ("LanguageDetectionResults".equals(discriminatorValue)) { + return LanguageDetectionTaskResult.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + static AnalyzeTextTaskResult fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AnalyzeTextTaskResult deserializedAnalyzeTextTaskResult = new AnalyzeTextTaskResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("kind".equals(fieldName)) { + deserializedAnalyzeTextTaskResult.kind = AnalyzeTextTaskResultsKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedAnalyzeTextTaskResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextTaskResultsKind.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextTaskResultsKind.java index 18eae6936dba..bfb2436d173d 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextTaskResultsKind.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextTaskResultsKind.java @@ -7,39 +7,54 @@ import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; -/** Enumeration of supported Text Analysis task results. */ +/** + * Enumeration of supported Text Analysis task results. + */ public final class AnalyzeTextTaskResultsKind extends ExpandableStringEnum { - /** Static value SentimentAnalysisResults for AnalyzeTextTaskResultsKind. */ + /** + * Static value SentimentAnalysisResults for AnalyzeTextTaskResultsKind. + */ public static final AnalyzeTextTaskResultsKind SENTIMENT_ANALYSIS_RESULTS = fromString("SentimentAnalysisResults"); - /** Static value EntityRecognitionResults for AnalyzeTextTaskResultsKind. */ + /** + * Static value EntityRecognitionResults for AnalyzeTextTaskResultsKind. + */ public static final AnalyzeTextTaskResultsKind ENTITY_RECOGNITION_RESULTS = fromString("EntityRecognitionResults"); - /** Static value PiiEntityRecognitionResults for AnalyzeTextTaskResultsKind. */ - public static final AnalyzeTextTaskResultsKind PII_ENTITY_RECOGNITION_RESULTS = - fromString("PiiEntityRecognitionResults"); + /** + * Static value PiiEntityRecognitionResults for AnalyzeTextTaskResultsKind. + */ + public static final AnalyzeTextTaskResultsKind PII_ENTITY_RECOGNITION_RESULTS + = fromString("PiiEntityRecognitionResults"); - /** Static value KeyPhraseExtractionResults for AnalyzeTextTaskResultsKind. */ - public static final AnalyzeTextTaskResultsKind KEY_PHRASE_EXTRACTION_RESULTS = - fromString("KeyPhraseExtractionResults"); + /** + * Static value KeyPhraseExtractionResults for AnalyzeTextTaskResultsKind. + */ + public static final AnalyzeTextTaskResultsKind KEY_PHRASE_EXTRACTION_RESULTS + = fromString("KeyPhraseExtractionResults"); - /** Static value LanguageDetectionResults for AnalyzeTextTaskResultsKind. */ + /** + * Static value LanguageDetectionResults for AnalyzeTextTaskResultsKind. + */ public static final AnalyzeTextTaskResultsKind LANGUAGE_DETECTION_RESULTS = fromString("LanguageDetectionResults"); - /** Static value EntityLinkingResults for AnalyzeTextTaskResultsKind. */ + /** + * Static value EntityLinkingResults for AnalyzeTextTaskResultsKind. + */ public static final AnalyzeTextTaskResultsKind ENTITY_LINKING_RESULTS = fromString("EntityLinkingResults"); /** * Creates a new instance of AnalyzeTextTaskResultsKind value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated - public AnalyzeTextTaskResultsKind() {} + public AnalyzeTextTaskResultsKind() { + } /** * Creates or finds a AnalyzeTextTaskResultsKind from its string representation. - * + * * @param name a name to look for. * @return the corresponding AnalyzeTextTaskResultsKind. */ @@ -49,7 +64,7 @@ public static AnalyzeTextTaskResultsKind fromString(String name) { /** * Gets known AnalyzeTextTaskResultsKind values. - * + * * @return known AnalyzeTextTaskResultsKind values. */ public static Collection values() { diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextsCancelJobHeaders.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextsCancelJobHeaders.java index b80004bded42..335ecd220128 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextsCancelJobHeaders.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextsCancelJobHeaders.java @@ -8,7 +8,9 @@ import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; -/** The AnalyzeTextsCancelJobHeaders model. */ +/** + * The AnalyzeTextsCancelJobHeaders model. + */ @Fluent public final class AnalyzeTextsCancelJobHeaders { /* @@ -21,7 +23,7 @@ public final class AnalyzeTextsCancelJobHeaders { // HttpHeaders containing the raw property values. /** * Creates an instance of AnalyzeTextsCancelJobHeaders class. - * + * * @param rawHeaders The raw HttpHeaders that will be used to create the property values. */ public AnalyzeTextsCancelJobHeaders(HttpHeaders rawHeaders) { @@ -30,7 +32,7 @@ public AnalyzeTextsCancelJobHeaders(HttpHeaders rawHeaders) { /** * Get the operationLocation property: The Operation-Location property. - * + * * @return the operationLocation value. */ public String getOperationLocation() { @@ -39,7 +41,7 @@ public String getOperationLocation() { /** * Set the operationLocation property: The Operation-Location property. - * + * * @param operationLocation the operationLocation value to set. * @return the AnalyzeTextsCancelJobHeaders object itself. */ diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextsSubmitJobHeaders.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextsSubmitJobHeaders.java index a40054ab288f..8b86af6c2945 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextsSubmitJobHeaders.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/AnalyzeTextsSubmitJobHeaders.java @@ -8,7 +8,9 @@ import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; -/** The AnalyzeTextsSubmitJobHeaders model. */ +/** + * The AnalyzeTextsSubmitJobHeaders model. + */ @Fluent public final class AnalyzeTextsSubmitJobHeaders { /* @@ -21,7 +23,7 @@ public final class AnalyzeTextsSubmitJobHeaders { // HttpHeaders containing the raw property values. /** * Creates an instance of AnalyzeTextsSubmitJobHeaders class. - * + * * @param rawHeaders The raw HttpHeaders that will be used to create the property values. */ public AnalyzeTextsSubmitJobHeaders(HttpHeaders rawHeaders) { @@ -30,7 +32,7 @@ public AnalyzeTextsSubmitJobHeaders(HttpHeaders rawHeaders) { /** * Get the operationLocation property: The Operation-Location property. - * + * * @return the operationLocation value. */ public String getOperationLocation() { @@ -39,7 +41,7 @@ public String getOperationLocation() { /** * Set the operationLocation property: The Operation-Location property. - * + * * @param operationLocation the operationLocation value to set. * @return the AnalyzeTextsSubmitJobHeaders object itself. */ diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Association.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Association.java index e5e4b03b6d2b..73454c37f7b4 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Association.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Association.java @@ -4,15 +4,23 @@ package com.azure.ai.textanalytics.implementation.models; -/** Describes if the entity is the subject of the text or if it describes someone else. */ +/** + * Describes if the entity is the subject of the text or if it describes someone else. + */ public enum Association { - /** Enum value subject. */ + /** + * Enum value subject. + */ SUBJECT("subject"), - /** Enum value other. */ + /** + * Enum value other. + */ OTHER("other"); - /** The actual serialized value for a Association instance. */ + /** + * The actual serialized value for a Association instance. + */ private final String value; Association(String value) { @@ -21,7 +29,7 @@ public enum Association { /** * Parses a serialized value to a Association instance. - * + * * @param value the serialized value to parse. * @return the parsed Association object, or null if unable to parse. */ @@ -38,7 +46,9 @@ public static Association fromString(String value) { return null; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public String toString() { return this.value; diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CancelHealthJobHeaders.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CancelHealthJobHeaders.java index 8c0124fe6bd1..8ee0facf272d 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CancelHealthJobHeaders.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CancelHealthJobHeaders.java @@ -1,19 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 CancelHealthJobHeaders model. */ @Fluent -public final class CancelHealthJobHeaders { +public final class CancelHealthJobHeaders implements JsonSerializable { /* * The Operation-Location property. */ - @JsonProperty(value = "Operation-Location") private String operationLocation; /** @@ -35,4 +38,39 @@ public CancelHealthJobHeaders setOperationLocation(String operationLocation) { this.operationLocation = operationLocation; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("Operation-Location", this.operationLocation); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CancelHealthJobHeaders from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CancelHealthJobHeaders 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 CancelHealthJobHeaders. + */ + public static CancelHealthJobHeaders fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CancelHealthJobHeaders deserializedCancelHealthJobHeaders = new CancelHealthJobHeaders(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("Operation-Location".equals(fieldName)) { + deserializedCancelHealthJobHeaders.operationLocation = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedCancelHealthJobHeaders; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Certainty.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Certainty.java index 9ea2904a233d..93b6319cd894 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Certainty.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Certainty.java @@ -4,24 +4,38 @@ package com.azure.ai.textanalytics.implementation.models; -/** Describes the entities certainty and polarity. */ +/** + * Describes the entities certainty and polarity. + */ public enum Certainty { - /** Enum value positive. */ + /** + * Enum value positive. + */ POSITIVE("positive"), - /** Enum value positivePossible. */ + /** + * Enum value positivePossible. + */ POSITIVE_POSSIBLE("positivePossible"), - /** Enum value neutralPossible. */ + /** + * Enum value neutralPossible. + */ NEUTRAL_POSSIBLE("neutralPossible"), - /** Enum value negativePossible. */ + /** + * Enum value negativePossible. + */ NEGATIVE_POSSIBLE("negativePossible"), - /** Enum value negative. */ + /** + * Enum value negative. + */ NEGATIVE("negative"); - /** The actual serialized value for a Certainty instance. */ + /** + * The actual serialized value for a Certainty instance. + */ private final String value; Certainty(String value) { @@ -30,7 +44,7 @@ public enum Certainty { /** * Parses a serialized value to a Certainty instance. - * + * * @param value the serialized value to parse. * @return the parsed Certainty object, or null if unable to parse. */ @@ -47,7 +61,9 @@ public static Certainty fromString(String value) { return null; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public String toString() { return this.value; diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ClassificationDocumentResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ClassificationDocumentResult.java index d4d52d31f78d..9a152940657b 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ClassificationDocumentResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ClassificationDocumentResult.java @@ -11,7 +11,9 @@ import java.io.IOException; import java.util.List; -/** The ClassificationDocumentResult model. */ +/** + * The ClassificationDocumentResult model. + */ @Fluent public class ClassificationDocumentResult extends DocumentResult { /* @@ -19,12 +21,15 @@ public class ClassificationDocumentResult extends DocumentResult { */ private List classProperty; - /** Creates an instance of ClassificationDocumentResult class. */ - public ClassificationDocumentResult() {} + /** + * Creates an instance of ClassificationDocumentResult class. + */ + public ClassificationDocumentResult() { + } /** * Get the classProperty property: The class property. - * + * * @return the classProperty value. */ public List getClassProperty() { @@ -33,7 +38,7 @@ public List getClassProperty() { /** * Set the classProperty property: The class property. - * + * * @param classProperty the classProperty value to set. * @return the ClassificationDocumentResult object itself. */ @@ -42,27 +47,36 @@ public ClassificationDocumentResult setClassProperty(List return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public ClassificationDocumentResult setId(String id) { super.setId(id); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public ClassificationDocumentResult setWarnings(List warnings) { super.setWarnings(warnings); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public ClassificationDocumentResult setStatistics(DocumentStatistics statistics) { super.setStatistics(statistics); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -75,40 +89,37 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of ClassificationDocumentResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of ClassificationDocumentResult if the JsonReader was pointing to an instance of it, or null - * if it was pointing to JSON 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 ClassificationDocumentResult. */ public static ClassificationDocumentResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - ClassificationDocumentResult deserializedClassificationDocumentResult = - new ClassificationDocumentResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + ClassificationDocumentResult deserializedClassificationDocumentResult = new ClassificationDocumentResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("id".equals(fieldName)) { - deserializedClassificationDocumentResult.setId(reader.getString()); - } else if ("warnings".equals(fieldName)) { - List warnings = - reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); - deserializedClassificationDocumentResult.setWarnings(warnings); - } else if ("statistics".equals(fieldName)) { - deserializedClassificationDocumentResult.setStatistics(DocumentStatistics.fromJson(reader)); - } else if ("class".equals(fieldName)) { - List classProperty = - reader.readArray(reader1 -> ClassificationResult.fromJson(reader1)); - deserializedClassificationDocumentResult.classProperty = classProperty; - } else { - reader.skipChildren(); - } - } + if ("id".equals(fieldName)) { + deserializedClassificationDocumentResult.setId(reader.getString()); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedClassificationDocumentResult.setWarnings(warnings); + } else if ("statistics".equals(fieldName)) { + deserializedClassificationDocumentResult.setStatistics(DocumentStatistics.fromJson(reader)); + } else if ("class".equals(fieldName)) { + List classProperty + = reader.readArray(reader1 -> ClassificationResult.fromJson(reader1)); + deserializedClassificationDocumentResult.classProperty = classProperty; + } else { + reader.skipChildren(); + } + } - return deserializedClassificationDocumentResult; - }); + return deserializedClassificationDocumentResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ClassificationResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ClassificationResult.java index a8cd8a9d586e..16436ded95af 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ClassificationResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ClassificationResult.java @@ -11,7 +11,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** The ClassificationResult model. */ +/** + * The ClassificationResult model. + */ @Fluent public final class ClassificationResult implements JsonSerializable { /* @@ -24,12 +26,15 @@ public final class ClassificationResult implements JsonSerializable { - ClassificationResult deserializedClassificationResult = new ClassificationResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + ClassificationResult deserializedClassificationResult = new ClassificationResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("category".equals(fieldName)) { - deserializedClassificationResult.category = reader.getString(); - } else if ("confidenceScore".equals(fieldName)) { - deserializedClassificationResult.confidenceScore = reader.getDouble(); - } else { - reader.skipChildren(); - } - } + if ("category".equals(fieldName)) { + deserializedClassificationResult.category = reader.getString(); + } else if ("confidenceScore".equals(fieldName)) { + deserializedClassificationResult.confidenceScore = reader.getDouble(); + } else { + reader.skipChildren(); + } + } - return deserializedClassificationResult; - }); + return deserializedClassificationResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Conditionality.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Conditionality.java index 35672348e945..b46c91c3f76c 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Conditionality.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Conditionality.java @@ -4,15 +4,23 @@ package com.azure.ai.textanalytics.implementation.models; -/** Describes any conditionality on the entity. */ +/** + * Describes any conditionality on the entity. + */ public enum Conditionality { - /** Enum value hypothetical. */ + /** + * Enum value hypothetical. + */ HYPOTHETICAL("hypothetical"), - /** Enum value conditional. */ + /** + * Enum value conditional. + */ CONDITIONAL("conditional"); - /** The actual serialized value for a Conditionality instance. */ + /** + * The actual serialized value for a Conditionality instance. + */ private final String value; Conditionality(String value) { @@ -21,7 +29,7 @@ public enum Conditionality { /** * Parses a serialized value to a Conditionality instance. - * + * * @param value the serialized value to parse. * @return the parsed Conditionality object, or null if unable to parse. */ @@ -38,7 +46,9 @@ public static Conditionality fromString(String value) { return null; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public String toString() { return this.value; diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntitiesLROTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntitiesLROTask.java index 2b36979782ff..7c111a90a1d2 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntitiesLROTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntitiesLROTask.java @@ -9,7 +9,6 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; /** * Use custom models to ease the process of information extraction from unstructured documents like contracts or @@ -17,17 +16,35 @@ */ @Fluent public final class CustomEntitiesLROTask extends AnalyzeTextLROTask { + /* + * Enumeration of supported long-running Text Analysis tasks. + */ + private AnalyzeTextLROTaskKind kind = AnalyzeTextLROTaskKind.CUSTOM_ENTITY_RECOGNITION; + /* * Supported parameters for a Custom Entities task. */ private CustomEntitiesTaskParameters parameters; - /** Creates an instance of CustomEntitiesLROTask class. */ - public CustomEntitiesLROTask() {} + /** + * Creates an instance of CustomEntitiesLROTask class. + */ + public CustomEntitiesLROTask() { + } + + /** + * Get the kind property: Enumeration of supported long-running Text Analysis tasks. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROTaskKind getKind() { + return this.kind; + } /** * Get the parameters property: Supported parameters for a Custom Entities task. - * + * * @return the parameters value. */ public CustomEntitiesTaskParameters getParameters() { @@ -36,7 +53,7 @@ public CustomEntitiesTaskParameters getParameters() { /** * Set the parameters property: Supported parameters for a Custom Entities task. - * + * * @param parameters the parameters value to set. * @return the CustomEntitiesLROTask object itself. */ @@ -45,58 +62,54 @@ public CustomEntitiesLROTask setParameters(CustomEntitiesTaskParameters paramete return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomEntitiesLROTask setTaskName(String taskName) { super.setTaskName(taskName); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("kind", Objects.toString(AnalyzeTextLROTaskKind.CUSTOM_ENTITY_RECOGNITION, null)); jsonWriter.writeStringField("taskName", getTaskName()); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); jsonWriter.writeJsonField("parameters", this.parameters); return jsonWriter.writeEndObject(); } /** * Reads an instance of CustomEntitiesLROTask from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of CustomEntitiesLROTask 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 the polymorphic discriminator. + * was pointing to JSON null. * @throws IOException If an error occurs while reading the CustomEntitiesLROTask. */ public static CustomEntitiesLROTask fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - CustomEntitiesLROTask deserializedCustomEntitiesLROTask = new CustomEntitiesLROTask(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + CustomEntitiesLROTask deserializedCustomEntitiesLROTask = new CustomEntitiesLROTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"CustomEntityRecognition".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'CustomEntityRecognition'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("taskName".equals(fieldName)) { - deserializedCustomEntitiesLROTask.setTaskName(reader.getString()); - } else if ("parameters".equals(fieldName)) { - deserializedCustomEntitiesLROTask.parameters = - CustomEntitiesTaskParameters.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("taskName".equals(fieldName)) { + deserializedCustomEntitiesLROTask.setTaskName(reader.getString()); + } else if ("kind".equals(fieldName)) { + deserializedCustomEntitiesLROTask.kind = AnalyzeTextLROTaskKind.fromString(reader.getString()); + } else if ("parameters".equals(fieldName)) { + deserializedCustomEntitiesLROTask.parameters = CustomEntitiesTaskParameters.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedCustomEntitiesLROTask; - }); + return deserializedCustomEntitiesLROTask; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntitiesResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntitiesResult.java index 56e89af5acea..49d1761448c2 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntitiesResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntitiesResult.java @@ -11,7 +11,9 @@ import java.io.IOException; import java.util.List; -/** The CustomEntitiesResult model. */ +/** + * The CustomEntitiesResult model. + */ @Fluent public final class CustomEntitiesResult extends CustomResult { /* @@ -19,12 +21,15 @@ public final class CustomEntitiesResult extends CustomResult { */ private List documents; - /** Creates an instance of CustomEntitiesResult class. */ - public CustomEntitiesResult() {} + /** + * Creates an instance of CustomEntitiesResult class. + */ + public CustomEntitiesResult() { + } /** * Get the documents property: Response by document. - * + * * @return the documents value. */ public List getDocuments() { @@ -33,7 +38,7 @@ public List getDocuments() { /** * Set the documents property: Response by document. - * + * * @param documents the documents value to set. * @return the CustomEntitiesResult object itself. */ @@ -42,34 +47,45 @@ public CustomEntitiesResult setDocuments(List return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomEntitiesResult setErrors(List errors) { super.setErrors(errors); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomEntitiesResult setStatistics(RequestStatistics statistics) { super.setStatistics(statistics); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomEntitiesResult setProjectName(String projectName) { super.setProjectName(projectName); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomEntitiesResult setDeploymentName(String deploymentName) { super.setDeploymentName(deploymentName); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -83,40 +99,39 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of CustomEntitiesResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of CustomEntitiesResult if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. + * 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 CustomEntitiesResult. */ public static CustomEntitiesResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - CustomEntitiesResult deserializedCustomEntitiesResult = new CustomEntitiesResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + CustomEntitiesResult deserializedCustomEntitiesResult = new CustomEntitiesResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("errors".equals(fieldName)) { - List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); - deserializedCustomEntitiesResult.setErrors(errors); - } else if ("projectName".equals(fieldName)) { - deserializedCustomEntitiesResult.setProjectName(reader.getString()); - } else if ("deploymentName".equals(fieldName)) { - deserializedCustomEntitiesResult.setDeploymentName(reader.getString()); - } else if ("statistics".equals(fieldName)) { - deserializedCustomEntitiesResult.setStatistics(RequestStatistics.fromJson(reader)); - } else if ("documents".equals(fieldName)) { - List documents = - reader.readArray(reader1 -> CustomEntitiesResultDocumentsItem.fromJson(reader1)); - deserializedCustomEntitiesResult.documents = documents; - } else { - reader.skipChildren(); - } - } + if ("errors".equals(fieldName)) { + List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); + deserializedCustomEntitiesResult.setErrors(errors); + } else if ("projectName".equals(fieldName)) { + deserializedCustomEntitiesResult.setProjectName(reader.getString()); + } else if ("deploymentName".equals(fieldName)) { + deserializedCustomEntitiesResult.setDeploymentName(reader.getString()); + } else if ("statistics".equals(fieldName)) { + deserializedCustomEntitiesResult.setStatistics(RequestStatistics.fromJson(reader)); + } else if ("documents".equals(fieldName)) { + List documents + = reader.readArray(reader1 -> CustomEntitiesResultDocumentsItem.fromJson(reader1)); + deserializedCustomEntitiesResult.documents = documents; + } else { + reader.skipChildren(); + } + } - return deserializedCustomEntitiesResult; - }); + return deserializedCustomEntitiesResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntitiesResultDocumentsItem.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntitiesResultDocumentsItem.java index 700c506d6278..219cccdd7f9e 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntitiesResultDocumentsItem.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntitiesResultDocumentsItem.java @@ -11,40 +11,56 @@ import java.io.IOException; import java.util.List; -/** The CustomEntitiesResultDocumentsItem model. */ +/** + * The CustomEntitiesResultDocumentsItem model. + */ @Fluent public final class CustomEntitiesResultDocumentsItem extends EntitiesDocumentResult { - /** Creates an instance of CustomEntitiesResultDocumentsItem class. */ - public CustomEntitiesResultDocumentsItem() {} + /** + * Creates an instance of CustomEntitiesResultDocumentsItem class. + */ + public CustomEntitiesResultDocumentsItem() { + } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomEntitiesResultDocumentsItem setEntities(List entities) { super.setEntities(entities); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomEntitiesResultDocumentsItem setId(String id) { super.setId(id); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomEntitiesResultDocumentsItem setWarnings(List warnings) { super.setWarnings(warnings); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomEntitiesResultDocumentsItem setStatistics(DocumentStatistics statistics) { super.setStatistics(statistics); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -57,40 +73,37 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of CustomEntitiesResultDocumentsItem from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of CustomEntitiesResultDocumentsItem if the JsonReader was pointing to an instance of it, or - * null if it was pointing to JSON null. + * 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 CustomEntitiesResultDocumentsItem. */ public static CustomEntitiesResultDocumentsItem fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - CustomEntitiesResultDocumentsItem deserializedCustomEntitiesResultDocumentsItem = - new CustomEntitiesResultDocumentsItem(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + CustomEntitiesResultDocumentsItem deserializedCustomEntitiesResultDocumentsItem + = new CustomEntitiesResultDocumentsItem(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("id".equals(fieldName)) { - deserializedCustomEntitiesResultDocumentsItem.setId(reader.getString()); - } else if ("warnings".equals(fieldName)) { - List warnings = - reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); - deserializedCustomEntitiesResultDocumentsItem.setWarnings(warnings); - } else if ("entities".equals(fieldName)) { - List entities = reader.readArray(reader1 -> Entity.fromJson(reader1)); - deserializedCustomEntitiesResultDocumentsItem.setEntities(entities); - } else if ("statistics".equals(fieldName)) { - deserializedCustomEntitiesResultDocumentsItem.setStatistics( - DocumentStatistics.fromJson(reader)); - } else { - reader.skipChildren(); - } - } + if ("id".equals(fieldName)) { + deserializedCustomEntitiesResultDocumentsItem.setId(reader.getString()); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedCustomEntitiesResultDocumentsItem.setWarnings(warnings); + } else if ("entities".equals(fieldName)) { + List entities = reader.readArray(reader1 -> Entity.fromJson(reader1)); + deserializedCustomEntitiesResultDocumentsItem.setEntities(entities); + } else if ("statistics".equals(fieldName)) { + deserializedCustomEntitiesResultDocumentsItem.setStatistics(DocumentStatistics.fromJson(reader)); + } else { + reader.skipChildren(); + } + } - return deserializedCustomEntitiesResultDocumentsItem; - }); + return deserializedCustomEntitiesResultDocumentsItem; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntitiesTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntitiesTask.java index 9c79307cab56..205e68f3e441 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntitiesTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntitiesTask.java @@ -1,25 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 CustomEntitiesTask model. */ @Fluent -public final class CustomEntitiesTask { +public final class CustomEntitiesTask implements JsonSerializable { /* * The parameters property. */ - @JsonProperty(value = "parameters") private CustomEntitiesTaskParameters parameters; /* * The taskName property. */ - @JsonProperty(value = "taskName") private String taskName; /** @@ -61,4 +63,44 @@ public CustomEntitiesTask setTaskName(String taskName) { this.taskName = taskName; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("parameters", parameters); + jsonWriter.writeStringField("taskName", this.taskName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CustomEntitiesTask from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CustomEntitiesTask 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 CustomEntitiesTask. + */ + public static CustomEntitiesTask fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CustomEntitiesTask deserializedCustomEntitiesTask = new CustomEntitiesTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("parameters".equals(fieldName)) { + deserializedCustomEntitiesTask.parameters = CustomEntitiesTaskParameters.fromJson(reader); + } else if ("taskName".equals(fieldName)) { + deserializedCustomEntitiesTask.taskName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedCustomEntitiesTask; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntitiesTaskParameters.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntitiesTaskParameters.java index 31e667d8d559..0070ac262e95 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntitiesTaskParameters.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntitiesTaskParameters.java @@ -9,25 +9,28 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** Supported parameters for a Custom Entities task. */ +/** + * Supported parameters for a Custom Entities task. + */ @Fluent public final class CustomEntitiesTaskParameters extends CustomTaskParameters { /* - * Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to - * Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. + * Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. */ private StringIndexType stringIndexType; - /** Creates an instance of CustomEntitiesTaskParameters class. */ - public CustomEntitiesTaskParameters() {} + /** + * Creates an instance of CustomEntitiesTaskParameters class. + */ + public CustomEntitiesTaskParameters() { + } /** * Get the stringIndexType property: Specifies the method used to interpret string offsets. Defaults to Text * Elements (Graphemes) according to Unicode v8.0.0. For additional information see * https://aka.ms/text-analytics-offsets. - * + * * @return the stringIndexType value. */ public StringIndexType getStringIndexType() { @@ -38,7 +41,7 @@ public StringIndexType getStringIndexType() { * Set the stringIndexType property: Specifies the method used to interpret string offsets. Defaults to Text * Elements (Graphemes) according to Unicode v8.0.0. For additional information see * https://aka.ms/text-analytics-offsets. - * + * * @param stringIndexType the stringIndexType value to set. * @return the CustomEntitiesTaskParameters object itself. */ @@ -47,71 +50,79 @@ public CustomEntitiesTaskParameters setStringIndexType(StringIndexType stringInd return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomEntitiesTaskParameters setProjectName(String projectName) { super.setProjectName(projectName); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomEntitiesTaskParameters setDeploymentName(String deploymentName) { super.setDeploymentName(deploymentName); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomEntitiesTaskParameters setLoggingOptOut(Boolean loggingOptOut) { super.setLoggingOptOut(loggingOptOut); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); jsonWriter.writeStringField("projectName", getProjectName()); jsonWriter.writeStringField("deploymentName", getDeploymentName()); jsonWriter.writeBooleanField("loggingOptOut", isLoggingOptOut()); - jsonWriter.writeStringField("stringIndexType", Objects.toString(this.stringIndexType, null)); + jsonWriter.writeStringField("stringIndexType", + this.stringIndexType == null ? null : this.stringIndexType.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of CustomEntitiesTaskParameters from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of CustomEntitiesTaskParameters if the JsonReader was pointing to an instance of it, or null - * if it was pointing to JSON 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 CustomEntitiesTaskParameters. */ public static CustomEntitiesTaskParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - CustomEntitiesTaskParameters deserializedCustomEntitiesTaskParameters = - new CustomEntitiesTaskParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + CustomEntitiesTaskParameters deserializedCustomEntitiesTaskParameters = new CustomEntitiesTaskParameters(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("projectName".equals(fieldName)) { - deserializedCustomEntitiesTaskParameters.setProjectName(reader.getString()); - } else if ("deploymentName".equals(fieldName)) { - deserializedCustomEntitiesTaskParameters.setDeploymentName(reader.getString()); - } else if ("loggingOptOut".equals(fieldName)) { - deserializedCustomEntitiesTaskParameters.setLoggingOptOut( - reader.getNullable(JsonReader::getBoolean)); - } else if ("stringIndexType".equals(fieldName)) { - deserializedCustomEntitiesTaskParameters.stringIndexType = - StringIndexType.fromString(reader.getString()); - } else { - reader.skipChildren(); - } - } + if ("projectName".equals(fieldName)) { + deserializedCustomEntitiesTaskParameters.setProjectName(reader.getString()); + } else if ("deploymentName".equals(fieldName)) { + deserializedCustomEntitiesTaskParameters.setDeploymentName(reader.getString()); + } else if ("loggingOptOut".equals(fieldName)) { + deserializedCustomEntitiesTaskParameters + .setLoggingOptOut(reader.getNullable(JsonReader::getBoolean)); + } else if ("stringIndexType".equals(fieldName)) { + deserializedCustomEntitiesTaskParameters.stringIndexType + = StringIndexType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedCustomEntitiesTaskParameters; - }); + return deserializedCustomEntitiesTaskParameters; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntityRecognitionLROResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntityRecognitionLROResult.java index 995645d4c90b..ace20b507fce 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntityRecognitionLROResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomEntityRecognitionLROResult.java @@ -10,22 +10,42 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.time.OffsetDateTime; -import java.util.Objects; +import java.time.format.DateTimeFormatter; -/** The CustomEntityRecognitionLROResult model. */ +/** + * The CustomEntityRecognitionLROResult model. + */ @Fluent public final class CustomEntityRecognitionLROResult extends AnalyzeTextLROResult { + /* + * Enumeration of supported Text Analysis long-running operation task results. + */ + private AnalyzeTextLROResultsKind kind = AnalyzeTextLROResultsKind.CUSTOM_ENTITY_RECOGNITION_LRORESULTS; + /* * The results property. */ private CustomEntitiesResult results; - /** Creates an instance of CustomEntityRecognitionLROResult class. */ - public CustomEntityRecognitionLROResult() {} + /** + * Creates an instance of CustomEntityRecognitionLROResult class. + */ + public CustomEntityRecognitionLROResult() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis long-running operation task results. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROResultsKind getKind() { + return this.kind; + } /** * Get the results property: The results property. - * + * * @return the results value. */ public CustomEntitiesResult getResults() { @@ -34,7 +54,7 @@ public CustomEntitiesResult getResults() { /** * Set the results property: The results property. - * + * * @param results the results value to set. * @return the CustomEntityRecognitionLROResult object itself. */ @@ -43,84 +63,85 @@ public CustomEntityRecognitionLROResult setResults(CustomEntitiesResult results) return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomEntityRecognitionLROResult setTaskName(String taskName) { super.setTaskName(taskName); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomEntityRecognitionLROResult setLastUpdateDateTime(OffsetDateTime lastUpdateDateTime) { super.setLastUpdateDateTime(lastUpdateDateTime); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomEntityRecognitionLROResult setStatus(State status) { super.setStatus(status); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField( - "kind", Objects.toString(AnalyzeTextLROResultsKind.CUSTOM_ENTITY_RECOGNITION_LRORESULTS, null)); - jsonWriter.writeStringField("lastUpdateDateTime", Objects.toString(getLastUpdateDateTime(), null)); - jsonWriter.writeStringField("status", Objects.toString(getStatus(), null)); + jsonWriter.writeStringField("lastUpdateDateTime", + getLastUpdateDateTime() == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(getLastUpdateDateTime())); + jsonWriter.writeStringField("status", getStatus() == null ? null : getStatus().toString()); jsonWriter.writeStringField("taskName", getTaskName()); jsonWriter.writeJsonField("results", this.results); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of CustomEntityRecognitionLROResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of CustomEntityRecognitionLROResult 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 or the - * polymorphic discriminator. + * 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 CustomEntityRecognitionLROResult. */ public static CustomEntityRecognitionLROResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - CustomEntityRecognitionLROResult deserializedCustomEntityRecognitionLROResult = - new CustomEntityRecognitionLROResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + CustomEntityRecognitionLROResult deserializedCustomEntityRecognitionLROResult + = new CustomEntityRecognitionLROResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"CustomEntityRecognitionLROResults".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'CustomEntityRecognitionLROResults'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("lastUpdateDateTime".equals(fieldName)) { - deserializedCustomEntityRecognitionLROResult.setLastUpdateDateTime( - reader.getNullable( - nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); - } else if ("status".equals(fieldName)) { - deserializedCustomEntityRecognitionLROResult.setStatus( - State.fromString(reader.getString())); - } else if ("taskName".equals(fieldName)) { - deserializedCustomEntityRecognitionLROResult.setTaskName(reader.getString()); - } else if ("results".equals(fieldName)) { - deserializedCustomEntityRecognitionLROResult.results = - CustomEntitiesResult.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("lastUpdateDateTime".equals(fieldName)) { + deserializedCustomEntityRecognitionLROResult.setLastUpdateDateTime( + reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); + } else if ("status".equals(fieldName)) { + deserializedCustomEntityRecognitionLROResult.setStatus(State.fromString(reader.getString())); + } else if ("taskName".equals(fieldName)) { + deserializedCustomEntityRecognitionLROResult.setTaskName(reader.getString()); + } else if ("results".equals(fieldName)) { + deserializedCustomEntityRecognitionLROResult.results = CustomEntitiesResult.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedCustomEntityRecognitionLROResult.kind + = AnalyzeTextLROResultsKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedCustomEntityRecognitionLROResult; - }); + return deserializedCustomEntityRecognitionLROResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomLabelClassificationResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomLabelClassificationResult.java index 84869cf681c5..00c178f7b14b 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomLabelClassificationResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomLabelClassificationResult.java @@ -11,7 +11,9 @@ import java.io.IOException; import java.util.List; -/** The CustomLabelClassificationResult model. */ +/** + * The CustomLabelClassificationResult model. + */ @Fluent public final class CustomLabelClassificationResult extends CustomResult { /* @@ -19,12 +21,15 @@ public final class CustomLabelClassificationResult extends CustomResult { */ private List documents; - /** Creates an instance of CustomLabelClassificationResult class. */ - public CustomLabelClassificationResult() {} + /** + * Creates an instance of CustomLabelClassificationResult class. + */ + public CustomLabelClassificationResult() { + } /** * Get the documents property: Response by document. - * + * * @return the documents value. */ public List getDocuments() { @@ -33,7 +38,7 @@ public List getDocuments() { /** * Set the documents property: Response by document. - * + * * @param documents the documents value to set. * @return the CustomLabelClassificationResult object itself. */ @@ -42,34 +47,45 @@ public CustomLabelClassificationResult setDocuments(List errors) { super.setErrors(errors); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomLabelClassificationResult setStatistics(RequestStatistics statistics) { super.setStatistics(statistics); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomLabelClassificationResult setProjectName(String projectName) { super.setProjectName(projectName); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomLabelClassificationResult setDeploymentName(String deploymentName) { super.setDeploymentName(deploymentName); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -83,43 +99,40 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of CustomLabelClassificationResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of CustomLabelClassificationResult if the JsonReader was pointing to an instance of it, or - * null if it was pointing to JSON null. + * 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 CustomLabelClassificationResult. */ public static CustomLabelClassificationResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - CustomLabelClassificationResult deserializedCustomLabelClassificationResult = - new CustomLabelClassificationResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + CustomLabelClassificationResult deserializedCustomLabelClassificationResult + = new CustomLabelClassificationResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("errors".equals(fieldName)) { - List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); - deserializedCustomLabelClassificationResult.setErrors(errors); - } else if ("projectName".equals(fieldName)) { - deserializedCustomLabelClassificationResult.setProjectName(reader.getString()); - } else if ("deploymentName".equals(fieldName)) { - deserializedCustomLabelClassificationResult.setDeploymentName(reader.getString()); - } else if ("statistics".equals(fieldName)) { - deserializedCustomLabelClassificationResult.setStatistics( - RequestStatistics.fromJson(reader)); - } else if ("documents".equals(fieldName)) { - List documents = - reader.readArray( - reader1 -> CustomLabelClassificationResultDocumentsItem.fromJson(reader1)); - deserializedCustomLabelClassificationResult.documents = documents; - } else { - reader.skipChildren(); - } - } + if ("errors".equals(fieldName)) { + List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); + deserializedCustomLabelClassificationResult.setErrors(errors); + } else if ("projectName".equals(fieldName)) { + deserializedCustomLabelClassificationResult.setProjectName(reader.getString()); + } else if ("deploymentName".equals(fieldName)) { + deserializedCustomLabelClassificationResult.setDeploymentName(reader.getString()); + } else if ("statistics".equals(fieldName)) { + deserializedCustomLabelClassificationResult.setStatistics(RequestStatistics.fromJson(reader)); + } else if ("documents".equals(fieldName)) { + List documents + = reader.readArray(reader1 -> CustomLabelClassificationResultDocumentsItem.fromJson(reader1)); + deserializedCustomLabelClassificationResult.documents = documents; + } else { + reader.skipChildren(); + } + } - return deserializedCustomLabelClassificationResult; - }); + return deserializedCustomLabelClassificationResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomLabelClassificationResultDocumentsItem.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomLabelClassificationResultDocumentsItem.java index b26a83fa2f23..6f581cfa9761 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomLabelClassificationResultDocumentsItem.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomLabelClassificationResultDocumentsItem.java @@ -11,40 +11,56 @@ import java.io.IOException; import java.util.List; -/** The CustomLabelClassificationResultDocumentsItem model. */ +/** + * The CustomLabelClassificationResultDocumentsItem model. + */ @Fluent public final class CustomLabelClassificationResultDocumentsItem extends ClassificationDocumentResult { - /** Creates an instance of CustomLabelClassificationResultDocumentsItem class. */ - public CustomLabelClassificationResultDocumentsItem() {} + /** + * Creates an instance of CustomLabelClassificationResultDocumentsItem class. + */ + public CustomLabelClassificationResultDocumentsItem() { + } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomLabelClassificationResultDocumentsItem setClassProperty(List classProperty) { super.setClassProperty(classProperty); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomLabelClassificationResultDocumentsItem setId(String id) { super.setId(id); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomLabelClassificationResultDocumentsItem setWarnings(List warnings) { super.setWarnings(warnings); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomLabelClassificationResultDocumentsItem setStatistics(DocumentStatistics statistics) { super.setStatistics(statistics); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -57,42 +73,39 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of CustomLabelClassificationResultDocumentsItem from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of CustomLabelClassificationResultDocumentsItem if the JsonReader was pointing to an instance - * of it, or null if it was pointing to JSON null. + * 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 CustomLabelClassificationResultDocumentsItem. */ public static CustomLabelClassificationResultDocumentsItem fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - CustomLabelClassificationResultDocumentsItem - deserializedCustomLabelClassificationResultDocumentsItem = - new CustomLabelClassificationResultDocumentsItem(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + CustomLabelClassificationResultDocumentsItem deserializedCustomLabelClassificationResultDocumentsItem + = new CustomLabelClassificationResultDocumentsItem(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("id".equals(fieldName)) { - deserializedCustomLabelClassificationResultDocumentsItem.setId(reader.getString()); - } else if ("warnings".equals(fieldName)) { - List warnings = - reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); - deserializedCustomLabelClassificationResultDocumentsItem.setWarnings(warnings); - } else if ("class".equals(fieldName)) { - List classProperty = - reader.readArray(reader1 -> ClassificationResult.fromJson(reader1)); - deserializedCustomLabelClassificationResultDocumentsItem.setClassProperty(classProperty); - } else if ("statistics".equals(fieldName)) { - deserializedCustomLabelClassificationResultDocumentsItem.setStatistics( - DocumentStatistics.fromJson(reader)); - } else { - reader.skipChildren(); - } - } + if ("id".equals(fieldName)) { + deserializedCustomLabelClassificationResultDocumentsItem.setId(reader.getString()); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedCustomLabelClassificationResultDocumentsItem.setWarnings(warnings); + } else if ("class".equals(fieldName)) { + List classProperty + = reader.readArray(reader1 -> ClassificationResult.fromJson(reader1)); + deserializedCustomLabelClassificationResultDocumentsItem.setClassProperty(classProperty); + } else if ("statistics".equals(fieldName)) { + deserializedCustomLabelClassificationResultDocumentsItem + .setStatistics(DocumentStatistics.fromJson(reader)); + } else { + reader.skipChildren(); + } + } - return deserializedCustomLabelClassificationResultDocumentsItem; - }); + return deserializedCustomLabelClassificationResultDocumentsItem; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomMultiClassificationResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomMultiClassificationResult.java index afefc364989d..edc8135f30ef 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomMultiClassificationResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomMultiClassificationResult.java @@ -1,45 +1,44 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 CustomMultiClassificationResult model. */ @Fluent -public final class CustomMultiClassificationResult { +public final class CustomMultiClassificationResult implements JsonSerializable { /* * Response by document */ - @JsonProperty(value = "documents", required = true) private List documents; /* * Errors by document id. */ - @JsonProperty(value = "errors", required = true) private List errors; /* * if showStats=true was specified in the request this field will contain * information about the request payload. */ - @JsonProperty(value = "statistics") private RequestStatistics statistics; /* * This field indicates the project name for the model. */ - @JsonProperty(value = "projectName", required = true) private String projectName; /* * This field indicates the deployment name for the model. */ - @JsonProperty(value = "deploymentName", required = true) private String deploymentName; /** @@ -143,4 +142,55 @@ public CustomMultiClassificationResult setDeploymentName(String deploymentName) this.deploymentName = deploymentName; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("documents", this.documents, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("errors", this.errors, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("statistics", this.statistics); + jsonWriter.writeStringField("projectName", this.projectName); + jsonWriter.writeStringField("deploymentName", this.deploymentName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CustomMultiClassificationResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CustomMultiClassificationResult 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 CustomMultiClassificationResult. + */ + public static CustomMultiClassificationResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CustomMultiClassificationResult deserializedCustomMultiClassificationResult = new CustomMultiClassificationResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("documents".equals(fieldName)) { + deserializedCustomMultiClassificationResult.documents + = reader.readArray(reader1 -> MultiClassificationDocument.fromJson(reader1)); + } else if ("errors".equals(fieldName)) { + deserializedCustomMultiClassificationResult.errors + = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); + } else if ("statistics".equals(fieldName)) { + deserializedCustomMultiClassificationResult.statistics = RequestStatistics.fromJson(reader); + } else if ("projectName".equals(fieldName)) { + deserializedCustomMultiClassificationResult.projectName = reader.getString(); + } else if ("deploymentName".equals(fieldName)) { + deserializedCustomMultiClassificationResult.deploymentName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedCustomMultiClassificationResult; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomMultiClassificationTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomMultiClassificationTask.java index 3c370a7cc6ea..83855d94fd4f 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomMultiClassificationTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomMultiClassificationTask.java @@ -1,25 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 CustomMultiClassificationTask model. */ @Fluent -public final class CustomMultiClassificationTask { +public final class CustomMultiClassificationTask implements JsonSerializable { /* * The parameters property. */ - @JsonProperty(value = "parameters") private CustomMultiLabelClassificationTaskParameters parameters; /* * The taskName property. */ - @JsonProperty(value = "taskName") private String taskName; /** @@ -61,4 +63,45 @@ public CustomMultiClassificationTask setTaskName(String taskName) { this.taskName = taskName; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("parameters", parameters); + jsonWriter.writeStringField("taskName", this.taskName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CustomMultiClassificationTask from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CustomMultiClassificationTask 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 CustomMultiClassificationTask. + */ + public static CustomMultiClassificationTask fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CustomMultiClassificationTask deserializedCustomMultiClassificationTask = new CustomMultiClassificationTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("parameters".equals(fieldName)) { + deserializedCustomMultiClassificationTask.parameters = + CustomMultiLabelClassificationTaskParameters.fromJson(reader); + } else if ("taskName".equals(fieldName)) { + deserializedCustomMultiClassificationTask.taskName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedCustomMultiClassificationTask; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomMultiLabelClassificationLROResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomMultiLabelClassificationLROResult.java index fc38ada69bd5..13a29bd51ea5 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomMultiLabelClassificationLROResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomMultiLabelClassificationLROResult.java @@ -10,22 +10,42 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.time.OffsetDateTime; -import java.util.Objects; +import java.time.format.DateTimeFormatter; -/** The CustomMultiLabelClassificationLROResult model. */ +/** + * The CustomMultiLabelClassificationLROResult model. + */ @Fluent public final class CustomMultiLabelClassificationLROResult extends AnalyzeTextLROResult { + /* + * Enumeration of supported Text Analysis long-running operation task results. + */ + private AnalyzeTextLROResultsKind kind = AnalyzeTextLROResultsKind.CUSTOM_MULTI_LABEL_CLASSIFICATION_LRORESULTS; + /* * The results property. */ private CustomLabelClassificationResult results; - /** Creates an instance of CustomMultiLabelClassificationLROResult class. */ - public CustomMultiLabelClassificationLROResult() {} + /** + * Creates an instance of CustomMultiLabelClassificationLROResult class. + */ + public CustomMultiLabelClassificationLROResult() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis long-running operation task results. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROResultsKind getKind() { + return this.kind; + } /** * Get the results property: The results property. - * + * * @return the results value. */ public CustomLabelClassificationResult getResults() { @@ -34,7 +54,7 @@ public CustomLabelClassificationResult getResults() { /** * Set the results property: The results property. - * + * * @param results the results value to set. * @return the CustomMultiLabelClassificationLROResult object itself. */ @@ -43,84 +63,86 @@ public CustomMultiLabelClassificationLROResult setResults(CustomLabelClassificat return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomMultiLabelClassificationLROResult setTaskName(String taskName) { super.setTaskName(taskName); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomMultiLabelClassificationLROResult setLastUpdateDateTime(OffsetDateTime lastUpdateDateTime) { super.setLastUpdateDateTime(lastUpdateDateTime); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomMultiLabelClassificationLROResult setStatus(State status) { super.setStatus(status); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField( - "kind", Objects.toString(AnalyzeTextLROResultsKind.CUSTOM_MULTI_LABEL_CLASSIFICATION_LRORESULTS, null)); - jsonWriter.writeStringField("lastUpdateDateTime", Objects.toString(getLastUpdateDateTime(), null)); - jsonWriter.writeStringField("status", Objects.toString(getStatus(), null)); + jsonWriter.writeStringField("lastUpdateDateTime", + getLastUpdateDateTime() == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(getLastUpdateDateTime())); + jsonWriter.writeStringField("status", getStatus() == null ? null : getStatus().toString()); jsonWriter.writeStringField("taskName", getTaskName()); jsonWriter.writeJsonField("results", this.results); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of CustomMultiLabelClassificationLROResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of CustomMultiLabelClassificationLROResult 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 or the - * polymorphic discriminator. + * 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 CustomMultiLabelClassificationLROResult. */ public static CustomMultiLabelClassificationLROResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - CustomMultiLabelClassificationLROResult deserializedCustomMultiLabelClassificationLROResult = - new CustomMultiLabelClassificationLROResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + CustomMultiLabelClassificationLROResult deserializedCustomMultiLabelClassificationLROResult + = new CustomMultiLabelClassificationLROResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"CustomMultiLabelClassificationLROResults".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'CustomMultiLabelClassificationLROResults'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("lastUpdateDateTime".equals(fieldName)) { - deserializedCustomMultiLabelClassificationLROResult.setLastUpdateDateTime( - reader.getNullable( - nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); - } else if ("status".equals(fieldName)) { - deserializedCustomMultiLabelClassificationLROResult.setStatus( - State.fromString(reader.getString())); - } else if ("taskName".equals(fieldName)) { - deserializedCustomMultiLabelClassificationLROResult.setTaskName(reader.getString()); - } else if ("results".equals(fieldName)) { - deserializedCustomMultiLabelClassificationLROResult.results = - CustomLabelClassificationResult.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("lastUpdateDateTime".equals(fieldName)) { + deserializedCustomMultiLabelClassificationLROResult.setLastUpdateDateTime( + reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); + } else if ("status".equals(fieldName)) { + deserializedCustomMultiLabelClassificationLROResult.setStatus(State.fromString(reader.getString())); + } else if ("taskName".equals(fieldName)) { + deserializedCustomMultiLabelClassificationLROResult.setTaskName(reader.getString()); + } else if ("results".equals(fieldName)) { + deserializedCustomMultiLabelClassificationLROResult.results + = CustomLabelClassificationResult.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedCustomMultiLabelClassificationLROResult.kind + = AnalyzeTextLROResultsKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedCustomMultiLabelClassificationLROResult; - }); + return deserializedCustomMultiLabelClassificationLROResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomMultiLabelClassificationLROTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomMultiLabelClassificationLROTask.java index 5805a1c82cac..1a7acc746115 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomMultiLabelClassificationLROTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomMultiLabelClassificationLROTask.java @@ -9,22 +9,41 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** Use custom models to classify text into multi label taxonomy. */ +/** + * Use custom models to classify text into multi label taxonomy. + */ @Fluent public final class CustomMultiLabelClassificationLROTask extends AnalyzeTextLROTask { + /* + * Enumeration of supported long-running Text Analysis tasks. + */ + private AnalyzeTextLROTaskKind kind = AnalyzeTextLROTaskKind.CUSTOM_MULTI_LABEL_CLASSIFICATION; + /* * Supported parameters for a Custom Multi Classification task. */ private CustomMultiLabelClassificationTaskParameters parameters; - /** Creates an instance of CustomMultiLabelClassificationLROTask class. */ - public CustomMultiLabelClassificationLROTask() {} + /** + * Creates an instance of CustomMultiLabelClassificationLROTask class. + */ + public CustomMultiLabelClassificationLROTask() { + } + + /** + * Get the kind property: Enumeration of supported long-running Text Analysis tasks. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROTaskKind getKind() { + return this.kind; + } /** * Get the parameters property: Supported parameters for a Custom Multi Classification task. - * + * * @return the parameters value. */ public CustomMultiLabelClassificationTaskParameters getParameters() { @@ -33,70 +52,67 @@ public CustomMultiLabelClassificationTaskParameters getParameters() { /** * Set the parameters property: Supported parameters for a Custom Multi Classification task. - * + * * @param parameters the parameters value to set. * @return the CustomMultiLabelClassificationLROTask object itself. */ - public CustomMultiLabelClassificationLROTask setParameters( - CustomMultiLabelClassificationTaskParameters parameters) { + public CustomMultiLabelClassificationLROTask + setParameters(CustomMultiLabelClassificationTaskParameters parameters) { this.parameters = parameters; return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomMultiLabelClassificationLROTask setTaskName(String taskName) { super.setTaskName(taskName); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField( - "kind", Objects.toString(AnalyzeTextLROTaskKind.CUSTOM_MULTI_LABEL_CLASSIFICATION, null)); jsonWriter.writeStringField("taskName", getTaskName()); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); jsonWriter.writeJsonField("parameters", this.parameters); return jsonWriter.writeEndObject(); } /** * Reads an instance of CustomMultiLabelClassificationLROTask from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of CustomMultiLabelClassificationLROTask 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 the polymorphic discriminator. + * or null if it was pointing to JSON null. * @throws IOException If an error occurs while reading the CustomMultiLabelClassificationLROTask. */ public static CustomMultiLabelClassificationLROTask fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - CustomMultiLabelClassificationLROTask deserializedCustomMultiLabelClassificationLROTask = - new CustomMultiLabelClassificationLROTask(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + CustomMultiLabelClassificationLROTask deserializedCustomMultiLabelClassificationLROTask + = new CustomMultiLabelClassificationLROTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"CustomMultiLabelClassification".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'CustomMultiLabelClassification'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("taskName".equals(fieldName)) { - deserializedCustomMultiLabelClassificationLROTask.setTaskName(reader.getString()); - } else if ("parameters".equals(fieldName)) { - deserializedCustomMultiLabelClassificationLROTask.parameters = - CustomMultiLabelClassificationTaskParameters.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("taskName".equals(fieldName)) { + deserializedCustomMultiLabelClassificationLROTask.setTaskName(reader.getString()); + } else if ("kind".equals(fieldName)) { + deserializedCustomMultiLabelClassificationLROTask.kind + = AnalyzeTextLROTaskKind.fromString(reader.getString()); + } else if ("parameters".equals(fieldName)) { + deserializedCustomMultiLabelClassificationLROTask.parameters + = CustomMultiLabelClassificationTaskParameters.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedCustomMultiLabelClassificationLROTask; - }); + return deserializedCustomMultiLabelClassificationLROTask; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomMultiLabelClassificationTaskParameters.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomMultiLabelClassificationTaskParameters.java index b5083ddd6140..4418d5a4d837 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomMultiLabelClassificationTaskParameters.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomMultiLabelClassificationTaskParameters.java @@ -10,33 +10,47 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** Supported parameters for a Custom Multi Classification task. */ +/** + * Supported parameters for a Custom Multi Classification task. + */ @Fluent public final class CustomMultiLabelClassificationTaskParameters extends CustomTaskParameters { - /** Creates an instance of CustomMultiLabelClassificationTaskParameters class. */ - public CustomMultiLabelClassificationTaskParameters() {} + /** + * Creates an instance of CustomMultiLabelClassificationTaskParameters class. + */ + public CustomMultiLabelClassificationTaskParameters() { + } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomMultiLabelClassificationTaskParameters setProjectName(String projectName) { super.setProjectName(projectName); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomMultiLabelClassificationTaskParameters setDeploymentName(String deploymentName) { super.setDeploymentName(deploymentName); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomMultiLabelClassificationTaskParameters setLoggingOptOut(Boolean loggingOptOut) { super.setLoggingOptOut(loggingOptOut); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -48,37 +62,34 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of CustomMultiLabelClassificationTaskParameters from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of CustomMultiLabelClassificationTaskParameters if the JsonReader was pointing to an instance - * of it, or null if it was pointing to JSON null. + * 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 CustomMultiLabelClassificationTaskParameters. */ public static CustomMultiLabelClassificationTaskParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - CustomMultiLabelClassificationTaskParameters - deserializedCustomMultiLabelClassificationTaskParameters = - new CustomMultiLabelClassificationTaskParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + CustomMultiLabelClassificationTaskParameters deserializedCustomMultiLabelClassificationTaskParameters + = new CustomMultiLabelClassificationTaskParameters(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("projectName".equals(fieldName)) { - deserializedCustomMultiLabelClassificationTaskParameters.setProjectName(reader.getString()); - } else if ("deploymentName".equals(fieldName)) { - deserializedCustomMultiLabelClassificationTaskParameters.setDeploymentName( - reader.getString()); - } else if ("loggingOptOut".equals(fieldName)) { - deserializedCustomMultiLabelClassificationTaskParameters.setLoggingOptOut( - reader.getNullable(JsonReader::getBoolean)); - } else { - reader.skipChildren(); - } - } + if ("projectName".equals(fieldName)) { + deserializedCustomMultiLabelClassificationTaskParameters.setProjectName(reader.getString()); + } else if ("deploymentName".equals(fieldName)) { + deserializedCustomMultiLabelClassificationTaskParameters.setDeploymentName(reader.getString()); + } else if ("loggingOptOut".equals(fieldName)) { + deserializedCustomMultiLabelClassificationTaskParameters + .setLoggingOptOut(reader.getNullable(JsonReader::getBoolean)); + } else { + reader.skipChildren(); + } + } - return deserializedCustomMultiLabelClassificationTaskParameters; - }); + return deserializedCustomMultiLabelClassificationTaskParameters; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomResult.java index 446847c4408e..070a596ddb1c 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomResult.java @@ -12,7 +12,9 @@ import java.io.IOException; import java.util.List; -/** The CustomResult model. */ +/** + * The CustomResult model. + */ @Fluent public class CustomResult implements JsonSerializable { /* @@ -35,12 +37,15 @@ public class CustomResult implements JsonSerializable { */ private String deploymentName; - /** Creates an instance of CustomResult class. */ - public CustomResult() {} + /** + * Creates an instance of CustomResult class. + */ + public CustomResult() { + } /** * Get the errors property: Errors by document id. - * + * * @return the errors value. */ public List getErrors() { @@ -49,7 +54,7 @@ public List getErrors() { /** * Set the errors property: Errors by document id. - * + * * @param errors the errors value to set. * @return the CustomResult object itself. */ @@ -61,7 +66,7 @@ public CustomResult setErrors(List errors) { /** * Get the statistics property: if showStats=true was specified in the request this field will contain information * about the request payload. - * + * * @return the statistics value. */ public RequestStatistics getStatistics() { @@ -71,7 +76,7 @@ public RequestStatistics getStatistics() { /** * Set the statistics property: if showStats=true was specified in the request this field will contain information * about the request payload. - * + * * @param statistics the statistics value to set. * @return the CustomResult object itself. */ @@ -82,7 +87,7 @@ public CustomResult setStatistics(RequestStatistics statistics) { /** * Get the projectName property: This field indicates the project name for the model. - * + * * @return the projectName value. */ public String getProjectName() { @@ -91,7 +96,7 @@ public String getProjectName() { /** * Set the projectName property: This field indicates the project name for the model. - * + * * @param projectName the projectName value to set. * @return the CustomResult object itself. */ @@ -102,7 +107,7 @@ public CustomResult setProjectName(String projectName) { /** * Get the deploymentName property: This field indicates the deployment name for the model. - * + * * @return the deploymentName value. */ public String getDeploymentName() { @@ -111,7 +116,7 @@ public String getDeploymentName() { /** * Set the deploymentName property: This field indicates the deployment name for the model. - * + * * @param deploymentName the deploymentName value to set. * @return the CustomResult object itself. */ @@ -120,6 +125,9 @@ public CustomResult setDeploymentName(String deploymentName) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -132,36 +140,35 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of CustomResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of CustomResult if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 CustomResult. */ public static CustomResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - CustomResult deserializedCustomResult = new CustomResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("errors".equals(fieldName)) { - List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); - deserializedCustomResult.errors = errors; - } else if ("projectName".equals(fieldName)) { - deserializedCustomResult.projectName = reader.getString(); - } else if ("deploymentName".equals(fieldName)) { - deserializedCustomResult.deploymentName = reader.getString(); - } else if ("statistics".equals(fieldName)) { - deserializedCustomResult.statistics = RequestStatistics.fromJson(reader); - } else { - reader.skipChildren(); - } - } - - return deserializedCustomResult; - }); + return jsonReader.readObject(reader -> { + CustomResult deserializedCustomResult = new CustomResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("errors".equals(fieldName)) { + List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); + deserializedCustomResult.errors = errors; + } else if ("projectName".equals(fieldName)) { + deserializedCustomResult.projectName = reader.getString(); + } else if ("deploymentName".equals(fieldName)) { + deserializedCustomResult.deploymentName = reader.getString(); + } else if ("statistics".equals(fieldName)) { + deserializedCustomResult.statistics = RequestStatistics.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedCustomResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomSingleClassificationResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomSingleClassificationResult.java index a52a581eab33..d0ea49abb54d 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomSingleClassificationResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomSingleClassificationResult.java @@ -1,45 +1,44 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 CustomSingleClassificationResult model. */ @Fluent -public final class CustomSingleClassificationResult { +public final class CustomSingleClassificationResult implements JsonSerializable { /* * Response by document */ - @JsonProperty(value = "documents", required = true) private List documents; /* * Errors by document id. */ - @JsonProperty(value = "errors", required = true) private List errors; /* * if showStats=true was specified in the request this field will contain * information about the request payload. */ - @JsonProperty(value = "statistics") private RequestStatistics statistics; /* * This field indicates the project name for the model. */ - @JsonProperty(value = "projectName", required = true) private String projectName; /* * This field indicates the deployment name for the model. */ - @JsonProperty(value = "deploymentName", required = true) private String deploymentName; /** @@ -143,4 +142,55 @@ public CustomSingleClassificationResult setDeploymentName(String deploymentName) this.deploymentName = deploymentName; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("documents", this.documents, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("errors", this.errors, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("statistics", this.statistics); + jsonWriter.writeStringField("projectName", this.projectName); + jsonWriter.writeStringField("deploymentName", this.deploymentName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CustomSingleClassificationResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CustomSingleClassificationResult 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 CustomSingleClassificationResult. + */ + public static CustomSingleClassificationResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CustomSingleClassificationResult deserializedCustomSingleClassificationResult = new CustomSingleClassificationResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("documents".equals(fieldName)) { + deserializedCustomSingleClassificationResult.documents + = reader.readArray(reader1 -> SingleClassificationDocument.fromJson(reader1)); + } else if ("errors".equals(fieldName)) { + deserializedCustomSingleClassificationResult.errors + = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); + } else if ("statistics".equals(fieldName)) { + deserializedCustomSingleClassificationResult.statistics = RequestStatistics.fromJson(reader); + } else if ("projectName".equals(fieldName)) { + deserializedCustomSingleClassificationResult.projectName = reader.getString(); + } else if ("deploymentName".equals(fieldName)) { + deserializedCustomSingleClassificationResult.deploymentName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedCustomSingleClassificationResult; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomSingleClassificationTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomSingleClassificationTask.java index 86561e43c896..6c8d5f385059 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomSingleClassificationTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomSingleClassificationTask.java @@ -1,25 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 CustomSingleClassificationTask model. */ @Fluent -public final class CustomSingleClassificationTask { +public final class CustomSingleClassificationTask implements JsonSerializable { /* * The parameters property. */ - @JsonProperty(value = "parameters") private CustomSingleLabelClassificationTaskParameters parameters; /* * The taskName property. */ - @JsonProperty(value = "taskName") private String taskName; /** @@ -61,4 +63,45 @@ public CustomSingleClassificationTask setTaskName(String taskName) { this.taskName = taskName; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("parameters", parameters); + jsonWriter.writeStringField("taskName", this.taskName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CustomSingleClassificationTask from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CustomSingleClassificationTask 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 CustomSingleClassificationTask. + */ + public static CustomSingleClassificationTask fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CustomSingleClassificationTask deserializedCustomSingleClassificationTask = new CustomSingleClassificationTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("parameters".equals(fieldName)) { + deserializedCustomSingleClassificationTask.parameters + = CustomSingleLabelClassificationTaskParameters.fromJson(reader); + } else if ("taskName".equals(fieldName)) { + deserializedCustomSingleClassificationTask.taskName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedCustomSingleClassificationTask; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomSingleLabelClassificationLROResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomSingleLabelClassificationLROResult.java index 8409e17749ec..30f8d57555e7 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomSingleLabelClassificationLROResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomSingleLabelClassificationLROResult.java @@ -10,22 +10,42 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.time.OffsetDateTime; -import java.util.Objects; +import java.time.format.DateTimeFormatter; -/** The CustomSingleLabelClassificationLROResult model. */ +/** + * The CustomSingleLabelClassificationLROResult model. + */ @Fluent public final class CustomSingleLabelClassificationLROResult extends AnalyzeTextLROResult { + /* + * Enumeration of supported Text Analysis long-running operation task results. + */ + private AnalyzeTextLROResultsKind kind = AnalyzeTextLROResultsKind.CUSTOM_SINGLE_LABEL_CLASSIFICATION_LRORESULTS; + /* * The results property. */ private CustomLabelClassificationResult results; - /** Creates an instance of CustomSingleLabelClassificationLROResult class. */ - public CustomSingleLabelClassificationLROResult() {} + /** + * Creates an instance of CustomSingleLabelClassificationLROResult class. + */ + public CustomSingleLabelClassificationLROResult() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis long-running operation task results. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROResultsKind getKind() { + return this.kind; + } /** * Get the results property: The results property. - * + * * @return the results value. */ public CustomLabelClassificationResult getResults() { @@ -34,7 +54,7 @@ public CustomLabelClassificationResult getResults() { /** * Set the results property: The results property. - * + * * @param results the results value to set. * @return the CustomSingleLabelClassificationLROResult object itself. */ @@ -43,85 +63,87 @@ public CustomSingleLabelClassificationLROResult setResults(CustomLabelClassifica return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomSingleLabelClassificationLROResult setTaskName(String taskName) { super.setTaskName(taskName); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomSingleLabelClassificationLROResult setLastUpdateDateTime(OffsetDateTime lastUpdateDateTime) { super.setLastUpdateDateTime(lastUpdateDateTime); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomSingleLabelClassificationLROResult setStatus(State status) { super.setStatus(status); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField( - "kind", - Objects.toString(AnalyzeTextLROResultsKind.CUSTOM_SINGLE_LABEL_CLASSIFICATION_LRORESULTS, null)); - jsonWriter.writeStringField("lastUpdateDateTime", Objects.toString(getLastUpdateDateTime(), null)); - jsonWriter.writeStringField("status", Objects.toString(getStatus(), null)); + jsonWriter.writeStringField("lastUpdateDateTime", + getLastUpdateDateTime() == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(getLastUpdateDateTime())); + jsonWriter.writeStringField("status", getStatus() == null ? null : getStatus().toString()); jsonWriter.writeStringField("taskName", getTaskName()); jsonWriter.writeJsonField("results", this.results); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of CustomSingleLabelClassificationLROResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of CustomSingleLabelClassificationLROResult 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 or the - * polymorphic discriminator. + * 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 CustomSingleLabelClassificationLROResult. */ public static CustomSingleLabelClassificationLROResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - CustomSingleLabelClassificationLROResult deserializedCustomSingleLabelClassificationLROResult = - new CustomSingleLabelClassificationLROResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + CustomSingleLabelClassificationLROResult deserializedCustomSingleLabelClassificationLROResult + = new CustomSingleLabelClassificationLROResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"CustomSingleLabelClassificationLROResults".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'CustomSingleLabelClassificationLROResults'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("lastUpdateDateTime".equals(fieldName)) { - deserializedCustomSingleLabelClassificationLROResult.setLastUpdateDateTime( - reader.getNullable( - nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); - } else if ("status".equals(fieldName)) { - deserializedCustomSingleLabelClassificationLROResult.setStatus( - State.fromString(reader.getString())); - } else if ("taskName".equals(fieldName)) { - deserializedCustomSingleLabelClassificationLROResult.setTaskName(reader.getString()); - } else if ("results".equals(fieldName)) { - deserializedCustomSingleLabelClassificationLROResult.results = - CustomLabelClassificationResult.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("lastUpdateDateTime".equals(fieldName)) { + deserializedCustomSingleLabelClassificationLROResult.setLastUpdateDateTime( + reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); + } else if ("status".equals(fieldName)) { + deserializedCustomSingleLabelClassificationLROResult + .setStatus(State.fromString(reader.getString())); + } else if ("taskName".equals(fieldName)) { + deserializedCustomSingleLabelClassificationLROResult.setTaskName(reader.getString()); + } else if ("results".equals(fieldName)) { + deserializedCustomSingleLabelClassificationLROResult.results + = CustomLabelClassificationResult.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedCustomSingleLabelClassificationLROResult.kind + = AnalyzeTextLROResultsKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedCustomSingleLabelClassificationLROResult; - }); + return deserializedCustomSingleLabelClassificationLROResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomSingleLabelClassificationLROTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomSingleLabelClassificationLROTask.java index 15f8d821627e..ef6a0fad170a 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomSingleLabelClassificationLROTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomSingleLabelClassificationLROTask.java @@ -9,22 +9,41 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** Use custom models to classify text into single label taxonomy. */ +/** + * Use custom models to classify text into single label taxonomy. + */ @Fluent public final class CustomSingleLabelClassificationLROTask extends AnalyzeTextLROTask { + /* + * Enumeration of supported long-running Text Analysis tasks. + */ + private AnalyzeTextLROTaskKind kind = AnalyzeTextLROTaskKind.CUSTOM_SINGLE_LABEL_CLASSIFICATION; + /* * Supported parameters for a Custom Single Classification task. */ private CustomSingleLabelClassificationTaskParameters parameters; - /** Creates an instance of CustomSingleLabelClassificationLROTask class. */ - public CustomSingleLabelClassificationLROTask() {} + /** + * Creates an instance of CustomSingleLabelClassificationLROTask class. + */ + public CustomSingleLabelClassificationLROTask() { + } + + /** + * Get the kind property: Enumeration of supported long-running Text Analysis tasks. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROTaskKind getKind() { + return this.kind; + } /** * Get the parameters property: Supported parameters for a Custom Single Classification task. - * + * * @return the parameters value. */ public CustomSingleLabelClassificationTaskParameters getParameters() { @@ -33,70 +52,67 @@ public CustomSingleLabelClassificationTaskParameters getParameters() { /** * Set the parameters property: Supported parameters for a Custom Single Classification task. - * + * * @param parameters the parameters value to set. * @return the CustomSingleLabelClassificationLROTask object itself. */ - public CustomSingleLabelClassificationLROTask setParameters( - CustomSingleLabelClassificationTaskParameters parameters) { + public CustomSingleLabelClassificationLROTask + setParameters(CustomSingleLabelClassificationTaskParameters parameters) { this.parameters = parameters; return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomSingleLabelClassificationLROTask setTaskName(String taskName) { super.setTaskName(taskName); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField( - "kind", Objects.toString(AnalyzeTextLROTaskKind.CUSTOM_SINGLE_LABEL_CLASSIFICATION, null)); jsonWriter.writeStringField("taskName", getTaskName()); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); jsonWriter.writeJsonField("parameters", this.parameters); return jsonWriter.writeEndObject(); } /** * Reads an instance of CustomSingleLabelClassificationLROTask from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of CustomSingleLabelClassificationLROTask 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 the polymorphic discriminator. + * it, or null if it was pointing to JSON null. * @throws IOException If an error occurs while reading the CustomSingleLabelClassificationLROTask. */ public static CustomSingleLabelClassificationLROTask fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - CustomSingleLabelClassificationLROTask deserializedCustomSingleLabelClassificationLROTask = - new CustomSingleLabelClassificationLROTask(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + CustomSingleLabelClassificationLROTask deserializedCustomSingleLabelClassificationLROTask + = new CustomSingleLabelClassificationLROTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"CustomSingleLabelClassification".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'CustomSingleLabelClassification'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("taskName".equals(fieldName)) { - deserializedCustomSingleLabelClassificationLROTask.setTaskName(reader.getString()); - } else if ("parameters".equals(fieldName)) { - deserializedCustomSingleLabelClassificationLROTask.parameters = - CustomSingleLabelClassificationTaskParameters.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("taskName".equals(fieldName)) { + deserializedCustomSingleLabelClassificationLROTask.setTaskName(reader.getString()); + } else if ("kind".equals(fieldName)) { + deserializedCustomSingleLabelClassificationLROTask.kind + = AnalyzeTextLROTaskKind.fromString(reader.getString()); + } else if ("parameters".equals(fieldName)) { + deserializedCustomSingleLabelClassificationLROTask.parameters + = CustomSingleLabelClassificationTaskParameters.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedCustomSingleLabelClassificationLROTask; - }); + return deserializedCustomSingleLabelClassificationLROTask; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomSingleLabelClassificationTaskParameters.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomSingleLabelClassificationTaskParameters.java index 63dd75eb609d..6536194ee0f2 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomSingleLabelClassificationTaskParameters.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomSingleLabelClassificationTaskParameters.java @@ -10,33 +10,47 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** Supported parameters for a Custom Single Classification task. */ +/** + * Supported parameters for a Custom Single Classification task. + */ @Fluent public final class CustomSingleLabelClassificationTaskParameters extends CustomTaskParameters { - /** Creates an instance of CustomSingleLabelClassificationTaskParameters class. */ - public CustomSingleLabelClassificationTaskParameters() {} + /** + * Creates an instance of CustomSingleLabelClassificationTaskParameters class. + */ + public CustomSingleLabelClassificationTaskParameters() { + } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomSingleLabelClassificationTaskParameters setProjectName(String projectName) { super.setProjectName(projectName); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomSingleLabelClassificationTaskParameters setDeploymentName(String deploymentName) { super.setDeploymentName(deploymentName); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomSingleLabelClassificationTaskParameters setLoggingOptOut(Boolean loggingOptOut) { super.setLoggingOptOut(loggingOptOut); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -48,38 +62,34 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of CustomSingleLabelClassificationTaskParameters from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of CustomSingleLabelClassificationTaskParameters if the JsonReader was pointing to an - * instance of it, or null if it was pointing to JSON null. + * 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 CustomSingleLabelClassificationTaskParameters. */ public static CustomSingleLabelClassificationTaskParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - CustomSingleLabelClassificationTaskParameters - deserializedCustomSingleLabelClassificationTaskParameters = - new CustomSingleLabelClassificationTaskParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + CustomSingleLabelClassificationTaskParameters deserializedCustomSingleLabelClassificationTaskParameters + = new CustomSingleLabelClassificationTaskParameters(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("projectName".equals(fieldName)) { - deserializedCustomSingleLabelClassificationTaskParameters.setProjectName( - reader.getString()); - } else if ("deploymentName".equals(fieldName)) { - deserializedCustomSingleLabelClassificationTaskParameters.setDeploymentName( - reader.getString()); - } else if ("loggingOptOut".equals(fieldName)) { - deserializedCustomSingleLabelClassificationTaskParameters.setLoggingOptOut( - reader.getNullable(JsonReader::getBoolean)); - } else { - reader.skipChildren(); - } - } + if ("projectName".equals(fieldName)) { + deserializedCustomSingleLabelClassificationTaskParameters.setProjectName(reader.getString()); + } else if ("deploymentName".equals(fieldName)) { + deserializedCustomSingleLabelClassificationTaskParameters.setDeploymentName(reader.getString()); + } else if ("loggingOptOut".equals(fieldName)) { + deserializedCustomSingleLabelClassificationTaskParameters + .setLoggingOptOut(reader.getNullable(JsonReader::getBoolean)); + } else { + reader.skipChildren(); + } + } - return deserializedCustomSingleLabelClassificationTaskParameters; - }); + return deserializedCustomSingleLabelClassificationTaskParameters; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomTaskParameters.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomTaskParameters.java index 4e90de352d22..25548ead7fce 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomTaskParameters.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/CustomTaskParameters.java @@ -10,7 +10,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** Parameters object for a text analysis task using custom models. */ +/** + * Parameters object for a text analysis task using custom models. + */ @Fluent public class CustomTaskParameters extends TaskParameters { /* @@ -23,12 +25,15 @@ public class CustomTaskParameters extends TaskParameters { */ private String deploymentName; - /** Creates an instance of CustomTaskParameters class. */ - public CustomTaskParameters() {} + /** + * Creates an instance of CustomTaskParameters class. + */ + public CustomTaskParameters() { + } /** * Get the projectName property: This field indicates the project name for the model. - * + * * @return the projectName value. */ public String getProjectName() { @@ -37,7 +42,7 @@ public String getProjectName() { /** * Set the projectName property: This field indicates the project name for the model. - * + * * @param projectName the projectName value to set. * @return the CustomTaskParameters object itself. */ @@ -48,7 +53,7 @@ public CustomTaskParameters setProjectName(String projectName) { /** * Get the deploymentName property: This field indicates the deployment name for the model. - * + * * @return the deploymentName value. */ public String getDeploymentName() { @@ -57,7 +62,7 @@ public String getDeploymentName() { /** * Set the deploymentName property: This field indicates the deployment name for the model. - * + * * @param deploymentName the deploymentName value to set. * @return the CustomTaskParameters object itself. */ @@ -66,13 +71,18 @@ public CustomTaskParameters setDeploymentName(String deploymentName) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public CustomTaskParameters setLoggingOptOut(Boolean loggingOptOut) { super.setLoggingOptOut(loggingOptOut); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -84,34 +94,32 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of CustomTaskParameters from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of CustomTaskParameters if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. + * 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 CustomTaskParameters. */ public static CustomTaskParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - CustomTaskParameters deserializedCustomTaskParameters = new CustomTaskParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + CustomTaskParameters deserializedCustomTaskParameters = new CustomTaskParameters(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("loggingOptOut".equals(fieldName)) { - deserializedCustomTaskParameters.setLoggingOptOut( - reader.getNullable(JsonReader::getBoolean)); - } else if ("projectName".equals(fieldName)) { - deserializedCustomTaskParameters.projectName = reader.getString(); - } else if ("deploymentName".equals(fieldName)) { - deserializedCustomTaskParameters.deploymentName = reader.getString(); - } else { - reader.skipChildren(); - } - } + if ("loggingOptOut".equals(fieldName)) { + deserializedCustomTaskParameters.setLoggingOptOut(reader.getNullable(JsonReader::getBoolean)); + } else if ("projectName".equals(fieldName)) { + deserializedCustomTaskParameters.projectName = reader.getString(); + } else if ("deploymentName".equals(fieldName)) { + deserializedCustomTaskParameters.deploymentName = reader.getString(); + } else { + reader.skipChildren(); + } + } - return deserializedCustomTaskParameters; - }); + return deserializedCustomTaskParameters; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DetectedLanguage.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DetectedLanguage.java index ce01b7f536ea..ea35f675d397 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DetectedLanguage.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DetectedLanguage.java @@ -11,7 +11,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** The DetectedLanguage model. */ +/** + * The DetectedLanguage model. + */ @Fluent public final class DetectedLanguage implements JsonSerializable { /* @@ -25,17 +27,19 @@ public final class DetectedLanguage implements JsonSerializable { - DetectedLanguage deserializedDetectedLanguage = new DetectedLanguage(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("name".equals(fieldName)) { - deserializedDetectedLanguage.name = reader.getString(); - } else if ("iso6391Name".equals(fieldName)) { - deserializedDetectedLanguage.iso6391Name = reader.getString(); - } else if ("confidenceScore".equals(fieldName)) { - deserializedDetectedLanguage.confidenceScore = reader.getDouble(); - } else { - reader.skipChildren(); - } - } - - return deserializedDetectedLanguage; - }); + return jsonReader.readObject(reader -> { + DetectedLanguage deserializedDetectedLanguage = new DetectedLanguage(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedDetectedLanguage.name = reader.getString(); + } else if ("iso6391Name".equals(fieldName)) { + deserializedDetectedLanguage.iso6391Name = reader.getString(); + } else if ("confidenceScore".equals(fieldName)) { + deserializedDetectedLanguage.confidenceScore = reader.getDouble(); + } else { + reader.skipChildren(); + } + } + + return deserializedDetectedLanguage; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentError.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentError.java index 66bc929f095f..1784ac619658 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentError.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentError.java @@ -11,7 +11,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** Contains details of errors encountered during a job execution. */ +/** + * Contains details of errors encountered during a job execution. + */ @Fluent public final class DocumentError implements JsonSerializable { /* @@ -24,12 +26,15 @@ public final class DocumentError implements JsonSerializable { */ private Error error; - /** Creates an instance of DocumentError class. */ - public DocumentError() {} + /** + * Creates an instance of DocumentError class. + */ + public DocumentError() { + } /** * Get the id property: The ID of the input document. - * + * * @return the id value. */ public String getId() { @@ -38,7 +43,7 @@ public String getId() { /** * Set the id property: The ID of the input document. - * + * * @param id the id value to set. * @return the DocumentError object itself. */ @@ -49,7 +54,7 @@ public DocumentError setId(String id) { /** * Get the error property: Error encountered. - * + * * @return the error value. */ public Error getError() { @@ -58,7 +63,7 @@ public Error getError() { /** * Set the error property: Error encountered. - * + * * @param error the error value to set. * @return the DocumentError object itself. */ @@ -67,6 +72,9 @@ public DocumentError setError(Error error) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -77,31 +85,30 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of DocumentError from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of DocumentError if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 DocumentError. */ public static DocumentError fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - DocumentError deserializedDocumentError = new DocumentError(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + DocumentError deserializedDocumentError = new DocumentError(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("id".equals(fieldName)) { - deserializedDocumentError.id = reader.getString(); - } else if ("error".equals(fieldName)) { - deserializedDocumentError.error = Error.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("id".equals(fieldName)) { + deserializedDocumentError.id = reader.getString(); + } else if ("error".equals(fieldName)) { + deserializedDocumentError.error = Error.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedDocumentError; - }); + return deserializedDocumentError; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentLanguage.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentLanguage.java index d68a5de43459..6535deef92ad 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentLanguage.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentLanguage.java @@ -1,40 +1,39 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 DocumentLanguage model. */ @Fluent -public final class DocumentLanguage { +public final class DocumentLanguage implements JsonSerializable { /* * Unique, non-empty document identifier. */ - @JsonProperty(value = "id", required = true) private String id; /* * Detected Language. */ - @JsonProperty(value = "detectedLanguage", required = true) private DetectedLanguage detectedLanguage; /* * Warnings encountered while processing document. */ - @JsonProperty(value = "warnings", required = true) private List warnings; /* * if showStats=true was specified in the request this field will contain * information about the document payload. */ - @JsonProperty(value = "statistics") private DocumentStatistics statistics; /** @@ -118,4 +117,51 @@ public DocumentLanguage setStatistics(DocumentStatistics statistics) { this.statistics = statistics; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeJsonField("detectedLanguage", this.detectedLanguage); + jsonWriter.writeArrayField("warnings", this.warnings, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("statistics", this.statistics); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DocumentLanguage from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DocumentLanguage 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 DocumentLanguage. + */ + public static DocumentLanguage fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DocumentLanguage deserializedDocumentLanguage = new DocumentLanguage(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedDocumentLanguage.id = reader.getString(); + } else if ("confidenceScores".equals(fieldName)) { + deserializedDocumentLanguage.detectedLanguage = DetectedLanguage.fromJson(reader); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedDocumentLanguage.warnings = warnings; + } else if ("statistics".equals(fieldName)) { + deserializedDocumentLanguage.statistics = DocumentStatistics.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedDocumentLanguage; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentResult.java index c2105cd44931..06255d4a2149 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentResult.java @@ -12,7 +12,9 @@ import java.io.IOException; import java.util.List; -/** The DocumentResult model. */ +/** + * The DocumentResult model. + */ @Fluent public class DocumentResult implements JsonSerializable { /* @@ -30,12 +32,15 @@ public class DocumentResult implements JsonSerializable { */ private DocumentStatistics statistics; - /** Creates an instance of DocumentResult class. */ - public DocumentResult() {} + /** + * Creates an instance of DocumentResult class. + */ + public DocumentResult() { + } /** * Get the id property: Unique, non-empty document identifier. - * + * * @return the id value. */ public String getId() { @@ -44,7 +49,7 @@ public String getId() { /** * Set the id property: Unique, non-empty document identifier. - * + * * @param id the id value to set. * @return the DocumentResult object itself. */ @@ -55,7 +60,7 @@ public DocumentResult setId(String id) { /** * Get the warnings property: Warnings encountered while processing document. - * + * * @return the warnings value. */ public List getWarnings() { @@ -64,7 +69,7 @@ public List getWarnings() { /** * Set the warnings property: Warnings encountered while processing document. - * + * * @param warnings the warnings value to set. * @return the DocumentResult object itself. */ @@ -76,7 +81,7 @@ public DocumentResult setWarnings(List warnings) { /** * Get the statistics property: if showStats=true was specified in the request this field will contain information * about the document payload. - * + * * @return the statistics value. */ public DocumentStatistics getStatistics() { @@ -86,7 +91,7 @@ public DocumentStatistics getStatistics() { /** * Set the statistics property: if showStats=true was specified in the request this field will contain information * about the document payload. - * + * * @param statistics the statistics value to set. * @return the DocumentResult object itself. */ @@ -95,6 +100,9 @@ public DocumentResult setStatistics(DocumentStatistics statistics) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -106,35 +114,33 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of DocumentResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of DocumentResult if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 DocumentResult. */ public static DocumentResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - DocumentResult deserializedDocumentResult = new DocumentResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - deserializedDocumentResult.id = reader.getString(); - } else if ("warnings".equals(fieldName)) { - List warnings = - reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); - deserializedDocumentResult.warnings = warnings; - } else if ("statistics".equals(fieldName)) { - deserializedDocumentResult.statistics = DocumentStatistics.fromJson(reader); - } else { - reader.skipChildren(); - } - } - - return deserializedDocumentResult; - }); + return jsonReader.readObject(reader -> { + DocumentResult deserializedDocumentResult = new DocumentResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedDocumentResult.id = reader.getString(); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedDocumentResult.warnings = warnings; + } else if ("statistics".equals(fieldName)) { + deserializedDocumentResult.statistics = DocumentStatistics.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedDocumentResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentSentiment.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentSentiment.java index 670bd9f0486a..c173202aefe6 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentSentiment.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentSentiment.java @@ -1,53 +1,51 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 DocumentSentiment model. */ @Fluent -public final class DocumentSentiment { +public final class DocumentSentiment implements JsonSerializable { /* * Unique, non-empty document identifier. */ - @JsonProperty(value = "id", required = true) private String id; /* * Predicted sentiment for document (Negative, Neutral, Positive, or * Mixed). */ - @JsonProperty(value = "sentiment", required = true) private DocumentSentimentValue sentiment; /* * if showStats=true was specified in the request this field will contain * information about the document payload. */ - @JsonProperty(value = "statistics") private DocumentStatistics statistics; /* * Document level sentiment confidence scores between 0 and 1 for each * sentiment class. */ - @JsonProperty(value = "confidenceScores", required = true) private SentimentConfidenceScorePerLabel confidenceScores; /* * Sentence level sentiment analysis. */ - @JsonProperty(value = "sentences", required = true) private List sentences; /* * Warnings encountered while processing document. */ - @JsonProperty(value = "warnings", required = true) private List warnings; /** @@ -173,4 +171,57 @@ public DocumentSentiment setWarnings(List warnings) { this.warnings = warnings; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("sentiment", this.sentiment.toString()); + jsonWriter.writeJsonField("statistics", this.statistics); + jsonWriter.writeJsonField("confidenceScores", this.confidenceScores); + jsonWriter.writeArrayField("sentences", this.sentences, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("warnings", this.warnings, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DocumentSentiment from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DocumentSentiment 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 DocumentSentiment. + */ + public static DocumentSentiment fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DocumentSentiment deserializedDocumentSentiment = new DocumentSentiment(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedDocumentSentiment.id = reader.getString(); + } else if ("sentiment".equals(fieldName)) { + deserializedDocumentSentiment.sentiment = DocumentSentimentValue.fromString(reader.getString()); + } else if ("statistics".equals(fieldName)) { + deserializedDocumentSentiment.statistics = DocumentStatistics.fromJson(reader); + } else if ("confidenceScores".equals(fieldName)) { + deserializedDocumentSentiment.confidenceScores = SentimentConfidenceScorePerLabel.fromJson(reader); + } else if ("sentences".equals(fieldName)) { + deserializedDocumentSentiment.sentences = reader.readArray(reader1 -> SentenceSentiment.fromJson(reader1)); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedDocumentSentiment.warnings = warnings; + } else { + reader.skipChildren(); + } + } + + return deserializedDocumentSentiment; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentSentimentValue.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentSentimentValue.java index e8c8bca20f4f..c1588b74b611 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentSentimentValue.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentSentimentValue.java @@ -4,21 +4,33 @@ package com.azure.ai.textanalytics.implementation.models; -/** Predicted sentiment for document (Negative, Neutral, Positive, or Mixed). */ +/** + * Predicted sentiment for document (Negative, Neutral, Positive, or Mixed). + */ public enum DocumentSentimentValue { - /** Enum value positive. */ + /** + * Enum value positive. + */ POSITIVE("positive"), - /** Enum value neutral. */ + /** + * Enum value neutral. + */ NEUTRAL("neutral"), - /** Enum value negative. */ + /** + * Enum value negative. + */ NEGATIVE("negative"), - /** Enum value mixed. */ + /** + * Enum value mixed. + */ MIXED("mixed"); - /** The actual serialized value for a DocumentSentimentValue instance. */ + /** + * The actual serialized value for a DocumentSentimentValue instance. + */ private final String value; DocumentSentimentValue(String value) { @@ -27,7 +39,7 @@ public enum DocumentSentimentValue { /** * Parses a serialized value to a DocumentSentimentValue instance. - * + * * @param value the serialized value to parse. * @return the parsed DocumentSentimentValue object, or null if unable to parse. */ @@ -44,7 +56,9 @@ public static DocumentSentimentValue fromString(String value) { return null; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public String toString() { return this.value; diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentStatistics.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentStatistics.java index f3d97b60b7a7..3e536bec043b 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentStatistics.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentStatistics.java @@ -11,7 +11,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** if showStats=true was specified in the request this field will contain information about the document payload. */ +/** + * if showStats=true was specified in the request this field will contain information about the document payload. + */ @Fluent public final class DocumentStatistics implements JsonSerializable { /* @@ -24,12 +26,15 @@ public final class DocumentStatistics implements JsonSerializable { - DocumentStatistics deserializedDocumentStatistics = new DocumentStatistics(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + DocumentStatistics deserializedDocumentStatistics = new DocumentStatistics(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("charactersCount".equals(fieldName)) { - deserializedDocumentStatistics.charactersCount = reader.getInt(); - } else if ("transactionsCount".equals(fieldName)) { - deserializedDocumentStatistics.transactionsCount = reader.getInt(); - } else { - reader.skipChildren(); - } - } + if ("charactersCount".equals(fieldName)) { + deserializedDocumentStatistics.charactersCount = reader.getInt(); + } else if ("transactionsCount".equals(fieldName)) { + deserializedDocumentStatistics.transactionsCount = reader.getInt(); + } else { + reader.skipChildren(); + } + } - return deserializedDocumentStatistics; - }); + return deserializedDocumentStatistics; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentWarning.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentWarning.java index 8fb47fd1658b..0bf52c68bddd 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentWarning.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/DocumentWarning.java @@ -10,9 +10,10 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** The DocumentWarning model. */ +/** + * The DocumentWarning model. + */ @Fluent public final class DocumentWarning implements JsonSerializable { /* @@ -30,12 +31,15 @@ public final class DocumentWarning implements JsonSerializable */ private String targetRef; - /** Creates an instance of DocumentWarning class. */ - public DocumentWarning() {} + /** + * Creates an instance of DocumentWarning class. + */ + public DocumentWarning() { + } /** * Get the code property: Error code. - * + * * @return the code value. */ public WarningCodeValue getCode() { @@ -44,7 +48,7 @@ public WarningCodeValue getCode() { /** * Set the code property: Error code. - * + * * @param code the code value to set. * @return the DocumentWarning object itself. */ @@ -55,7 +59,7 @@ public DocumentWarning setCode(WarningCodeValue code) { /** * Get the message property: Warning message. - * + * * @return the message value. */ public String getMessage() { @@ -64,7 +68,7 @@ public String getMessage() { /** * Set the message property: Warning message. - * + * * @param message the message value to set. * @return the DocumentWarning object itself. */ @@ -75,7 +79,7 @@ public DocumentWarning setMessage(String message) { /** * Get the targetRef property: A JSON pointer reference indicating the target object. - * + * * @return the targetRef value. */ public String getTargetRef() { @@ -84,7 +88,7 @@ public String getTargetRef() { /** * Set the targetRef property: A JSON pointer reference indicating the target object. - * + * * @param targetRef the targetRef value to set. * @return the DocumentWarning object itself. */ @@ -93,10 +97,13 @@ public DocumentWarning setTargetRef(String targetRef) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("code", Objects.toString(this.code, null)); + jsonWriter.writeStringField("code", this.code == null ? null : this.code.toString()); jsonWriter.writeStringField("message", this.message); jsonWriter.writeStringField("targetRef", this.targetRef); return jsonWriter.writeEndObject(); @@ -104,33 +111,32 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of DocumentWarning from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of DocumentWarning if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 DocumentWarning. */ public static DocumentWarning fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - DocumentWarning deserializedDocumentWarning = new DocumentWarning(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("code".equals(fieldName)) { - deserializedDocumentWarning.code = WarningCodeValue.fromString(reader.getString()); - } else if ("message".equals(fieldName)) { - deserializedDocumentWarning.message = reader.getString(); - } else if ("targetRef".equals(fieldName)) { - deserializedDocumentWarning.targetRef = reader.getString(); - } else { - reader.skipChildren(); - } - } - - return deserializedDocumentWarning; - }); + return jsonReader.readObject(reader -> { + DocumentWarning deserializedDocumentWarning = new DocumentWarning(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("code".equals(fieldName)) { + deserializedDocumentWarning.code = WarningCodeValue.fromString(reader.getString()); + } else if ("message".equals(fieldName)) { + deserializedDocumentWarning.message = reader.getString(); + } else if ("targetRef".equals(fieldName)) { + deserializedDocumentWarning.targetRef = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedDocumentWarning; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesDocumentResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesDocumentResult.java index 8182f811567e..4f6767953fea 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesDocumentResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesDocumentResult.java @@ -11,7 +11,9 @@ import java.io.IOException; import java.util.List; -/** The EntitiesDocumentResult model. */ +/** + * The EntitiesDocumentResult model. + */ @Fluent public class EntitiesDocumentResult extends DocumentResult { /* @@ -19,12 +21,15 @@ public class EntitiesDocumentResult extends DocumentResult { */ private List entities; - /** Creates an instance of EntitiesDocumentResult class. */ - public EntitiesDocumentResult() {} + /** + * Creates an instance of EntitiesDocumentResult class. + */ + public EntitiesDocumentResult() { + } /** * Get the entities property: Recognized entities in the document. - * + * * @return the entities value. */ public List getEntities() { @@ -33,7 +38,7 @@ public List getEntities() { /** * Set the entities property: Recognized entities in the document. - * + * * @param entities the entities value to set. * @return the EntitiesDocumentResult object itself. */ @@ -42,27 +47,36 @@ public EntitiesDocumentResult setEntities(List entities) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntitiesDocumentResult setId(String id) { super.setId(id); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntitiesDocumentResult setWarnings(List warnings) { super.setWarnings(warnings); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntitiesDocumentResult setStatistics(DocumentStatistics statistics) { super.setStatistics(statistics); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -75,38 +89,36 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of EntitiesDocumentResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of EntitiesDocumentResult if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. + * 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 EntitiesDocumentResult. */ public static EntitiesDocumentResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - EntitiesDocumentResult deserializedEntitiesDocumentResult = new EntitiesDocumentResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + EntitiesDocumentResult deserializedEntitiesDocumentResult = new EntitiesDocumentResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("id".equals(fieldName)) { - deserializedEntitiesDocumentResult.setId(reader.getString()); - } else if ("warnings".equals(fieldName)) { - List warnings = - reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); - deserializedEntitiesDocumentResult.setWarnings(warnings); - } else if ("statistics".equals(fieldName)) { - deserializedEntitiesDocumentResult.setStatistics(DocumentStatistics.fromJson(reader)); - } else if ("entities".equals(fieldName)) { - List entities = reader.readArray(reader1 -> Entity.fromJson(reader1)); - deserializedEntitiesDocumentResult.entities = entities; - } else { - reader.skipChildren(); - } - } + if ("id".equals(fieldName)) { + deserializedEntitiesDocumentResult.setId(reader.getString()); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedEntitiesDocumentResult.setWarnings(warnings); + } else if ("statistics".equals(fieldName)) { + deserializedEntitiesDocumentResult.setStatistics(DocumentStatistics.fromJson(reader)); + } else if ("entities".equals(fieldName)) { + List entities = reader.readArray(reader1 -> Entity.fromJson(reader1)); + deserializedEntitiesDocumentResult.entities = entities; + } else { + reader.skipChildren(); + } + } - return deserializedEntitiesDocumentResult; - }); + return deserializedEntitiesDocumentResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesLROTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesLROTask.java index 5f1b0b5ea1b0..51c20057c62a 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesLROTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesLROTask.java @@ -9,22 +9,41 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** An object representing the task definition for an Entities Recognition task. */ +/** + * An object representing the task definition for an Entities Recognition task. + */ @Fluent public final class EntitiesLROTask extends AnalyzeTextLROTask { + /* + * Enumeration of supported long-running Text Analysis tasks. + */ + private AnalyzeTextLROTaskKind kind = AnalyzeTextLROTaskKind.ENTITY_RECOGNITION; + /* * Supported parameters for an Entity Recognition task. */ private EntitiesTaskParameters parameters; - /** Creates an instance of EntitiesLROTask class. */ - public EntitiesLROTask() {} + /** + * Creates an instance of EntitiesLROTask class. + */ + public EntitiesLROTask() { + } + + /** + * Get the kind property: Enumeration of supported long-running Text Analysis tasks. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROTaskKind getKind() { + return this.kind; + } /** * Get the parameters property: Supported parameters for an Entity Recognition task. - * + * * @return the parameters value. */ public EntitiesTaskParameters getParameters() { @@ -33,7 +52,7 @@ public EntitiesTaskParameters getParameters() { /** * Set the parameters property: Supported parameters for an Entity Recognition task. - * + * * @param parameters the parameters value to set. * @return the EntitiesLROTask object itself. */ @@ -42,57 +61,54 @@ public EntitiesLROTask setParameters(EntitiesTaskParameters parameters) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntitiesLROTask setTaskName(String taskName) { super.setTaskName(taskName); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("kind", Objects.toString(AnalyzeTextLROTaskKind.ENTITY_RECOGNITION, null)); jsonWriter.writeStringField("taskName", getTaskName()); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); jsonWriter.writeJsonField("parameters", this.parameters); return jsonWriter.writeEndObject(); } /** * Reads an instance of EntitiesLROTask from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of EntitiesLROTask 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 the polymorphic discriminator. + * pointing to JSON null. * @throws IOException If an error occurs while reading the EntitiesLROTask. */ public static EntitiesLROTask fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - EntitiesLROTask deserializedEntitiesLROTask = new EntitiesLROTask(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + EntitiesLROTask deserializedEntitiesLROTask = new EntitiesLROTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"EntityRecognition".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'EntityRecognition'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("taskName".equals(fieldName)) { - deserializedEntitiesLROTask.setTaskName(reader.getString()); - } else if ("parameters".equals(fieldName)) { - deserializedEntitiesLROTask.parameters = EntitiesTaskParameters.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("taskName".equals(fieldName)) { + deserializedEntitiesLROTask.setTaskName(reader.getString()); + } else if ("kind".equals(fieldName)) { + deserializedEntitiesLROTask.kind = AnalyzeTextLROTaskKind.fromString(reader.getString()); + } else if ("parameters".equals(fieldName)) { + deserializedEntitiesLROTask.parameters = EntitiesTaskParameters.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedEntitiesLROTask; - }); + return deserializedEntitiesLROTask; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesResult.java index 70e4c17622d8..f3a59e2cdfa8 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesResult.java @@ -11,7 +11,9 @@ import java.io.IOException; import java.util.List; -/** The EntitiesResult model. */ +/** + * The EntitiesResult model. + */ @Fluent public final class EntitiesResult extends PreBuiltResult { /* @@ -19,12 +21,15 @@ public final class EntitiesResult extends PreBuiltResult { */ private List documents; - /** Creates an instance of EntitiesResult class. */ - public EntitiesResult() {} + /** + * Creates an instance of EntitiesResult class. + */ + public EntitiesResult() { + } /** * Get the documents property: Response by document. - * + * * @return the documents value. */ public List getDocuments() { @@ -33,7 +38,7 @@ public List getDocuments() { /** * Set the documents property: Response by document. - * + * * @param documents the documents value to set. * @return the EntitiesResult object itself. */ @@ -42,27 +47,36 @@ public EntitiesResult setDocuments(List documents) return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntitiesResult setErrors(List errors) { super.setErrors(errors); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntitiesResult setStatistics(RequestStatistics statistics) { super.setStatistics(statistics); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntitiesResult setModelVersion(String modelVersion) { super.setModelVersion(modelVersion); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -75,38 +89,37 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of EntitiesResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of EntitiesResult if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 EntitiesResult. */ public static EntitiesResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - EntitiesResult deserializedEntitiesResult = new EntitiesResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + EntitiesResult deserializedEntitiesResult = new EntitiesResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("errors".equals(fieldName)) { - List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); - deserializedEntitiesResult.setErrors(errors); - } else if ("modelVersion".equals(fieldName)) { - deserializedEntitiesResult.setModelVersion(reader.getString()); - } else if ("statistics".equals(fieldName)) { - deserializedEntitiesResult.setStatistics(RequestStatistics.fromJson(reader)); - } else if ("documents".equals(fieldName)) { - List documents = - reader.readArray(reader1 -> EntitiesResultDocumentsItem.fromJson(reader1)); - deserializedEntitiesResult.documents = documents; - } else { - reader.skipChildren(); - } - } + if ("errors".equals(fieldName)) { + List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); + deserializedEntitiesResult.setErrors(errors); + } else if ("modelVersion".equals(fieldName)) { + deserializedEntitiesResult.setModelVersion(reader.getString()); + } else if ("statistics".equals(fieldName)) { + deserializedEntitiesResult.setStatistics(RequestStatistics.fromJson(reader)); + } else if ("documents".equals(fieldName)) { + List documents + = reader.readArray(reader1 -> EntitiesResultDocumentsItem.fromJson(reader1)); + deserializedEntitiesResult.documents = documents; + } else { + reader.skipChildren(); + } + } - return deserializedEntitiesResult; - }); + return deserializedEntitiesResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesResultDocumentsItem.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesResultDocumentsItem.java index 6512fcf1f089..84fcd5288885 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesResultDocumentsItem.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesResultDocumentsItem.java @@ -11,40 +11,56 @@ import java.io.IOException; import java.util.List; -/** The EntitiesResultDocumentsItem model. */ +/** + * The EntitiesResultDocumentsItem model. + */ @Fluent public final class EntitiesResultDocumentsItem extends EntitiesDocumentResult { - /** Creates an instance of EntitiesResultDocumentsItem class. */ - public EntitiesResultDocumentsItem() {} + /** + * Creates an instance of EntitiesResultDocumentsItem class. + */ + public EntitiesResultDocumentsItem() { + } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntitiesResultDocumentsItem setEntities(List entities) { super.setEntities(entities); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntitiesResultDocumentsItem setId(String id) { super.setId(id); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntitiesResultDocumentsItem setWarnings(List warnings) { super.setWarnings(warnings); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntitiesResultDocumentsItem setStatistics(DocumentStatistics statistics) { super.setStatistics(statistics); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -57,39 +73,36 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of EntitiesResultDocumentsItem from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of EntitiesResultDocumentsItem if the JsonReader was pointing to an instance of it, or null - * if it was pointing to JSON 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 EntitiesResultDocumentsItem. */ public static EntitiesResultDocumentsItem fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - EntitiesResultDocumentsItem deserializedEntitiesResultDocumentsItem = - new EntitiesResultDocumentsItem(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + EntitiesResultDocumentsItem deserializedEntitiesResultDocumentsItem = new EntitiesResultDocumentsItem(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("id".equals(fieldName)) { - deserializedEntitiesResultDocumentsItem.setId(reader.getString()); - } else if ("warnings".equals(fieldName)) { - List warnings = - reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); - deserializedEntitiesResultDocumentsItem.setWarnings(warnings); - } else if ("entities".equals(fieldName)) { - List entities = reader.readArray(reader1 -> Entity.fromJson(reader1)); - deserializedEntitiesResultDocumentsItem.setEntities(entities); - } else if ("statistics".equals(fieldName)) { - deserializedEntitiesResultDocumentsItem.setStatistics(DocumentStatistics.fromJson(reader)); - } else { - reader.skipChildren(); - } - } + if ("id".equals(fieldName)) { + deserializedEntitiesResultDocumentsItem.setId(reader.getString()); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedEntitiesResultDocumentsItem.setWarnings(warnings); + } else if ("entities".equals(fieldName)) { + List entities = reader.readArray(reader1 -> Entity.fromJson(reader1)); + deserializedEntitiesResultDocumentsItem.setEntities(entities); + } else if ("statistics".equals(fieldName)) { + deserializedEntitiesResultDocumentsItem.setStatistics(DocumentStatistics.fromJson(reader)); + } else { + reader.skipChildren(); + } + } - return deserializedEntitiesResultDocumentsItem; - }); + return deserializedEntitiesResultDocumentsItem; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesTask.java index 7124f4a69c0d..0a161e9cebe4 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesTask.java @@ -1,25 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 EntitiesTask model. */ @Fluent -public final class EntitiesTask { +public final class EntitiesTask implements JsonSerializable { /* * The parameters property. */ - @JsonProperty(value = "parameters") private EntitiesTaskParameters parameters; /* * The taskName property. */ - @JsonProperty(value = "taskName") private String taskName; /** @@ -61,4 +63,44 @@ public EntitiesTask setTaskName(String taskName) { this.taskName = taskName; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("parameters", parameters); + jsonWriter.writeStringField("taskName", this.taskName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EntitiesTask from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EntitiesTask 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 EntitiesTask. + */ + public static EntitiesTask fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EntitiesTask deserializedEntitiesTask = new EntitiesTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("parameters".equals(fieldName)) { + deserializedEntitiesTask.parameters = EntitiesTaskParameters.fromJson(reader); + } else if ("taskName".equals(fieldName)) { + deserializedEntitiesTask.taskName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedEntitiesTask; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesTaskParameters.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesTaskParameters.java index 780d00b35269..010d3e1be445 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesTaskParameters.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesTaskParameters.java @@ -9,25 +9,28 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** Supported parameters for an Entity Recognition task. */ +/** + * Supported parameters for an Entity Recognition task. + */ @Fluent public final class EntitiesTaskParameters extends PreBuiltTaskParameters { /* - * Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to - * Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. + * Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. */ private StringIndexType stringIndexType; - /** Creates an instance of EntitiesTaskParameters class. */ - public EntitiesTaskParameters() {} + /** + * Creates an instance of EntitiesTaskParameters class. + */ + public EntitiesTaskParameters() { + } /** * Get the stringIndexType property: Specifies the method used to interpret string offsets. Defaults to Text * Elements (Graphemes) according to Unicode v8.0.0. For additional information see * https://aka.ms/text-analytics-offsets. - * + * * @return the stringIndexType value. */ public StringIndexType getStringIndexType() { @@ -38,7 +41,7 @@ public StringIndexType getStringIndexType() { * Set the stringIndexType property: Specifies the method used to interpret string offsets. Defaults to Text * Elements (Graphemes) according to Unicode v8.0.0. For additional information see * https://aka.ms/text-analytics-offsets. - * + * * @param stringIndexType the stringIndexType value to set. * @return the EntitiesTaskParameters object itself. */ @@ -47,59 +50,64 @@ public EntitiesTaskParameters setStringIndexType(StringIndexType stringIndexType return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntitiesTaskParameters setModelVersion(String modelVersion) { super.setModelVersion(modelVersion); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntitiesTaskParameters setLoggingOptOut(Boolean loggingOptOut) { super.setLoggingOptOut(loggingOptOut); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); jsonWriter.writeBooleanField("loggingOptOut", isLoggingOptOut()); jsonWriter.writeStringField("modelVersion", getModelVersion()); - jsonWriter.writeStringField("stringIndexType", Objects.toString(this.stringIndexType, null)); + jsonWriter.writeStringField("stringIndexType", + this.stringIndexType == null ? null : this.stringIndexType.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of EntitiesTaskParameters from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of EntitiesTaskParameters if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. + * was pointing to JSON null. * @throws IOException If an error occurs while reading the EntitiesTaskParameters. */ public static EntitiesTaskParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - EntitiesTaskParameters deserializedEntitiesTaskParameters = new EntitiesTaskParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + EntitiesTaskParameters deserializedEntitiesTaskParameters = new EntitiesTaskParameters(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("loggingOptOut".equals(fieldName)) { - deserializedEntitiesTaskParameters.setLoggingOptOut( - reader.getNullable(JsonReader::getBoolean)); - } else if ("modelVersion".equals(fieldName)) { - deserializedEntitiesTaskParameters.setModelVersion(reader.getString()); - } else if ("stringIndexType".equals(fieldName)) { - deserializedEntitiesTaskParameters.stringIndexType = - StringIndexType.fromString(reader.getString()); - } else { - reader.skipChildren(); - } - } + if ("loggingOptOut".equals(fieldName)) { + deserializedEntitiesTaskParameters.setLoggingOptOut(reader.getNullable(JsonReader::getBoolean)); + } else if ("modelVersion".equals(fieldName)) { + deserializedEntitiesTaskParameters.setModelVersion(reader.getString()); + } else if ("stringIndexType".equals(fieldName)) { + deserializedEntitiesTaskParameters.stringIndexType = StringIndexType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedEntitiesTaskParameters; - }); + return deserializedEntitiesTaskParameters; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesTaskResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesTaskResult.java index 552ef100e97f..698cfe15e50d 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesTaskResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntitiesTaskResult.java @@ -9,22 +9,41 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** The EntitiesTaskResult model. */ +/** + * The EntitiesTaskResult model. + */ @Fluent public final class EntitiesTaskResult extends AnalyzeTextTaskResult { + /* + * Enumeration of supported Text Analysis task results. + */ + private AnalyzeTextTaskResultsKind kind = AnalyzeTextTaskResultsKind.ENTITY_RECOGNITION_RESULTS; + /* * The results property. */ private EntitiesResult results; - /** Creates an instance of EntitiesTaskResult class. */ - public EntitiesTaskResult() {} + /** + * Creates an instance of EntitiesTaskResult class. + */ + public EntitiesTaskResult() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis task results. + * + * @return the kind value. + */ + @Override + public AnalyzeTextTaskResultsKind getKind() { + return this.kind; + } /** * Get the results property: The results property. - * + * * @return the results value. */ public EntitiesResult getResults() { @@ -33,7 +52,7 @@ public EntitiesResult getResults() { /** * Set the results property: The results property. - * + * * @param results the results value to set. * @return the EntitiesTaskResult object itself. */ @@ -42,49 +61,43 @@ public EntitiesTaskResult setResults(EntitiesResult results) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField( - "kind", Objects.toString(AnalyzeTextTaskResultsKind.ENTITY_RECOGNITION_RESULTS, null)); jsonWriter.writeJsonField("results", this.results); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of EntitiesTaskResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of EntitiesTaskResult 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 or the - * polymorphic discriminator. + * 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 EntitiesTaskResult. */ public static EntitiesTaskResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - EntitiesTaskResult deserializedEntitiesTaskResult = new EntitiesTaskResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + EntitiesTaskResult deserializedEntitiesTaskResult = new EntitiesTaskResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"EntityRecognitionResults".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'EntityRecognitionResults'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("results".equals(fieldName)) { - deserializedEntitiesTaskResult.results = EntitiesResult.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("results".equals(fieldName)) { + deserializedEntitiesTaskResult.results = EntitiesResult.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedEntitiesTaskResult.kind = AnalyzeTextTaskResultsKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedEntitiesTaskResult; - }); + return deserializedEntitiesTaskResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Entity.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Entity.java index 3fdea6570b14..44f1ae721322 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Entity.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Entity.java @@ -11,7 +11,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** The Entity model. */ +/** + * The Entity model. + */ @Fluent public final class Entity implements JsonSerializable { /* @@ -44,12 +46,15 @@ public final class Entity implements JsonSerializable { */ private double confidenceScore; - /** Creates an instance of Entity class. */ - public Entity() {} + /** + * Creates an instance of Entity class. + */ + public Entity() { + } /** * Get the text property: Entity text as appears in the request. - * + * * @return the text value. */ public String getText() { @@ -58,7 +63,7 @@ public String getText() { /** * Set the text property: Entity text as appears in the request. - * + * * @param text the text value to set. * @return the Entity object itself. */ @@ -69,7 +74,7 @@ public Entity setText(String text) { /** * Get the category property: Entity type. - * + * * @return the category value. */ public String getCategory() { @@ -78,7 +83,7 @@ public String getCategory() { /** * Set the category property: Entity type. - * + * * @param category the category value to set. * @return the Entity object itself. */ @@ -89,7 +94,7 @@ public Entity setCategory(String category) { /** * Get the subcategory property: (Optional) Entity sub type. - * + * * @return the subcategory value. */ public String getSubcategory() { @@ -98,7 +103,7 @@ public String getSubcategory() { /** * Set the subcategory property: (Optional) Entity sub type. - * + * * @param subcategory the subcategory value to set. * @return the Entity object itself. */ @@ -110,7 +115,7 @@ public Entity setSubcategory(String subcategory) { /** * Get the offset property: Start position for the entity text. Use of different 'stringIndexType' values can affect * the offset returned. - * + * * @return the offset value. */ public int getOffset() { @@ -120,7 +125,7 @@ public int getOffset() { /** * Set the offset property: Start position for the entity text. Use of different 'stringIndexType' values can affect * the offset returned. - * + * * @param offset the offset value to set. * @return the Entity object itself. */ @@ -132,7 +137,7 @@ public Entity setOffset(int offset) { /** * Get the length property: Length for the entity text. Use of different 'stringIndexType' values can affect the * length returned. - * + * * @return the length value. */ public int getLength() { @@ -142,7 +147,7 @@ public int getLength() { /** * Set the length property: Length for the entity text. Use of different 'stringIndexType' values can affect the * length returned. - * + * * @param length the length value to set. * @return the Entity object itself. */ @@ -153,7 +158,7 @@ public Entity setLength(int length) { /** * Get the confidenceScore property: Confidence score between 0 and 1 of the extracted entity. - * + * * @return the confidenceScore value. */ public double getConfidenceScore() { @@ -162,7 +167,7 @@ public double getConfidenceScore() { /** * Set the confidenceScore property: Confidence score between 0 and 1 of the extracted entity. - * + * * @param confidenceScore the confidenceScore value to set. * @return the Entity object itself. */ @@ -171,6 +176,9 @@ public Entity setConfidenceScore(double confidenceScore) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -185,39 +193,38 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of Entity from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of Entity if the JsonReader was pointing to an instance of it, or null if it was pointing to - * JSON null. + * JSON null. * @throws IllegalStateException If the deserialized JSON object was missing any required properties. * @throws IOException If an error occurs while reading the Entity. */ public static Entity fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - Entity deserializedEntity = new Entity(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("text".equals(fieldName)) { - deserializedEntity.text = reader.getString(); - } else if ("category".equals(fieldName)) { - deserializedEntity.category = reader.getString(); - } else if ("offset".equals(fieldName)) { - deserializedEntity.offset = reader.getInt(); - } else if ("length".equals(fieldName)) { - deserializedEntity.length = reader.getInt(); - } else if ("confidenceScore".equals(fieldName)) { - deserializedEntity.confidenceScore = reader.getDouble(); - } else if ("subcategory".equals(fieldName)) { - deserializedEntity.subcategory = reader.getString(); - } else { - reader.skipChildren(); - } - } - - return deserializedEntity; - }); + return jsonReader.readObject(reader -> { + Entity deserializedEntity = new Entity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("text".equals(fieldName)) { + deserializedEntity.text = reader.getString(); + } else if ("category".equals(fieldName)) { + deserializedEntity.category = reader.getString(); + } else if ("offset".equals(fieldName)) { + deserializedEntity.offset = reader.getInt(); + } else if ("length".equals(fieldName)) { + deserializedEntity.length = reader.getInt(); + } else if ("confidenceScore".equals(fieldName)) { + deserializedEntity.confidenceScore = reader.getDouble(); + } else if ("subcategory".equals(fieldName)) { + deserializedEntity.subcategory = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedEntity; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingLROResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingLROResult.java index 7690a5ebf665..7a02825f608b 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingLROResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingLROResult.java @@ -10,22 +10,42 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.time.OffsetDateTime; -import java.util.Objects; +import java.time.format.DateTimeFormatter; -/** The EntityLinkingLROResult model. */ +/** + * The EntityLinkingLROResult model. + */ @Fluent public final class EntityLinkingLROResult extends AnalyzeTextLROResult { + /* + * Enumeration of supported Text Analysis long-running operation task results. + */ + private AnalyzeTextLROResultsKind kind = AnalyzeTextLROResultsKind.ENTITY_LINKING_LRORESULTS; + /* * The results property. */ private EntityLinkingResult results; - /** Creates an instance of EntityLinkingLROResult class. */ - public EntityLinkingLROResult() {} + /** + * Creates an instance of EntityLinkingLROResult class. + */ + public EntityLinkingLROResult() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis long-running operation task results. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROResultsKind getKind() { + return this.kind; + } /** * Get the results property: The results property. - * + * * @return the results value. */ public EntityLinkingResult getResults() { @@ -34,7 +54,7 @@ public EntityLinkingResult getResults() { /** * Set the results property: The results property. - * + * * @param results the results value to set. * @return the EntityLinkingLROResult object itself. */ @@ -43,81 +63,83 @@ public EntityLinkingLROResult setResults(EntityLinkingResult results) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntityLinkingLROResult setTaskName(String taskName) { super.setTaskName(taskName); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntityLinkingLROResult setLastUpdateDateTime(OffsetDateTime lastUpdateDateTime) { super.setLastUpdateDateTime(lastUpdateDateTime); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntityLinkingLROResult setStatus(State status) { super.setStatus(status); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField( - "kind", Objects.toString(AnalyzeTextLROResultsKind.ENTITY_LINKING_LRORESULTS, null)); - jsonWriter.writeStringField("lastUpdateDateTime", Objects.toString(getLastUpdateDateTime(), null)); - jsonWriter.writeStringField("status", Objects.toString(getStatus(), null)); + jsonWriter.writeStringField("lastUpdateDateTime", + getLastUpdateDateTime() == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(getLastUpdateDateTime())); + jsonWriter.writeStringField("status", getStatus() == null ? null : getStatus().toString()); jsonWriter.writeStringField("taskName", getTaskName()); jsonWriter.writeJsonField("results", this.results); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of EntityLinkingLROResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of EntityLinkingLROResult 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 or the - * polymorphic discriminator. + * 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 EntityLinkingLROResult. */ public static EntityLinkingLROResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - EntityLinkingLROResult deserializedEntityLinkingLROResult = new EntityLinkingLROResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + EntityLinkingLROResult deserializedEntityLinkingLROResult = new EntityLinkingLROResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"EntityLinkingLROResults".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'EntityLinkingLROResults'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("lastUpdateDateTime".equals(fieldName)) { - deserializedEntityLinkingLROResult.setLastUpdateDateTime( - reader.getNullable( - nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); - } else if ("status".equals(fieldName)) { - deserializedEntityLinkingLROResult.setStatus(State.fromString(reader.getString())); - } else if ("taskName".equals(fieldName)) { - deserializedEntityLinkingLROResult.setTaskName(reader.getString()); - } else if ("results".equals(fieldName)) { - deserializedEntityLinkingLROResult.results = EntityLinkingResult.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("lastUpdateDateTime".equals(fieldName)) { + deserializedEntityLinkingLROResult.setLastUpdateDateTime( + reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); + } else if ("status".equals(fieldName)) { + deserializedEntityLinkingLROResult.setStatus(State.fromString(reader.getString())); + } else if ("taskName".equals(fieldName)) { + deserializedEntityLinkingLROResult.setTaskName(reader.getString()); + } else if ("results".equals(fieldName)) { + deserializedEntityLinkingLROResult.results = EntityLinkingResult.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedEntityLinkingLROResult.kind = AnalyzeTextLROResultsKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedEntityLinkingLROResult; - }); + return deserializedEntityLinkingLROResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingLROTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingLROTask.java index 288eb042e884..0bb03ec7bec8 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingLROTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingLROTask.java @@ -9,22 +9,41 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** An object representing the task definition for an Entity Linking task. */ +/** + * An object representing the task definition for an Entity Linking task. + */ @Fluent public final class EntityLinkingLROTask extends AnalyzeTextLROTask { + /* + * Enumeration of supported long-running Text Analysis tasks. + */ + private AnalyzeTextLROTaskKind kind = AnalyzeTextLROTaskKind.ENTITY_LINKING; + /* * Supported parameters for an Entity Linking task. */ private EntityLinkingTaskParameters parameters; - /** Creates an instance of EntityLinkingLROTask class. */ - public EntityLinkingLROTask() {} + /** + * Creates an instance of EntityLinkingLROTask class. + */ + public EntityLinkingLROTask() { + } + + /** + * Get the kind property: Enumeration of supported long-running Text Analysis tasks. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROTaskKind getKind() { + return this.kind; + } /** * Get the parameters property: Supported parameters for an Entity Linking task. - * + * * @return the parameters value. */ public EntityLinkingTaskParameters getParameters() { @@ -33,7 +52,7 @@ public EntityLinkingTaskParameters getParameters() { /** * Set the parameters property: Supported parameters for an Entity Linking task. - * + * * @param parameters the parameters value to set. * @return the EntityLinkingLROTask object itself. */ @@ -42,57 +61,54 @@ public EntityLinkingLROTask setParameters(EntityLinkingTaskParameters parameters return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntityLinkingLROTask setTaskName(String taskName) { super.setTaskName(taskName); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("kind", Objects.toString(AnalyzeTextLROTaskKind.ENTITY_LINKING, null)); jsonWriter.writeStringField("taskName", getTaskName()); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); jsonWriter.writeJsonField("parameters", this.parameters); return jsonWriter.writeEndObject(); } /** * Reads an instance of EntityLinkingLROTask from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of EntityLinkingLROTask 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 the polymorphic discriminator. + * was pointing to JSON null. * @throws IOException If an error occurs while reading the EntityLinkingLROTask. */ public static EntityLinkingLROTask fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - EntityLinkingLROTask deserializedEntityLinkingLROTask = new EntityLinkingLROTask(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + EntityLinkingLROTask deserializedEntityLinkingLROTask = new EntityLinkingLROTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"EntityLinking".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'EntityLinking'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("taskName".equals(fieldName)) { - deserializedEntityLinkingLROTask.setTaskName(reader.getString()); - } else if ("parameters".equals(fieldName)) { - deserializedEntityLinkingLROTask.parameters = EntityLinkingTaskParameters.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("taskName".equals(fieldName)) { + deserializedEntityLinkingLROTask.setTaskName(reader.getString()); + } else if ("kind".equals(fieldName)) { + deserializedEntityLinkingLROTask.kind = AnalyzeTextLROTaskKind.fromString(reader.getString()); + } else if ("parameters".equals(fieldName)) { + deserializedEntityLinkingLROTask.parameters = EntityLinkingTaskParameters.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedEntityLinkingLROTask; - }); + return deserializedEntityLinkingLROTask; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingResult.java index a4b60b854fc7..46ea685464b5 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingResult.java @@ -11,7 +11,9 @@ import java.io.IOException; import java.util.List; -/** The EntityLinkingResult model. */ +/** + * The EntityLinkingResult model. + */ @Fluent public final class EntityLinkingResult extends PreBuiltResult { /* @@ -19,12 +21,15 @@ public final class EntityLinkingResult extends PreBuiltResult { */ private List documents; - /** Creates an instance of EntityLinkingResult class. */ - public EntityLinkingResult() {} + /** + * Creates an instance of EntityLinkingResult class. + */ + public EntityLinkingResult() { + } /** * Get the documents property: Response by document. - * + * * @return the documents value. */ public List getDocuments() { @@ -33,7 +38,7 @@ public List getDocuments() { /** * Set the documents property: Response by document. - * + * * @param documents the documents value to set. * @return the EntityLinkingResult object itself. */ @@ -42,27 +47,36 @@ public EntityLinkingResult setDocuments(List d return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntityLinkingResult setErrors(List errors) { super.setErrors(errors); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntityLinkingResult setStatistics(RequestStatistics statistics) { super.setStatistics(statistics); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntityLinkingResult setModelVersion(String modelVersion) { super.setModelVersion(modelVersion); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -75,38 +89,37 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of EntityLinkingResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of EntityLinkingResult if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 EntityLinkingResult. */ public static EntityLinkingResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - EntityLinkingResult deserializedEntityLinkingResult = new EntityLinkingResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + EntityLinkingResult deserializedEntityLinkingResult = new EntityLinkingResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("errors".equals(fieldName)) { - List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); - deserializedEntityLinkingResult.setErrors(errors); - } else if ("modelVersion".equals(fieldName)) { - deserializedEntityLinkingResult.setModelVersion(reader.getString()); - } else if ("statistics".equals(fieldName)) { - deserializedEntityLinkingResult.setStatistics(RequestStatistics.fromJson(reader)); - } else if ("documents".equals(fieldName)) { - List documents = - reader.readArray(reader1 -> EntityLinkingResultDocumentsItem.fromJson(reader1)); - deserializedEntityLinkingResult.documents = documents; - } else { - reader.skipChildren(); - } - } + if ("errors".equals(fieldName)) { + List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); + deserializedEntityLinkingResult.setErrors(errors); + } else if ("modelVersion".equals(fieldName)) { + deserializedEntityLinkingResult.setModelVersion(reader.getString()); + } else if ("statistics".equals(fieldName)) { + deserializedEntityLinkingResult.setStatistics(RequestStatistics.fromJson(reader)); + } else if ("documents".equals(fieldName)) { + List documents + = reader.readArray(reader1 -> EntityLinkingResultDocumentsItem.fromJson(reader1)); + deserializedEntityLinkingResult.documents = documents; + } else { + reader.skipChildren(); + } + } - return deserializedEntityLinkingResult; - }); + return deserializedEntityLinkingResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingResultDocumentsItem.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingResultDocumentsItem.java index 0a6663699d58..d923b67f943a 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingResultDocumentsItem.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingResultDocumentsItem.java @@ -11,40 +11,56 @@ import java.io.IOException; import java.util.List; -/** The EntityLinkingResultDocumentsItem model. */ +/** + * The EntityLinkingResultDocumentsItem model. + */ @Fluent public final class EntityLinkingResultDocumentsItem extends LinkedEntitiesDocumentResult { - /** Creates an instance of EntityLinkingResultDocumentsItem class. */ - public EntityLinkingResultDocumentsItem() {} + /** + * Creates an instance of EntityLinkingResultDocumentsItem class. + */ + public EntityLinkingResultDocumentsItem() { + } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntityLinkingResultDocumentsItem setEntities(List entities) { super.setEntities(entities); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntityLinkingResultDocumentsItem setId(String id) { super.setId(id); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntityLinkingResultDocumentsItem setWarnings(List warnings) { super.setWarnings(warnings); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntityLinkingResultDocumentsItem setStatistics(DocumentStatistics statistics) { super.setStatistics(statistics); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -57,40 +73,37 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of EntityLinkingResultDocumentsItem from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of EntityLinkingResultDocumentsItem if the JsonReader was pointing to an instance of it, or - * null if it was pointing to JSON null. + * 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 EntityLinkingResultDocumentsItem. */ public static EntityLinkingResultDocumentsItem fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - EntityLinkingResultDocumentsItem deserializedEntityLinkingResultDocumentsItem = - new EntityLinkingResultDocumentsItem(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + EntityLinkingResultDocumentsItem deserializedEntityLinkingResultDocumentsItem + = new EntityLinkingResultDocumentsItem(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("id".equals(fieldName)) { - deserializedEntityLinkingResultDocumentsItem.setId(reader.getString()); - } else if ("warnings".equals(fieldName)) { - List warnings = - reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); - deserializedEntityLinkingResultDocumentsItem.setWarnings(warnings); - } else if ("entities".equals(fieldName)) { - List entities = reader.readArray(reader1 -> LinkedEntity.fromJson(reader1)); - deserializedEntityLinkingResultDocumentsItem.setEntities(entities); - } else if ("statistics".equals(fieldName)) { - deserializedEntityLinkingResultDocumentsItem.setStatistics( - DocumentStatistics.fromJson(reader)); - } else { - reader.skipChildren(); - } - } + if ("id".equals(fieldName)) { + deserializedEntityLinkingResultDocumentsItem.setId(reader.getString()); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedEntityLinkingResultDocumentsItem.setWarnings(warnings); + } else if ("entities".equals(fieldName)) { + List entities = reader.readArray(reader1 -> LinkedEntity.fromJson(reader1)); + deserializedEntityLinkingResultDocumentsItem.setEntities(entities); + } else if ("statistics".equals(fieldName)) { + deserializedEntityLinkingResultDocumentsItem.setStatistics(DocumentStatistics.fromJson(reader)); + } else { + reader.skipChildren(); + } + } - return deserializedEntityLinkingResultDocumentsItem; - }); + return deserializedEntityLinkingResultDocumentsItem; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingTask.java index 6d53a046c831..79a34b5ba636 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingTask.java @@ -1,25 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 EntityLinkingTask model. */ @Fluent -public final class EntityLinkingTask { +public final class EntityLinkingTask implements JsonSerializable { /* * The parameters property. */ - @JsonProperty(value = "parameters") private EntityLinkingTaskParameters parameters; /* * The taskName property. */ - @JsonProperty(value = "taskName") private String taskName; /** @@ -61,4 +63,44 @@ public EntityLinkingTask setTaskName(String taskName) { this.taskName = taskName; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("parameters", parameters); + jsonWriter.writeStringField("taskName", this.taskName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EntityLinkingTask from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EntityLinkingTask 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 EntityLinkingTask. + */ + public static EntityLinkingTask fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EntityLinkingTask deserializedEntityLinkingTask = new EntityLinkingTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("parameters".equals(fieldName)) { + deserializedEntityLinkingTask.parameters = EntityLinkingTaskParameters.fromJson(reader); + } else if ("taskName".equals(fieldName)) { + deserializedEntityLinkingTask.taskName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedEntityLinkingTask; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingTaskParameters.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingTaskParameters.java index feeeda379b0a..40856d76eb08 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingTaskParameters.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingTaskParameters.java @@ -9,25 +9,28 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** Supported parameters for an Entity Linking task. */ +/** + * Supported parameters for an Entity Linking task. + */ @Fluent public final class EntityLinkingTaskParameters extends PreBuiltTaskParameters { /* - * Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to - * Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. + * Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. */ private StringIndexType stringIndexType; - /** Creates an instance of EntityLinkingTaskParameters class. */ - public EntityLinkingTaskParameters() {} + /** + * Creates an instance of EntityLinkingTaskParameters class. + */ + public EntityLinkingTaskParameters() { + } /** * Get the stringIndexType property: Specifies the method used to interpret string offsets. Defaults to Text * Elements (Graphemes) according to Unicode v8.0.0. For additional information see * https://aka.ms/text-analytics-offsets. - * + * * @return the stringIndexType value. */ public StringIndexType getStringIndexType() { @@ -38,7 +41,7 @@ public StringIndexType getStringIndexType() { * Set the stringIndexType property: Specifies the method used to interpret string offsets. Defaults to Text * Elements (Graphemes) according to Unicode v8.0.0. For additional information see * https://aka.ms/text-analytics-offsets. - * + * * @param stringIndexType the stringIndexType value to set. * @return the EntityLinkingTaskParameters object itself. */ @@ -47,60 +50,66 @@ public EntityLinkingTaskParameters setStringIndexType(StringIndexType stringInde return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntityLinkingTaskParameters setModelVersion(String modelVersion) { super.setModelVersion(modelVersion); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntityLinkingTaskParameters setLoggingOptOut(Boolean loggingOptOut) { super.setLoggingOptOut(loggingOptOut); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); jsonWriter.writeBooleanField("loggingOptOut", isLoggingOptOut()); jsonWriter.writeStringField("modelVersion", getModelVersion()); - jsonWriter.writeStringField("stringIndexType", Objects.toString(this.stringIndexType, null)); + jsonWriter.writeStringField("stringIndexType", + this.stringIndexType == null ? null : this.stringIndexType.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of EntityLinkingTaskParameters from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of EntityLinkingTaskParameters if the JsonReader was pointing to an instance of it, or null - * if it was pointing to JSON null. + * if it was pointing to JSON null. * @throws IOException If an error occurs while reading the EntityLinkingTaskParameters. */ public static EntityLinkingTaskParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - EntityLinkingTaskParameters deserializedEntityLinkingTaskParameters = - new EntityLinkingTaskParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + EntityLinkingTaskParameters deserializedEntityLinkingTaskParameters = new EntityLinkingTaskParameters(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("loggingOptOut".equals(fieldName)) { - deserializedEntityLinkingTaskParameters.setLoggingOptOut( - reader.getNullable(JsonReader::getBoolean)); - } else if ("modelVersion".equals(fieldName)) { - deserializedEntityLinkingTaskParameters.setModelVersion(reader.getString()); - } else if ("stringIndexType".equals(fieldName)) { - deserializedEntityLinkingTaskParameters.stringIndexType = - StringIndexType.fromString(reader.getString()); - } else { - reader.skipChildren(); - } - } + if ("loggingOptOut".equals(fieldName)) { + deserializedEntityLinkingTaskParameters + .setLoggingOptOut(reader.getNullable(JsonReader::getBoolean)); + } else if ("modelVersion".equals(fieldName)) { + deserializedEntityLinkingTaskParameters.setModelVersion(reader.getString()); + } else if ("stringIndexType".equals(fieldName)) { + deserializedEntityLinkingTaskParameters.stringIndexType + = StringIndexType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedEntityLinkingTaskParameters; - }); + return deserializedEntityLinkingTaskParameters; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingTaskResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingTaskResult.java index 8851e30fb63e..352c71d291bb 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingTaskResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityLinkingTaskResult.java @@ -9,22 +9,41 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** The EntityLinkingTaskResult model. */ +/** + * The EntityLinkingTaskResult model. + */ @Fluent public final class EntityLinkingTaskResult extends AnalyzeTextTaskResult { + /* + * Enumeration of supported Text Analysis task results. + */ + private AnalyzeTextTaskResultsKind kind = AnalyzeTextTaskResultsKind.ENTITY_LINKING_RESULTS; + /* * The results property. */ private EntityLinkingResult results; - /** Creates an instance of EntityLinkingTaskResult class. */ - public EntityLinkingTaskResult() {} + /** + * Creates an instance of EntityLinkingTaskResult class. + */ + public EntityLinkingTaskResult() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis task results. + * + * @return the kind value. + */ + @Override + public AnalyzeTextTaskResultsKind getKind() { + return this.kind; + } /** * Get the results property: The results property. - * + * * @return the results value. */ public EntityLinkingResult getResults() { @@ -33,7 +52,7 @@ public EntityLinkingResult getResults() { /** * Set the results property: The results property. - * + * * @param results the results value to set. * @return the EntityLinkingTaskResult object itself. */ @@ -42,48 +61,44 @@ public EntityLinkingTaskResult setResults(EntityLinkingResult results) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("kind", Objects.toString(AnalyzeTextTaskResultsKind.ENTITY_LINKING_RESULTS, null)); jsonWriter.writeJsonField("results", this.results); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of EntityLinkingTaskResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of EntityLinkingTaskResult 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 or the - * polymorphic discriminator. + * 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 EntityLinkingTaskResult. */ public static EntityLinkingTaskResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - EntityLinkingTaskResult deserializedEntityLinkingTaskResult = new EntityLinkingTaskResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + EntityLinkingTaskResult deserializedEntityLinkingTaskResult = new EntityLinkingTaskResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"EntityLinkingResults".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'EntityLinkingResults'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("results".equals(fieldName)) { - deserializedEntityLinkingTaskResult.results = EntityLinkingResult.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("results".equals(fieldName)) { + deserializedEntityLinkingTaskResult.results = EntityLinkingResult.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedEntityLinkingTaskResult.kind + = AnalyzeTextTaskResultsKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedEntityLinkingTaskResult; - }); + return deserializedEntityLinkingTaskResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityRecognitionLROResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityRecognitionLROResult.java index 3e3bd5c312bd..1b6d3e8d5b6c 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityRecognitionLROResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/EntityRecognitionLROResult.java @@ -10,22 +10,42 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.time.OffsetDateTime; -import java.util.Objects; +import java.time.format.DateTimeFormatter; -/** The EntityRecognitionLROResult model. */ +/** + * The EntityRecognitionLROResult model. + */ @Fluent public final class EntityRecognitionLROResult extends AnalyzeTextLROResult { + /* + * Enumeration of supported Text Analysis long-running operation task results. + */ + private AnalyzeTextLROResultsKind kind = AnalyzeTextLROResultsKind.ENTITY_RECOGNITION_LRORESULTS; + /* * The results property. */ private EntitiesResult results; - /** Creates an instance of EntityRecognitionLROResult class. */ - public EntityRecognitionLROResult() {} + /** + * Creates an instance of EntityRecognitionLROResult class. + */ + public EntityRecognitionLROResult() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis long-running operation task results. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROResultsKind getKind() { + return this.kind; + } /** * Get the results property: The results property. - * + * * @return the results value. */ public EntitiesResult getResults() { @@ -34,7 +54,7 @@ public EntitiesResult getResults() { /** * Set the results property: The results property. - * + * * @param results the results value to set. * @return the EntityRecognitionLROResult object itself. */ @@ -43,82 +63,84 @@ public EntityRecognitionLROResult setResults(EntitiesResult results) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntityRecognitionLROResult setTaskName(String taskName) { super.setTaskName(taskName); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntityRecognitionLROResult setLastUpdateDateTime(OffsetDateTime lastUpdateDateTime) { super.setLastUpdateDateTime(lastUpdateDateTime); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public EntityRecognitionLROResult setStatus(State status) { super.setStatus(status); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField( - "kind", Objects.toString(AnalyzeTextLROResultsKind.ENTITY_RECOGNITION_LRORESULTS, null)); - jsonWriter.writeStringField("lastUpdateDateTime", Objects.toString(getLastUpdateDateTime(), null)); - jsonWriter.writeStringField("status", Objects.toString(getStatus(), null)); + jsonWriter.writeStringField("lastUpdateDateTime", + getLastUpdateDateTime() == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(getLastUpdateDateTime())); + jsonWriter.writeStringField("status", getStatus() == null ? null : getStatus().toString()); jsonWriter.writeStringField("taskName", getTaskName()); jsonWriter.writeJsonField("results", this.results); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of EntityRecognitionLROResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of EntityRecognitionLROResult 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 or the - * polymorphic discriminator. + * 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 EntityRecognitionLROResult. */ public static EntityRecognitionLROResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - EntityRecognitionLROResult deserializedEntityRecognitionLROResult = - new EntityRecognitionLROResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + EntityRecognitionLROResult deserializedEntityRecognitionLROResult = new EntityRecognitionLROResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"EntityRecognitionLROResults".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'EntityRecognitionLROResults'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("lastUpdateDateTime".equals(fieldName)) { - deserializedEntityRecognitionLROResult.setLastUpdateDateTime( - reader.getNullable( - nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); - } else if ("status".equals(fieldName)) { - deserializedEntityRecognitionLROResult.setStatus(State.fromString(reader.getString())); - } else if ("taskName".equals(fieldName)) { - deserializedEntityRecognitionLROResult.setTaskName(reader.getString()); - } else if ("results".equals(fieldName)) { - deserializedEntityRecognitionLROResult.results = EntitiesResult.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("lastUpdateDateTime".equals(fieldName)) { + deserializedEntityRecognitionLROResult.setLastUpdateDateTime( + reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); + } else if ("status".equals(fieldName)) { + deserializedEntityRecognitionLROResult.setStatus(State.fromString(reader.getString())); + } else if ("taskName".equals(fieldName)) { + deserializedEntityRecognitionLROResult.setTaskName(reader.getString()); + } else if ("results".equals(fieldName)) { + deserializedEntityRecognitionLROResult.results = EntitiesResult.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedEntityRecognitionLROResult.kind + = AnalyzeTextLROResultsKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedEntityRecognitionLROResult; - }); + return deserializedEntityRecognitionLROResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Error.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Error.java index 0c8258ab05c7..633bc0ff2976 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Error.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Error.java @@ -13,9 +13,10 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Objects; -/** The error object. */ +/** + * The error object. + */ @Fluent public final class Error implements JsonSerializable { /* @@ -48,12 +49,15 @@ public final class Error implements JsonSerializable { */ private Map additionalProperties; - /** Creates an instance of Error class. */ - public Error() {} + /** + * Creates an instance of Error class. + */ + public Error() { + } /** * Get the code property: One of a server-defined set of error codes. - * + * * @return the code value. */ public ErrorCode getCode() { @@ -62,7 +66,7 @@ public ErrorCode getCode() { /** * Set the code property: One of a server-defined set of error codes. - * + * * @param code the code value to set. * @return the Error object itself. */ @@ -73,7 +77,7 @@ public Error setCode(ErrorCode code) { /** * Get the message property: A human-readable representation of the error. - * + * * @return the message value. */ public String getMessage() { @@ -82,7 +86,7 @@ public String getMessage() { /** * Set the message property: A human-readable representation of the error. - * + * * @param message the message value to set. * @return the Error object itself. */ @@ -93,7 +97,7 @@ public Error setMessage(String message) { /** * Get the target property: The target of the error. - * + * * @return the target value. */ public String getTarget() { @@ -102,7 +106,7 @@ public String getTarget() { /** * Set the target property: The target of the error. - * + * * @param target the target value to set. * @return the Error object itself. */ @@ -113,7 +117,7 @@ public Error setTarget(String target) { /** * Get the details property: An array of details about specific errors that led to this reported error. - * + * * @return the details value. */ public List getDetails() { @@ -122,7 +126,7 @@ public List getDetails() { /** * Set the details property: An array of details about specific errors that led to this reported error. - * + * * @param details the details value to set. * @return the Error object itself. */ @@ -134,7 +138,7 @@ public Error setDetails(List details) { /** * Get the innererror property: An object containing more specific information than the current object about the * error. - * + * * @return the innererror value. */ public InnerErrorModel getInnererror() { @@ -144,7 +148,7 @@ public InnerErrorModel getInnererror() { /** * Set the innererror property: An object containing more specific information than the current object about the * error. - * + * * @param innererror the innererror value to set. * @return the Error object itself. */ @@ -155,7 +159,7 @@ public Error setInnererror(InnerErrorModel innererror) { /** * Get the additionalProperties property: The error object. - * + * * @return the additionalProperties value. */ public Map getAdditionalProperties() { @@ -164,7 +168,7 @@ public Map getAdditionalProperties() { /** * Set the additionalProperties property: The error object. - * + * * @param additionalProperties the additionalProperties value to set. * @return the Error object itself. */ @@ -173,10 +177,13 @@ public Error setAdditionalProperties(Map additionalProperties) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("code", Objects.toString(this.code, null)); + jsonWriter.writeStringField("code", this.code == null ? null : this.code.toString()); jsonWriter.writeStringField("message", this.message); jsonWriter.writeStringField("target", this.target); jsonWriter.writeArrayField("details", this.details, (writer, element) -> writer.writeJson(element)); @@ -191,44 +198,43 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of Error from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of Error if the JsonReader was pointing to an instance of it, or null if it was pointing to - * JSON null. + * JSON null. * @throws IllegalStateException If the deserialized JSON object was missing any required properties. * @throws IOException If an error occurs while reading the Error. */ public static Error fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - Error deserializedError = new Error(); - Map additionalProperties = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("code".equals(fieldName)) { - deserializedError.code = ErrorCode.fromString(reader.getString()); - } else if ("message".equals(fieldName)) { - deserializedError.message = reader.getString(); - } else if ("target".equals(fieldName)) { - deserializedError.target = reader.getString(); - } else if ("details".equals(fieldName)) { - List details = reader.readArray(reader1 -> Error.fromJson(reader1)); - deserializedError.details = details; - } else if ("innererror".equals(fieldName)) { - deserializedError.innererror = InnerErrorModel.fromJson(reader); - } else { - if (additionalProperties == null) { - additionalProperties = new LinkedHashMap<>(); - } - - additionalProperties.put(fieldName, reader.readUntyped()); - } + return jsonReader.readObject(reader -> { + Error deserializedError = new Error(); + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("code".equals(fieldName)) { + deserializedError.code = ErrorCode.fromString(reader.getString()); + } else if ("message".equals(fieldName)) { + deserializedError.message = reader.getString(); + } else if ("target".equals(fieldName)) { + deserializedError.target = reader.getString(); + } else if ("details".equals(fieldName)) { + List details = reader.readArray(reader1 -> Error.fromJson(reader1)); + deserializedError.details = details; + } else if ("innererror".equals(fieldName)) { + deserializedError.innererror = InnerErrorModel.fromJson(reader); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); } - deserializedError.additionalProperties = additionalProperties; - return deserializedError; - }); + additionalProperties.put(fieldName, reader.readUntyped()); + } + } + deserializedError.additionalProperties = additionalProperties; + + return deserializedError; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ErrorCode.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ErrorCode.java index 21cba5c7b03f..a7429a39ce6e 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ErrorCode.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ErrorCode.java @@ -7,75 +7,114 @@ import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; -/** Human-readable error code. */ +/** + * Human-readable error code. + */ public final class ErrorCode extends ExpandableStringEnum { - /** Static value InvalidRequest for ErrorCode. */ + /** + * Static value InvalidRequest for ErrorCode. + */ public static final ErrorCode INVALID_REQUEST = fromString("InvalidRequest"); - /** Static value InvalidArgument for ErrorCode. */ + /** + * Static value InvalidArgument for ErrorCode. + */ public static final ErrorCode INVALID_ARGUMENT = fromString("InvalidArgument"); - /** Static value Unauthorized for ErrorCode. */ + /** + * Static value Unauthorized for ErrorCode. + */ public static final ErrorCode UNAUTHORIZED = fromString("Unauthorized"); - /** Static value Forbidden for ErrorCode. */ + /** + * Static value Forbidden for ErrorCode. + */ public static final ErrorCode FORBIDDEN = fromString("Forbidden"); - /** Static value NotFound for ErrorCode. */ + /** + * Static value NotFound for ErrorCode. + */ public static final ErrorCode NOT_FOUND = fromString("NotFound"); - /** Static value ProjectNotFound for ErrorCode. */ + /** + * Static value ProjectNotFound for ErrorCode. + */ public static final ErrorCode PROJECT_NOT_FOUND = fromString("ProjectNotFound"); - /** Static value OperationNotFound for ErrorCode. */ + /** + * Static value OperationNotFound for ErrorCode. + */ public static final ErrorCode OPERATION_NOT_FOUND = fromString("OperationNotFound"); - /** Static value AzureCognitiveSearchNotFound for ErrorCode. */ + /** + * Static value AzureCognitiveSearchNotFound for ErrorCode. + */ public static final ErrorCode AZURE_COGNITIVE_SEARCH_NOT_FOUND = fromString("AzureCognitiveSearchNotFound"); - /** Static value AzureCognitiveSearchIndexNotFound for ErrorCode. */ - public static final ErrorCode AZURE_COGNITIVE_SEARCH_INDEX_NOT_FOUND = - fromString("AzureCognitiveSearchIndexNotFound"); + /** + * Static value AzureCognitiveSearchIndexNotFound for ErrorCode. + */ + public static final ErrorCode AZURE_COGNITIVE_SEARCH_INDEX_NOT_FOUND + = fromString("AzureCognitiveSearchIndexNotFound"); - /** Static value TooManyRequests for ErrorCode. */ + /** + * Static value TooManyRequests for ErrorCode. + */ public static final ErrorCode TOO_MANY_REQUESTS = fromString("TooManyRequests"); - /** Static value AzureCognitiveSearchThrottling for ErrorCode. */ + /** + * Static value AzureCognitiveSearchThrottling for ErrorCode. + */ public static final ErrorCode AZURE_COGNITIVE_SEARCH_THROTTLING = fromString("AzureCognitiveSearchThrottling"); - /** Static value AzureCognitiveSearchIndexLimitReached for ErrorCode. */ - public static final ErrorCode AZURE_COGNITIVE_SEARCH_INDEX_LIMIT_REACHED = - fromString("AzureCognitiveSearchIndexLimitReached"); + /** + * Static value AzureCognitiveSearchIndexLimitReached for ErrorCode. + */ + public static final ErrorCode AZURE_COGNITIVE_SEARCH_INDEX_LIMIT_REACHED + = fromString("AzureCognitiveSearchIndexLimitReached"); - /** Static value InternalServerError for ErrorCode. */ + /** + * Static value InternalServerError for ErrorCode. + */ public static final ErrorCode INTERNAL_SERVER_ERROR = fromString("InternalServerError"); - /** Static value ServiceUnavailable for ErrorCode. */ + /** + * Static value ServiceUnavailable for ErrorCode. + */ public static final ErrorCode SERVICE_UNAVAILABLE = fromString("ServiceUnavailable"); - /** Static value Timeout for ErrorCode. */ + /** + * Static value Timeout for ErrorCode. + */ public static final ErrorCode TIMEOUT = fromString("Timeout"); - /** Static value QuotaExceeded for ErrorCode. */ + /** + * Static value QuotaExceeded for ErrorCode. + */ public static final ErrorCode QUOTA_EXCEEDED = fromString("QuotaExceeded"); - /** Static value Conflict for ErrorCode. */ + /** + * Static value Conflict for ErrorCode. + */ public static final ErrorCode CONFLICT = fromString("Conflict"); - /** Static value Warning for ErrorCode. */ + /** + * Static value Warning for ErrorCode. + */ public static final ErrorCode WARNING = fromString("Warning"); /** * Creates a new instance of ErrorCode value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated - public ErrorCode() {} + public ErrorCode() { + } /** * Creates or finds a ErrorCode from its string representation. - * + * * @param name a name to look for. * @return the corresponding ErrorCode. */ @@ -85,7 +124,7 @@ public static ErrorCode fromString(String name) { /** * Gets known ErrorCode values. - * + * * @return known ErrorCode values. */ public static Collection values() { diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ErrorResponse.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ErrorResponse.java index aaf4be608d23..261ad0014bd2 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ErrorResponse.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ErrorResponse.java @@ -11,7 +11,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** Error response. */ +/** + * Error response. + */ @Fluent public final class ErrorResponse implements JsonSerializable { /* @@ -19,12 +21,15 @@ public final class ErrorResponse implements JsonSerializable { */ private Error error; - /** Creates an instance of ErrorResponse class. */ - public ErrorResponse() {} + /** + * Creates an instance of ErrorResponse class. + */ + public ErrorResponse() { + } /** * Get the error property: The error object. - * + * * @return the error value. */ public Error getError() { @@ -33,7 +38,7 @@ public Error getError() { /** * Set the error property: The error object. - * + * * @param error the error value to set. * @return the ErrorResponse object itself. */ @@ -42,6 +47,9 @@ public ErrorResponse setError(Error error) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -51,29 +59,28 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of ErrorResponse from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of ErrorResponse if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 ErrorResponse. */ public static ErrorResponse fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - ErrorResponse deserializedErrorResponse = new ErrorResponse(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + ErrorResponse deserializedErrorResponse = new ErrorResponse(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("error".equals(fieldName)) { - deserializedErrorResponse.error = Error.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("error".equals(fieldName)) { + deserializedErrorResponse.error = Error.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedErrorResponse; - }); + return deserializedErrorResponse; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ErrorResponseException.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ErrorResponseException.java index 63d8c99e31b2..9dac4cd67a14 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ErrorResponseException.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ErrorResponseException.java @@ -7,11 +7,13 @@ import com.azure.core.exception.HttpResponseException; import com.azure.core.http.HttpResponse; -/** Exception thrown for an invalid response with ErrorResponse information. */ +/** + * Exception thrown for an invalid response with ErrorResponse information. + */ public final class ErrorResponseException extends HttpResponseException { /** * Initializes a new instance of the ErrorResponseException class. - * + * * @param message the exception message or the response content if a message is not available. * @param response the HTTP response. */ @@ -21,7 +23,7 @@ public ErrorResponseException(String message, HttpResponse response) { /** * Initializes a new instance of the ErrorResponseException class. - * + * * @param message the exception message or the response content if a message is not available. * @param response the HTTP response. * @param value the deserialized response value. @@ -30,7 +32,9 @@ public ErrorResponseException(String message, HttpResponse response, ErrorRespon super(message, response, value); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public ErrorResponse getValue() { return (ErrorResponse) super.getValue(); diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractedSummaryDocumentResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractedSummaryDocumentResult.java index 2b6467110cff..5d68e6a84489 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractedSummaryDocumentResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractedSummaryDocumentResult.java @@ -11,7 +11,9 @@ import java.io.IOException; import java.util.List; -/** The ExtractedSummaryDocumentResult model. */ +/** + * The ExtractedSummaryDocumentResult model. + */ @Fluent public final class ExtractedSummaryDocumentResult extends DocumentResult { /* @@ -19,12 +21,15 @@ public final class ExtractedSummaryDocumentResult extends DocumentResult { */ private List sentences; - /** Creates an instance of ExtractedSummaryDocumentResult class. */ - public ExtractedSummaryDocumentResult() {} + /** + * Creates an instance of ExtractedSummaryDocumentResult class. + */ + public ExtractedSummaryDocumentResult() { + } /** * Get the sentences property: A ranked list of sentences representing the extracted summary. - * + * * @return the sentences value. */ public List getSentences() { @@ -33,7 +38,7 @@ public List getSentences() { /** * Set the sentences property: A ranked list of sentences representing the extracted summary. - * + * * @param sentences the sentences value to set. * @return the ExtractedSummaryDocumentResult object itself. */ @@ -42,27 +47,36 @@ public ExtractedSummaryDocumentResult setSentences(List warnings) { super.setWarnings(warnings); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public ExtractedSummaryDocumentResult setStatistics(DocumentStatistics statistics) { super.setStatistics(statistics); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -75,41 +89,38 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of ExtractedSummaryDocumentResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of ExtractedSummaryDocumentResult if the JsonReader was pointing to an instance of it, or - * null if it was pointing to JSON null. + * 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 ExtractedSummaryDocumentResult. */ public static ExtractedSummaryDocumentResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - ExtractedSummaryDocumentResult deserializedExtractedSummaryDocumentResult = - new ExtractedSummaryDocumentResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + ExtractedSummaryDocumentResult deserializedExtractedSummaryDocumentResult + = new ExtractedSummaryDocumentResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("id".equals(fieldName)) { - deserializedExtractedSummaryDocumentResult.setId(reader.getString()); - } else if ("warnings".equals(fieldName)) { - List warnings = - reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); - deserializedExtractedSummaryDocumentResult.setWarnings(warnings); - } else if ("statistics".equals(fieldName)) { - deserializedExtractedSummaryDocumentResult.setStatistics( - DocumentStatistics.fromJson(reader)); - } else if ("sentences".equals(fieldName)) { - List sentences = - reader.readArray(reader1 -> ExtractedSummarySentence.fromJson(reader1)); - deserializedExtractedSummaryDocumentResult.sentences = sentences; - } else { - reader.skipChildren(); - } - } + if ("id".equals(fieldName)) { + deserializedExtractedSummaryDocumentResult.setId(reader.getString()); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedExtractedSummaryDocumentResult.setWarnings(warnings); + } else if ("statistics".equals(fieldName)) { + deserializedExtractedSummaryDocumentResult.setStatistics(DocumentStatistics.fromJson(reader)); + } else if ("sentences".equals(fieldName)) { + List sentences + = reader.readArray(reader1 -> ExtractedSummarySentence.fromJson(reader1)); + deserializedExtractedSummaryDocumentResult.sentences = sentences; + } else { + reader.skipChildren(); + } + } - return deserializedExtractedSummaryDocumentResult; - }); + return deserializedExtractedSummaryDocumentResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractedSummarySentence.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractedSummarySentence.java index f7438602a41d..35835f24d5b8 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractedSummarySentence.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractedSummarySentence.java @@ -11,7 +11,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** The ExtractedSummarySentence model. */ +/** + * The ExtractedSummarySentence model. + */ @Fluent public final class ExtractedSummarySentence implements JsonSerializable { /* @@ -20,8 +22,7 @@ public final class ExtractedSummarySentence implements JsonSerializable { - ExtractedSummarySentence deserializedExtractedSummarySentence = new ExtractedSummarySentence(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("text".equals(fieldName)) { - deserializedExtractedSummarySentence.text = reader.getString(); - } else if ("rankScore".equals(fieldName)) { - deserializedExtractedSummarySentence.rankScore = reader.getDouble(); - } else if ("offset".equals(fieldName)) { - deserializedExtractedSummarySentence.offset = reader.getInt(); - } else if ("length".equals(fieldName)) { - deserializedExtractedSummarySentence.length = reader.getInt(); - } else { - reader.skipChildren(); - } - } - - return deserializedExtractedSummarySentence; - }); + return jsonReader.readObject(reader -> { + ExtractedSummarySentence deserializedExtractedSummarySentence = new ExtractedSummarySentence(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("text".equals(fieldName)) { + deserializedExtractedSummarySentence.text = reader.getString(); + } else if ("rankScore".equals(fieldName)) { + deserializedExtractedSummarySentence.rankScore = reader.getDouble(); + } else if ("offset".equals(fieldName)) { + deserializedExtractedSummarySentence.offset = reader.getInt(); + } else if ("length".equals(fieldName)) { + deserializedExtractedSummarySentence.length = reader.getInt(); + } else { + reader.skipChildren(); + } + } + + return deserializedExtractedSummarySentence; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractiveSummarizationLROResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractiveSummarizationLROResult.java index 3dd2a7cb2d8f..a912ce1d19f6 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractiveSummarizationLROResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractiveSummarizationLROResult.java @@ -10,22 +10,42 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.time.OffsetDateTime; -import java.util.Objects; +import java.time.format.DateTimeFormatter; -/** The ExtractiveSummarizationLROResult model. */ +/** + * The ExtractiveSummarizationLROResult model. + */ @Fluent public final class ExtractiveSummarizationLROResult extends AnalyzeTextLROResult { + /* + * Enumeration of supported Text Analysis long-running operation task results. + */ + private AnalyzeTextLROResultsKind kind = AnalyzeTextLROResultsKind.EXTRACTIVE_SUMMARIZATION_LRORESULTS; + /* * The results property. */ private ExtractiveSummarizationResult results; - /** Creates an instance of ExtractiveSummarizationLROResult class. */ - public ExtractiveSummarizationLROResult() {} + /** + * Creates an instance of ExtractiveSummarizationLROResult class. + */ + public ExtractiveSummarizationLROResult() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis long-running operation task results. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROResultsKind getKind() { + return this.kind; + } /** * Get the results property: The results property. - * + * * @return the results value. */ public ExtractiveSummarizationResult getResults() { @@ -34,7 +54,7 @@ public ExtractiveSummarizationResult getResults() { /** * Set the results property: The results property. - * + * * @param results the results value to set. * @return the ExtractiveSummarizationLROResult object itself. */ @@ -43,84 +63,86 @@ public ExtractiveSummarizationLROResult setResults(ExtractiveSummarizationResult return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public ExtractiveSummarizationLROResult setTaskName(String taskName) { super.setTaskName(taskName); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public ExtractiveSummarizationLROResult setLastUpdateDateTime(OffsetDateTime lastUpdateDateTime) { super.setLastUpdateDateTime(lastUpdateDateTime); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public ExtractiveSummarizationLROResult setStatus(State status) { super.setStatus(status); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField( - "kind", Objects.toString(AnalyzeTextLROResultsKind.EXTRACTIVE_SUMMARIZATION_LRORESULTS, null)); - jsonWriter.writeStringField("lastUpdateDateTime", Objects.toString(getLastUpdateDateTime(), null)); - jsonWriter.writeStringField("status", Objects.toString(getStatus(), null)); + jsonWriter.writeStringField("lastUpdateDateTime", + getLastUpdateDateTime() == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(getLastUpdateDateTime())); + jsonWriter.writeStringField("status", getStatus() == null ? null : getStatus().toString()); jsonWriter.writeStringField("taskName", getTaskName()); jsonWriter.writeJsonField("results", this.results); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of ExtractiveSummarizationLROResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of ExtractiveSummarizationLROResult 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 or the - * polymorphic discriminator. + * 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 ExtractiveSummarizationLROResult. */ public static ExtractiveSummarizationLROResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - ExtractiveSummarizationLROResult deserializedExtractiveSummarizationLROResult = - new ExtractiveSummarizationLROResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + ExtractiveSummarizationLROResult deserializedExtractiveSummarizationLROResult + = new ExtractiveSummarizationLROResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"ExtractiveSummarizationLROResults".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'ExtractiveSummarizationLROResults'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("lastUpdateDateTime".equals(fieldName)) { - deserializedExtractiveSummarizationLROResult.setLastUpdateDateTime( - reader.getNullable( - nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); - } else if ("status".equals(fieldName)) { - deserializedExtractiveSummarizationLROResult.setStatus( - State.fromString(reader.getString())); - } else if ("taskName".equals(fieldName)) { - deserializedExtractiveSummarizationLROResult.setTaskName(reader.getString()); - } else if ("results".equals(fieldName)) { - deserializedExtractiveSummarizationLROResult.results = - ExtractiveSummarizationResult.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("lastUpdateDateTime".equals(fieldName)) { + deserializedExtractiveSummarizationLROResult.setLastUpdateDateTime( + reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); + } else if ("status".equals(fieldName)) { + deserializedExtractiveSummarizationLROResult.setStatus(State.fromString(reader.getString())); + } else if ("taskName".equals(fieldName)) { + deserializedExtractiveSummarizationLROResult.setTaskName(reader.getString()); + } else if ("results".equals(fieldName)) { + deserializedExtractiveSummarizationLROResult.results + = ExtractiveSummarizationResult.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedExtractiveSummarizationLROResult.kind + = AnalyzeTextLROResultsKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedExtractiveSummarizationLROResult; - }); + return deserializedExtractiveSummarizationLROResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractiveSummarizationLROTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractiveSummarizationLROTask.java index 29b9fa9b344a..19fe1dd49c5b 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractiveSummarizationLROTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractiveSummarizationLROTask.java @@ -9,22 +9,41 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** An object representing the task definition for an Extractive Summarization task. */ +/** + * An object representing the task definition for an Extractive Summarization task. + */ @Fluent public final class ExtractiveSummarizationLROTask extends AnalyzeTextLROTask { + /* + * Enumeration of supported long-running Text Analysis tasks. + */ + private AnalyzeTextLROTaskKind kind = AnalyzeTextLROTaskKind.EXTRACTIVE_SUMMARIZATION; + /* * Supported parameters for an Extractive Summarization task. */ private ExtractiveSummarizationTaskParameters parameters; - /** Creates an instance of ExtractiveSummarizationLROTask class. */ - public ExtractiveSummarizationLROTask() {} + /** + * Creates an instance of ExtractiveSummarizationLROTask class. + */ + public ExtractiveSummarizationLROTask() { + } + + /** + * Get the kind property: Enumeration of supported long-running Text Analysis tasks. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROTaskKind getKind() { + return this.kind; + } /** * Get the parameters property: Supported parameters for an Extractive Summarization task. - * + * * @return the parameters value. */ public ExtractiveSummarizationTaskParameters getParameters() { @@ -33,7 +52,7 @@ public ExtractiveSummarizationTaskParameters getParameters() { /** * Set the parameters property: Supported parameters for an Extractive Summarization task. - * + * * @param parameters the parameters value to set. * @return the ExtractiveSummarizationLROTask object itself. */ @@ -42,59 +61,57 @@ public ExtractiveSummarizationLROTask setParameters(ExtractiveSummarizationTaskP return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public ExtractiveSummarizationLROTask setTaskName(String taskName) { super.setTaskName(taskName); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("kind", Objects.toString(AnalyzeTextLROTaskKind.EXTRACTIVE_SUMMARIZATION, null)); jsonWriter.writeStringField("taskName", getTaskName()); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); jsonWriter.writeJsonField("parameters", this.parameters); return jsonWriter.writeEndObject(); } /** * Reads an instance of ExtractiveSummarizationLROTask from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of ExtractiveSummarizationLROTask 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 the polymorphic discriminator. + * null if it was pointing to JSON null. * @throws IOException If an error occurs while reading the ExtractiveSummarizationLROTask. */ public static ExtractiveSummarizationLROTask fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - ExtractiveSummarizationLROTask deserializedExtractiveSummarizationLROTask = - new ExtractiveSummarizationLROTask(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + ExtractiveSummarizationLROTask deserializedExtractiveSummarizationLROTask + = new ExtractiveSummarizationLROTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"ExtractiveSummarization".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'ExtractiveSummarization'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("taskName".equals(fieldName)) { - deserializedExtractiveSummarizationLROTask.setTaskName(reader.getString()); - } else if ("parameters".equals(fieldName)) { - deserializedExtractiveSummarizationLROTask.parameters = - ExtractiveSummarizationTaskParameters.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("taskName".equals(fieldName)) { + deserializedExtractiveSummarizationLROTask.setTaskName(reader.getString()); + } else if ("kind".equals(fieldName)) { + deserializedExtractiveSummarizationLROTask.kind + = AnalyzeTextLROTaskKind.fromString(reader.getString()); + } else if ("parameters".equals(fieldName)) { + deserializedExtractiveSummarizationLROTask.parameters + = ExtractiveSummarizationTaskParameters.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedExtractiveSummarizationLROTask; - }); + return deserializedExtractiveSummarizationLROTask; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractiveSummarizationResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractiveSummarizationResult.java index 6600f7b65f96..6c85fdc3dd60 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractiveSummarizationResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractiveSummarizationResult.java @@ -11,7 +11,9 @@ import java.io.IOException; import java.util.List; -/** The ExtractiveSummarizationResult model. */ +/** + * The ExtractiveSummarizationResult model. + */ @Fluent public final class ExtractiveSummarizationResult extends PreBuiltResult { /* @@ -19,12 +21,15 @@ public final class ExtractiveSummarizationResult extends PreBuiltResult { */ private List documents; - /** Creates an instance of ExtractiveSummarizationResult class. */ - public ExtractiveSummarizationResult() {} + /** + * Creates an instance of ExtractiveSummarizationResult class. + */ + public ExtractiveSummarizationResult() { + } /** * Get the documents property: Response by document. - * + * * @return the documents value. */ public List getDocuments() { @@ -33,7 +38,7 @@ public List getDocuments() { /** * Set the documents property: Response by document. - * + * * @param documents the documents value to set. * @return the ExtractiveSummarizationResult object itself. */ @@ -42,27 +47,36 @@ public ExtractiveSummarizationResult setDocuments(List errors) { super.setErrors(errors); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public ExtractiveSummarizationResult setStatistics(RequestStatistics statistics) { super.setStatistics(statistics); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public ExtractiveSummarizationResult setModelVersion(String modelVersion) { super.setModelVersion(modelVersion); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -75,39 +89,38 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of ExtractiveSummarizationResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of ExtractiveSummarizationResult if the JsonReader was pointing to an instance of it, or null - * if it was pointing to JSON 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 ExtractiveSummarizationResult. */ public static ExtractiveSummarizationResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - ExtractiveSummarizationResult deserializedExtractiveSummarizationResult = - new ExtractiveSummarizationResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + ExtractiveSummarizationResult deserializedExtractiveSummarizationResult + = new ExtractiveSummarizationResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("errors".equals(fieldName)) { - List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); - deserializedExtractiveSummarizationResult.setErrors(errors); - } else if ("modelVersion".equals(fieldName)) { - deserializedExtractiveSummarizationResult.setModelVersion(reader.getString()); - } else if ("statistics".equals(fieldName)) { - deserializedExtractiveSummarizationResult.setStatistics(RequestStatistics.fromJson(reader)); - } else if ("documents".equals(fieldName)) { - List documents = - reader.readArray(reader1 -> ExtractedSummaryDocumentResult.fromJson(reader1)); - deserializedExtractiveSummarizationResult.documents = documents; - } else { - reader.skipChildren(); - } - } + if ("errors".equals(fieldName)) { + List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); + deserializedExtractiveSummarizationResult.setErrors(errors); + } else if ("modelVersion".equals(fieldName)) { + deserializedExtractiveSummarizationResult.setModelVersion(reader.getString()); + } else if ("statistics".equals(fieldName)) { + deserializedExtractiveSummarizationResult.setStatistics(RequestStatistics.fromJson(reader)); + } else if ("documents".equals(fieldName)) { + List documents + = reader.readArray(reader1 -> ExtractedSummaryDocumentResult.fromJson(reader1)); + deserializedExtractiveSummarizationResult.documents = documents; + } else { + reader.skipChildren(); + } + } - return deserializedExtractiveSummarizationResult; - }); + return deserializedExtractiveSummarizationResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractiveSummarizationTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractiveSummarizationTask.java index 27472cb117ce..264421526588 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractiveSummarizationTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractiveSummarizationTask.java @@ -1,25 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 ExtractiveSummarizationTask model. */ @Fluent -public final class ExtractiveSummarizationTask { +public final class ExtractiveSummarizationTask implements JsonSerializable { /* * The parameters property. */ - @JsonProperty(value = "parameters") private ExtractiveSummarizationTaskParameters parameters; /* * The taskName property. */ - @JsonProperty(value = "taskName") private String taskName; /** @@ -61,4 +63,44 @@ public ExtractiveSummarizationTask setTaskName(String taskName) { this.taskName = taskName; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("parameters", parameters); + jsonWriter.writeStringField("taskName", this.taskName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExtractiveSummarizationTask from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExtractiveSummarizationTask 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 ExtractiveSummarizationTask. + */ + public static ExtractiveSummarizationTask fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ExtractiveSummarizationTask deserializedExtractiveSummarizationTask = new ExtractiveSummarizationTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("parameters".equals(fieldName)) { + deserializedExtractiveSummarizationTask.parameters = ExtractiveSummarizationTaskParameters.fromJson(reader); + } else if ("taskName".equals(fieldName)) { + deserializedExtractiveSummarizationTask.taskName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedExtractiveSummarizationTask; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractiveSummarizationTaskParameters.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractiveSummarizationTaskParameters.java index 80673832add7..b5e64d8fcd3c 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractiveSummarizationTaskParameters.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/ExtractiveSummarizationTaskParameters.java @@ -10,9 +10,10 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** Supported parameters for an Extractive Summarization task. */ +/** + * Supported parameters for an Extractive Summarization task. + */ @Fluent public final class ExtractiveSummarizationTaskParameters extends PreBuiltTaskParameters { /* @@ -26,17 +27,19 @@ public final class ExtractiveSummarizationTaskParameters extends PreBuiltTaskPar private ExtractiveSummarySentencesOrder sortBy; /* - * Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to - * Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. + * Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. */ private StringIndexType stringIndexType; - /** Creates an instance of ExtractiveSummarizationTaskParameters class. */ - public ExtractiveSummarizationTaskParameters() {} + /** + * Creates an instance of ExtractiveSummarizationTaskParameters class. + */ + public ExtractiveSummarizationTaskParameters() { + } /** * Get the sentenceCount property: The sentenceCount property. - * + * * @return the sentenceCount value. */ public Integer getSentenceCount() { @@ -45,7 +48,7 @@ public Integer getSentenceCount() { /** * Set the sentenceCount property: The sentenceCount property. - * + * * @param sentenceCount the sentenceCount value to set. * @return the ExtractiveSummarizationTaskParameters object itself. */ @@ -56,7 +59,7 @@ public ExtractiveSummarizationTaskParameters setSentenceCount(Integer sentenceCo /** * Get the sortBy property: The sorting criteria to use for the results of Extractive Summarization. - * + * * @return the sortBy value. */ public ExtractiveSummarySentencesOrder getSortBy() { @@ -65,7 +68,7 @@ public ExtractiveSummarySentencesOrder getSortBy() { /** * Set the sortBy property: The sorting criteria to use for the results of Extractive Summarization. - * + * * @param sortBy the sortBy value to set. * @return the ExtractiveSummarizationTaskParameters object itself. */ @@ -78,7 +81,7 @@ public ExtractiveSummarizationTaskParameters setSortBy(ExtractiveSummarySentence * Get the stringIndexType property: Specifies the method used to interpret string offsets. Defaults to Text * Elements (Graphemes) according to Unicode v8.0.0. For additional information see * https://aka.ms/text-analytics-offsets. - * + * * @return the stringIndexType value. */ public StringIndexType getStringIndexType() { @@ -89,7 +92,7 @@ public StringIndexType getStringIndexType() { * Set the stringIndexType property: Specifies the method used to interpret string offsets. Defaults to Text * Elements (Graphemes) according to Unicode v8.0.0. For additional information see * https://aka.ms/text-analytics-offsets. - * + * * @param stringIndexType the stringIndexType value to set. * @return the ExtractiveSummarizationTaskParameters object itself. */ @@ -98,68 +101,75 @@ public ExtractiveSummarizationTaskParameters setStringIndexType(StringIndexType return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public ExtractiveSummarizationTaskParameters setModelVersion(String modelVersion) { super.setModelVersion(modelVersion); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public ExtractiveSummarizationTaskParameters setLoggingOptOut(Boolean loggingOptOut) { super.setLoggingOptOut(loggingOptOut); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); jsonWriter.writeBooleanField("loggingOptOut", isLoggingOptOut()); jsonWriter.writeStringField("modelVersion", getModelVersion()); jsonWriter.writeNumberField("sentenceCount", this.sentenceCount); - jsonWriter.writeStringField("sortBy", Objects.toString(this.sortBy, null)); - jsonWriter.writeStringField("stringIndexType", Objects.toString(this.stringIndexType, null)); + jsonWriter.writeStringField("sortBy", this.sortBy == null ? null : this.sortBy.toString()); + jsonWriter.writeStringField("stringIndexType", + this.stringIndexType == null ? null : this.stringIndexType.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of ExtractiveSummarizationTaskParameters from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of ExtractiveSummarizationTaskParameters if the JsonReader was pointing to an instance of it, - * or null if it was pointing to JSON null. + * or null if it was pointing to JSON null. * @throws IOException If an error occurs while reading the ExtractiveSummarizationTaskParameters. */ public static ExtractiveSummarizationTaskParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - ExtractiveSummarizationTaskParameters deserializedExtractiveSummarizationTaskParameters = - new ExtractiveSummarizationTaskParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("loggingOptOut".equals(fieldName)) { - deserializedExtractiveSummarizationTaskParameters.setLoggingOptOut( - reader.getNullable(JsonReader::getBoolean)); - } else if ("modelVersion".equals(fieldName)) { - deserializedExtractiveSummarizationTaskParameters.setModelVersion(reader.getString()); - } else if ("sentenceCount".equals(fieldName)) { - deserializedExtractiveSummarizationTaskParameters.sentenceCount = - reader.getNullable(JsonReader::getInt); - } else if ("sortBy".equals(fieldName)) { - deserializedExtractiveSummarizationTaskParameters.sortBy = - ExtractiveSummarySentencesOrder.fromString(reader.getString()); - } else if ("stringIndexType".equals(fieldName)) { - deserializedExtractiveSummarizationTaskParameters.stringIndexType = - StringIndexType.fromString(reader.getString()); - } else { - reader.skipChildren(); - } - } - - return deserializedExtractiveSummarizationTaskParameters; - }); + return jsonReader.readObject(reader -> { + ExtractiveSummarizationTaskParameters deserializedExtractiveSummarizationTaskParameters + = new ExtractiveSummarizationTaskParameters(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("loggingOptOut".equals(fieldName)) { + deserializedExtractiveSummarizationTaskParameters + .setLoggingOptOut(reader.getNullable(JsonReader::getBoolean)); + } else if ("modelVersion".equals(fieldName)) { + deserializedExtractiveSummarizationTaskParameters.setModelVersion(reader.getString()); + } else if ("sentenceCount".equals(fieldName)) { + deserializedExtractiveSummarizationTaskParameters.sentenceCount + = reader.getNullable(JsonReader::getInt); + } else if ("sortBy".equals(fieldName)) { + deserializedExtractiveSummarizationTaskParameters.sortBy + = ExtractiveSummarySentencesOrder.fromString(reader.getString()); + } else if ("stringIndexType".equals(fieldName)) { + deserializedExtractiveSummarizationTaskParameters.stringIndexType + = StringIndexType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedExtractiveSummarizationTaskParameters; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthHeaders.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthHeaders.java index 72d92ae5ee7d..700e666d85c2 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthHeaders.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthHeaders.java @@ -1,19 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 HealthHeaders model. */ @Fluent -public final class HealthHeaders { +public final class HealthHeaders implements JsonSerializable { /* * The Operation-Location property. */ - @JsonProperty(value = "Operation-Location") private String operationLocation; /** @@ -35,4 +38,39 @@ public HealthHeaders setOperationLocation(String operationLocation) { this.operationLocation = operationLocation; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("Operation-Location", this.operationLocation); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of HealthHeaders from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of HealthHeaders 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 HealthHeaders. + */ + public static HealthHeaders fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + HealthHeaders deserializedHealthHeaders = new HealthHeaders(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("Operation-Location".equals(fieldName)) { + deserializedHealthHeaders.operationLocation = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedHealthHeaders; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareAssertion.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareAssertion.java index 8a247f3a2d34..e1195b9ed33b 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareAssertion.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareAssertion.java @@ -10,9 +10,10 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** The HealthcareAssertion model. */ +/** + * The HealthcareAssertion model. + */ @Fluent public final class HealthcareAssertion implements JsonSerializable { /* @@ -30,12 +31,15 @@ public final class HealthcareAssertion implements JsonSerializable { - HealthcareAssertion deserializedHealthcareAssertion = new HealthcareAssertion(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("conditionality".equals(fieldName)) { - deserializedHealthcareAssertion.conditionality = - Conditionality.fromString(reader.getString()); - } else if ("certainty".equals(fieldName)) { - deserializedHealthcareAssertion.certainty = Certainty.fromString(reader.getString()); - } else if ("association".equals(fieldName)) { - deserializedHealthcareAssertion.association = Association.fromString(reader.getString()); - } else { - reader.skipChildren(); - } - } - - return deserializedHealthcareAssertion; - }); + return jsonReader.readObject(reader -> { + HealthcareAssertion deserializedHealthcareAssertion = new HealthcareAssertion(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("conditionality".equals(fieldName)) { + deserializedHealthcareAssertion.conditionality = Conditionality.fromString(reader.getString()); + } else if ("certainty".equals(fieldName)) { + deserializedHealthcareAssertion.certainty = Certainty.fromString(reader.getString()); + } else if ("association".equals(fieldName)) { + deserializedHealthcareAssertion.association = Association.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedHealthcareAssertion; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareEntitiesDocumentResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareEntitiesDocumentResult.java index 4815e05f4886..a6875c708d10 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareEntitiesDocumentResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareEntitiesDocumentResult.java @@ -11,7 +11,9 @@ import java.io.IOException; import java.util.List; -/** The HealthcareEntitiesDocumentResult model. */ +/** + * The HealthcareEntitiesDocumentResult model. + */ @Fluent public class HealthcareEntitiesDocumentResult extends DocumentResult { /* @@ -24,12 +26,15 @@ public class HealthcareEntitiesDocumentResult extends DocumentResult { */ private List relations; - /** Creates an instance of HealthcareEntitiesDocumentResult class. */ - public HealthcareEntitiesDocumentResult() {} + /** + * Creates an instance of HealthcareEntitiesDocumentResult class. + */ + public HealthcareEntitiesDocumentResult() { + } /** * Get the entities property: Healthcare entities. - * + * * @return the entities value. */ public List getEntities() { @@ -38,7 +43,7 @@ public List getEntities() { /** * Set the entities property: Healthcare entities. - * + * * @param entities the entities value to set. * @return the HealthcareEntitiesDocumentResult object itself. */ @@ -49,7 +54,7 @@ public HealthcareEntitiesDocumentResult setEntities(List entit /** * Get the relations property: Healthcare entity relations. - * + * * @return the relations value. */ public List getRelations() { @@ -58,7 +63,7 @@ public List getRelations() { /** * Set the relations property: Healthcare entity relations. - * + * * @param relations the relations value to set. * @return the HealthcareEntitiesDocumentResult object itself. */ @@ -67,27 +72,36 @@ public HealthcareEntitiesDocumentResult setRelations(List re return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public HealthcareEntitiesDocumentResult setId(String id) { super.setId(id); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public HealthcareEntitiesDocumentResult setWarnings(List warnings) { super.setWarnings(warnings); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public HealthcareEntitiesDocumentResult setStatistics(DocumentStatistics statistics) { super.setStatistics(statistics); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -101,45 +115,41 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of HealthcareEntitiesDocumentResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of HealthcareEntitiesDocumentResult if the JsonReader was pointing to an instance of it, or - * null if it was pointing to JSON null. + * 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 HealthcareEntitiesDocumentResult. */ public static HealthcareEntitiesDocumentResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - HealthcareEntitiesDocumentResult deserializedHealthcareEntitiesDocumentResult = - new HealthcareEntitiesDocumentResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - deserializedHealthcareEntitiesDocumentResult.setId(reader.getString()); - } else if ("warnings".equals(fieldName)) { - List warnings = - reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); - deserializedHealthcareEntitiesDocumentResult.setWarnings(warnings); - } else if ("statistics".equals(fieldName)) { - deserializedHealthcareEntitiesDocumentResult.setStatistics( - DocumentStatistics.fromJson(reader)); - } else if ("entities".equals(fieldName)) { - List entities = - reader.readArray(reader1 -> HealthcareEntity.fromJson(reader1)); - deserializedHealthcareEntitiesDocumentResult.entities = entities; - } else if ("relations".equals(fieldName)) { - List relations = - reader.readArray(reader1 -> HealthcareRelation.fromJson(reader1)); - deserializedHealthcareEntitiesDocumentResult.relations = relations; - } else { - reader.skipChildren(); - } - } - - return deserializedHealthcareEntitiesDocumentResult; - }); + return jsonReader.readObject(reader -> { + HealthcareEntitiesDocumentResult deserializedHealthcareEntitiesDocumentResult + = new HealthcareEntitiesDocumentResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedHealthcareEntitiesDocumentResult.setId(reader.getString()); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedHealthcareEntitiesDocumentResult.setWarnings(warnings); + } else if ("statistics".equals(fieldName)) { + deserializedHealthcareEntitiesDocumentResult.setStatistics(DocumentStatistics.fromJson(reader)); + } else if ("entities".equals(fieldName)) { + List entities = reader.readArray(reader1 -> HealthcareEntity.fromJson(reader1)); + deserializedHealthcareEntitiesDocumentResult.entities = entities; + } else if ("relations".equals(fieldName)) { + List relations + = reader.readArray(reader1 -> HealthcareRelation.fromJson(reader1)); + deserializedHealthcareEntitiesDocumentResult.relations = relations; + } else { + reader.skipChildren(); + } + } + + return deserializedHealthcareEntitiesDocumentResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareEntity.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareEntity.java index b1460a109f7c..162a387bab31 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareEntity.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareEntity.java @@ -12,9 +12,10 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.util.List; -import java.util.Objects; -/** The HealthcareEntity model. */ +/** + * The HealthcareEntity model. + */ @Fluent public final class HealthcareEntity implements JsonSerializable { /* @@ -62,12 +63,15 @@ public final class HealthcareEntity implements JsonSerializable links; - /** Creates an instance of HealthcareEntity class. */ - public HealthcareEntity() {} + /** + * Creates an instance of HealthcareEntity class. + */ + public HealthcareEntity() { + } /** * Get the text property: Entity text as appears in the request. - * + * * @return the text value. */ public String getText() { @@ -76,7 +80,7 @@ public String getText() { /** * Set the text property: Entity text as appears in the request. - * + * * @param text the text value to set. * @return the HealthcareEntity object itself. */ @@ -87,7 +91,7 @@ public HealthcareEntity setText(String text) { /** * Get the category property: Healthcare Entity Category. - * + * * @return the category value. */ public HealthcareEntityCategory getCategory() { @@ -96,7 +100,7 @@ public HealthcareEntityCategory getCategory() { /** * Set the category property: Healthcare Entity Category. - * + * * @param category the category value to set. * @return the HealthcareEntity object itself. */ @@ -107,7 +111,7 @@ public HealthcareEntity setCategory(HealthcareEntityCategory category) { /** * Get the subcategory property: (Optional) Entity sub type. - * + * * @return the subcategory value. */ public String getSubcategory() { @@ -116,7 +120,7 @@ public String getSubcategory() { /** * Set the subcategory property: (Optional) Entity sub type. - * + * * @param subcategory the subcategory value to set. * @return the HealthcareEntity object itself. */ @@ -128,7 +132,7 @@ public HealthcareEntity setSubcategory(String subcategory) { /** * Get the offset property: Start position for the entity text. Use of different 'stringIndexType' values can affect * the offset returned. - * + * * @return the offset value. */ public int getOffset() { @@ -138,7 +142,7 @@ public int getOffset() { /** * Set the offset property: Start position for the entity text. Use of different 'stringIndexType' values can affect * the offset returned. - * + * * @param offset the offset value to set. * @return the HealthcareEntity object itself. */ @@ -150,7 +154,7 @@ public HealthcareEntity setOffset(int offset) { /** * Get the length property: Length for the entity text. Use of different 'stringIndexType' values can affect the * length returned. - * + * * @return the length value. */ public int getLength() { @@ -160,7 +164,7 @@ public int getLength() { /** * Set the length property: Length for the entity text. Use of different 'stringIndexType' values can affect the * length returned. - * + * * @param length the length value to set. * @return the HealthcareEntity object itself. */ @@ -171,7 +175,7 @@ public HealthcareEntity setLength(int length) { /** * Get the confidenceScore property: Confidence score between 0 and 1 of the extracted entity. - * + * * @return the confidenceScore value. */ public double getConfidenceScore() { @@ -180,7 +184,7 @@ public double getConfidenceScore() { /** * Set the confidenceScore property: Confidence score between 0 and 1 of the extracted entity. - * + * * @param confidenceScore the confidenceScore value to set. * @return the HealthcareEntity object itself. */ @@ -191,7 +195,7 @@ public HealthcareEntity setConfidenceScore(double confidenceScore) { /** * Get the assertion property: The assertion property. - * + * * @return the assertion value. */ public HealthcareAssertion getAssertion() { @@ -200,7 +204,7 @@ public HealthcareAssertion getAssertion() { /** * Set the assertion property: The assertion property. - * + * * @param assertion the assertion value to set. * @return the HealthcareEntity object itself. */ @@ -212,7 +216,7 @@ public HealthcareEntity setAssertion(HealthcareAssertion assertion) { /** * Get the name property: Preferred name for the entity. Example: 'histologically' would have a 'name' of * 'histologic'. - * + * * @return the name value. */ public String getName() { @@ -222,7 +226,7 @@ public String getName() { /** * Set the name property: Preferred name for the entity. Example: 'histologically' would have a 'name' of * 'histologic'. - * + * * @param name the name value to set. * @return the HealthcareEntity object itself. */ @@ -233,7 +237,7 @@ public HealthcareEntity setName(String name) { /** * Get the links property: Entity references in known data sources. - * + * * @return the links value. */ public List getLinks() { @@ -242,7 +246,7 @@ public List getLinks() { /** * Set the links property: Entity references in known data sources. - * + * * @param links the links value to set. * @return the HealthcareEntity object itself. */ @@ -251,11 +255,14 @@ public HealthcareEntity setLinks(List links) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); jsonWriter.writeStringField("text", this.text); - jsonWriter.writeStringField("category", Objects.toString(this.category, null)); + jsonWriter.writeStringField("category", this.category == null ? null : this.category.toString()); jsonWriter.writeIntField("offset", this.offset); jsonWriter.writeIntField("length", this.length); jsonWriter.writeDoubleField("confidenceScore", this.confidenceScore); @@ -268,48 +275,46 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of HealthcareEntity from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of HealthcareEntity if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 HealthcareEntity. */ public static HealthcareEntity fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - HealthcareEntity deserializedHealthcareEntity = new HealthcareEntity(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("text".equals(fieldName)) { - deserializedHealthcareEntity.text = reader.getString(); - } else if ("category".equals(fieldName)) { - deserializedHealthcareEntity.category = - HealthcareEntityCategory.fromString(reader.getString()); - } else if ("offset".equals(fieldName)) { - deserializedHealthcareEntity.offset = reader.getInt(); - } else if ("length".equals(fieldName)) { - deserializedHealthcareEntity.length = reader.getInt(); - } else if ("confidenceScore".equals(fieldName)) { - deserializedHealthcareEntity.confidenceScore = reader.getDouble(); - } else if ("subcategory".equals(fieldName)) { - deserializedHealthcareEntity.subcategory = reader.getString(); - } else if ("assertion".equals(fieldName)) { - deserializedHealthcareEntity.assertion = HealthcareAssertion.fromJson(reader); - } else if ("name".equals(fieldName)) { - deserializedHealthcareEntity.name = reader.getString(); - } else if ("links".equals(fieldName)) { - List links = - reader.readArray(reader1 -> HealthcareEntityLink.fromJson(reader1)); - deserializedHealthcareEntity.links = links; - } else { - reader.skipChildren(); - } - } - - return deserializedHealthcareEntity; - }); + return jsonReader.readObject(reader -> { + HealthcareEntity deserializedHealthcareEntity = new HealthcareEntity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("text".equals(fieldName)) { + deserializedHealthcareEntity.text = reader.getString(); + } else if ("category".equals(fieldName)) { + deserializedHealthcareEntity.category = HealthcareEntityCategory.fromString(reader.getString()); + } else if ("offset".equals(fieldName)) { + deserializedHealthcareEntity.offset = reader.getInt(); + } else if ("length".equals(fieldName)) { + deserializedHealthcareEntity.length = reader.getInt(); + } else if ("confidenceScore".equals(fieldName)) { + deserializedHealthcareEntity.confidenceScore = reader.getDouble(); + } else if ("subcategory".equals(fieldName)) { + deserializedHealthcareEntity.subcategory = reader.getString(); + } else if ("assertion".equals(fieldName)) { + deserializedHealthcareEntity.assertion = HealthcareAssertion.fromJson(reader); + } else if ("name".equals(fieldName)) { + deserializedHealthcareEntity.name = reader.getString(); + } else if ("links".equals(fieldName)) { + List links + = reader.readArray(reader1 -> HealthcareEntityLink.fromJson(reader1)); + deserializedHealthcareEntity.links = links; + } else { + reader.skipChildren(); + } + } + + return deserializedHealthcareEntity; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareEntityLink.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareEntityLink.java index fb91e43f0b30..d5133a066c97 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareEntityLink.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareEntityLink.java @@ -11,7 +11,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** The HealthcareEntityLink model. */ +/** + * The HealthcareEntityLink model. + */ @Fluent public final class HealthcareEntityLink implements JsonSerializable { /* @@ -24,12 +26,15 @@ public final class HealthcareEntityLink implements JsonSerializable { - HealthcareEntityLink deserializedHealthcareEntityLink = new HealthcareEntityLink(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + HealthcareEntityLink deserializedHealthcareEntityLink = new HealthcareEntityLink(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("dataSource".equals(fieldName)) { - deserializedHealthcareEntityLink.dataSource = reader.getString(); - } else if ("id".equals(fieldName)) { - deserializedHealthcareEntityLink.id = reader.getString(); - } else { - reader.skipChildren(); - } - } + if ("dataSource".equals(fieldName)) { + deserializedHealthcareEntityLink.dataSource = reader.getString(); + } else if ("id".equals(fieldName)) { + deserializedHealthcareEntityLink.id = reader.getString(); + } else { + reader.skipChildren(); + } + } - return deserializedHealthcareEntityLink; - }); + return deserializedHealthcareEntityLink; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareEntityProperties.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareEntityProperties.java deleted file mode 100644 index d1e02e9b2806..000000000000 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareEntityProperties.java +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.ai.textanalytics.implementation.models; - -import com.azure.ai.textanalytics.models.HealthcareEntityCategory; -import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** The HealthcareEntityProperties model. */ -@Fluent -public class HealthcareEntityProperties { - /* - * Entity text as appears in the request. - */ - @JsonProperty(value = "text", required = true) - private String text; - - /* - * Healthcare Entity Category. - */ - @JsonProperty(value = "category", required = true) - private HealthcareEntityCategory category; - - /* - * (Optional) Entity sub type. - */ - @JsonProperty(value = "subcategory") - private String subcategory; - - /* - * Start position for the entity text. Use of different 'stringIndexType' - * values can affect the offset returned. - */ - @JsonProperty(value = "offset", required = true) - private int offset; - - /* - * Length for the entity text. Use of different 'stringIndexType' values - * can affect the length returned. - */ - @JsonProperty(value = "length", required = true) - private int length; - - /* - * Confidence score between 0 and 1 of the extracted entity. - */ - @JsonProperty(value = "confidenceScore", required = true) - private double confidenceScore; - - /** - * Get the text property: Entity text as appears in the request. - * - * @return the text value. - */ - public String getText() { - return this.text; - } - - /** - * Set the text property: Entity text as appears in the request. - * - * @param text the text value to set. - * @return the HealthcareEntityProperties object itself. - */ - public HealthcareEntityProperties setText(String text) { - this.text = text; - return this; - } - - /** - * Get the category property: Healthcare Entity Category. - * - * @return the category value. - */ - public HealthcareEntityCategory getCategory() { - return this.category; - } - - /** - * Set the category property: Healthcare Entity Category. - * - * @param category the category value to set. - * @return the HealthcareEntityProperties object itself. - */ - public HealthcareEntityProperties setCategory(HealthcareEntityCategory category) { - this.category = category; - return this; - } - - /** - * Get the subcategory property: (Optional) Entity sub type. - * - * @return the subcategory value. - */ - public String getSubcategory() { - return this.subcategory; - } - - /** - * Set the subcategory property: (Optional) Entity sub type. - * - * @param subcategory the subcategory value to set. - * @return the HealthcareEntityProperties object itself. - */ - public HealthcareEntityProperties setSubcategory(String subcategory) { - this.subcategory = subcategory; - return this; - } - - /** - * Get the offset property: Start position for the entity text. Use of different 'stringIndexType' values can affect - * the offset returned. - * - * @return the offset value. - */ - public int getOffset() { - return this.offset; - } - - /** - * Set the offset property: Start position for the entity text. Use of different 'stringIndexType' values can affect - * the offset returned. - * - * @param offset the offset value to set. - * @return the HealthcareEntityProperties object itself. - */ - public HealthcareEntityProperties setOffset(int offset) { - this.offset = offset; - return this; - } - - /** - * Get the length property: Length for the entity text. Use of different 'stringIndexType' values can affect the - * length returned. - * - * @return the length value. - */ - public int getLength() { - return this.length; - } - - /** - * Set the length property: Length for the entity text. Use of different 'stringIndexType' values can affect the - * length returned. - * - * @param length the length value to set. - * @return the HealthcareEntityProperties object itself. - */ - public HealthcareEntityProperties setLength(int length) { - this.length = length; - return this; - } - - /** - * Get the confidenceScore property: Confidence score between 0 and 1 of the extracted entity. - * - * @return the confidenceScore value. - */ - public double getConfidenceScore() { - return this.confidenceScore; - } - - /** - * Set the confidenceScore property: Confidence score between 0 and 1 of the extracted entity. - * - * @param confidenceScore the confidenceScore value to set. - * @return the HealthcareEntityProperties object itself. - */ - public HealthcareEntityProperties setConfidenceScore(double confidenceScore) { - this.confidenceScore = confidenceScore; - return this; - } -} diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareJobState.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareJobState.java index 56230a606060..1dfc124a8dfd 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareJobState.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareJobState.java @@ -1,11 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; + +import java.io.IOException; import java.util.List; /** The HealthcareJobState model. */ @@ -14,19 +17,16 @@ public final class HealthcareJobState extends JobMetadata { /* * The results property. */ - @JsonProperty(value = "results") private HealthcareResult results; /* * The errors property. */ - @JsonProperty(value = "errors") private List errors; /* * The @nextLink property. */ - @JsonProperty(value = "@nextLink") private String nextLink; /** @@ -88,4 +88,46 @@ public HealthcareJobState setNextLink(String nextLink) { this.nextLink = nextLink; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("results", this.results); + jsonWriter.writeArrayField("errors", this.errors, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("@nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of HealthcareJobState from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of HealthcareJobState 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 HealthcareJobState. + */ + public static HealthcareJobState fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + HealthcareJobState deserializedHealthcareJobState = new HealthcareJobState(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("results".equals(fieldName)) { + deserializedHealthcareJobState.results = HealthcareResult.fromJson(reader); + } else if ("errors".equals(fieldName)) { + deserializedHealthcareJobState.errors = reader.readArray(reader1 -> Error.fromJson(reader1)); + } else if ("@nextLink".equals(fieldName)) { + deserializedHealthcareJobState.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedHealthcareJobState; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareLROResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareLROResult.java index f9056de2dbb1..bece815494bf 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareLROResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareLROResult.java @@ -10,22 +10,42 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.time.OffsetDateTime; -import java.util.Objects; +import java.time.format.DateTimeFormatter; -/** The HealthcareLROResult model. */ +/** + * The HealthcareLROResult model. + */ @Fluent public final class HealthcareLROResult extends AnalyzeTextLROResult { + /* + * Enumeration of supported Text Analysis long-running operation task results. + */ + private AnalyzeTextLROResultsKind kind = AnalyzeTextLROResultsKind.HEALTHCARE_LRORESULTS; + /* * The results property. */ private HealthcareResult results; - /** Creates an instance of HealthcareLROResult class. */ - public HealthcareLROResult() {} + /** + * Creates an instance of HealthcareLROResult class. + */ + public HealthcareLROResult() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis long-running operation task results. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROResultsKind getKind() { + return this.kind; + } /** * Get the results property: The results property. - * + * * @return the results value. */ public HealthcareResult getResults() { @@ -34,7 +54,7 @@ public HealthcareResult getResults() { /** * Set the results property: The results property. - * + * * @param results the results value to set. * @return the HealthcareLROResult object itself. */ @@ -43,80 +63,83 @@ public HealthcareLROResult setResults(HealthcareResult results) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public HealthcareLROResult setTaskName(String taskName) { super.setTaskName(taskName); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public HealthcareLROResult setLastUpdateDateTime(OffsetDateTime lastUpdateDateTime) { super.setLastUpdateDateTime(lastUpdateDateTime); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public HealthcareLROResult setStatus(State status) { super.setStatus(status); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("kind", Objects.toString(AnalyzeTextLROResultsKind.HEALTHCARE_LRORESULTS, null)); - jsonWriter.writeStringField("lastUpdateDateTime", Objects.toString(getLastUpdateDateTime(), null)); - jsonWriter.writeStringField("status", Objects.toString(getStatus(), null)); + jsonWriter.writeStringField("lastUpdateDateTime", + getLastUpdateDateTime() == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(getLastUpdateDateTime())); + jsonWriter.writeStringField("status", getStatus() == null ? null : getStatus().toString()); jsonWriter.writeStringField("taskName", getTaskName()); jsonWriter.writeJsonField("results", this.results); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of HealthcareLROResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of HealthcareLROResult 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 or the - * polymorphic discriminator. + * 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 HealthcareLROResult. */ public static HealthcareLROResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - HealthcareLROResult deserializedHealthcareLROResult = new HealthcareLROResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + HealthcareLROResult deserializedHealthcareLROResult = new HealthcareLROResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"HealthcareLROResults".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'HealthcareLROResults'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("lastUpdateDateTime".equals(fieldName)) { - deserializedHealthcareLROResult.setLastUpdateDateTime( - reader.getNullable( - nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); - } else if ("status".equals(fieldName)) { - deserializedHealthcareLROResult.setStatus(State.fromString(reader.getString())); - } else if ("taskName".equals(fieldName)) { - deserializedHealthcareLROResult.setTaskName(reader.getString()); - } else if ("results".equals(fieldName)) { - deserializedHealthcareLROResult.results = HealthcareResult.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("lastUpdateDateTime".equals(fieldName)) { + deserializedHealthcareLROResult.setLastUpdateDateTime( + reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); + } else if ("status".equals(fieldName)) { + deserializedHealthcareLROResult.setStatus(State.fromString(reader.getString())); + } else if ("taskName".equals(fieldName)) { + deserializedHealthcareLROResult.setTaskName(reader.getString()); + } else if ("results".equals(fieldName)) { + deserializedHealthcareLROResult.results = HealthcareResult.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedHealthcareLROResult.kind = AnalyzeTextLROResultsKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedHealthcareLROResult; - }); + return deserializedHealthcareLROResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareLROTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareLROTask.java index 5989c4ce9f76..ffe62ea99854 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareLROTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareLROTask.java @@ -9,22 +9,41 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** The HealthcareLROTask model. */ +/** + * The HealthcareLROTask model. + */ @Fluent public final class HealthcareLROTask extends AnalyzeTextLROTask { + /* + * Enumeration of supported long-running Text Analysis tasks. + */ + private AnalyzeTextLROTaskKind kind = AnalyzeTextLROTaskKind.HEALTHCARE; + /* * Supported parameters for a Healthcare task. */ private HealthcareTaskParameters parameters; - /** Creates an instance of HealthcareLROTask class. */ - public HealthcareLROTask() {} + /** + * Creates an instance of HealthcareLROTask class. + */ + public HealthcareLROTask() { + } + + /** + * Get the kind property: Enumeration of supported long-running Text Analysis tasks. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROTaskKind getKind() { + return this.kind; + } /** * Get the parameters property: Supported parameters for a Healthcare task. - * + * * @return the parameters value. */ public HealthcareTaskParameters getParameters() { @@ -33,7 +52,7 @@ public HealthcareTaskParameters getParameters() { /** * Set the parameters property: Supported parameters for a Healthcare task. - * + * * @param parameters the parameters value to set. * @return the HealthcareLROTask object itself. */ @@ -42,57 +61,54 @@ public HealthcareLROTask setParameters(HealthcareTaskParameters parameters) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public HealthcareLROTask setTaskName(String taskName) { super.setTaskName(taskName); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("kind", Objects.toString(AnalyzeTextLROTaskKind.HEALTHCARE, null)); jsonWriter.writeStringField("taskName", getTaskName()); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); jsonWriter.writeJsonField("parameters", this.parameters); return jsonWriter.writeEndObject(); } /** * Reads an instance of HealthcareLROTask from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of HealthcareLROTask 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 the polymorphic discriminator. + * pointing to JSON null. * @throws IOException If an error occurs while reading the HealthcareLROTask. */ public static HealthcareLROTask fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - HealthcareLROTask deserializedHealthcareLROTask = new HealthcareLROTask(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + HealthcareLROTask deserializedHealthcareLROTask = new HealthcareLROTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"Healthcare".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'Healthcare'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("taskName".equals(fieldName)) { - deserializedHealthcareLROTask.setTaskName(reader.getString()); - } else if ("parameters".equals(fieldName)) { - deserializedHealthcareLROTask.parameters = HealthcareTaskParameters.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("taskName".equals(fieldName)) { + deserializedHealthcareLROTask.setTaskName(reader.getString()); + } else if ("kind".equals(fieldName)) { + deserializedHealthcareLROTask.kind = AnalyzeTextLROTaskKind.fromString(reader.getString()); + } else if ("parameters".equals(fieldName)) { + deserializedHealthcareLROTask.parameters = HealthcareTaskParameters.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedHealthcareLROTask; - }); + return deserializedHealthcareLROTask; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareRelation.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareRelation.java index db4e24c3f662..ad0e45af3865 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareRelation.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareRelation.java @@ -12,7 +12,6 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.util.List; -import java.util.Objects; /** * Every relation is an entity graph of a certain relationType, where all entities are connected and have specific roles @@ -35,13 +34,16 @@ public final class HealthcareRelation implements JsonSerializable entities; - /** Creates an instance of HealthcareRelation class. */ - public HealthcareRelation() {} + /** + * Creates an instance of HealthcareRelation class. + */ + public HealthcareRelation() { + } /** * Get the relationType property: Type of relation. Examples include: `DosageOfMedication` or * 'FrequencyOfMedication', etc. - * + * * @return the relationType value. */ public HealthcareEntityRelationType getRelationType() { @@ -51,7 +53,7 @@ public HealthcareEntityRelationType getRelationType() { /** * Set the relationType property: Type of relation. Examples include: `DosageOfMedication` or * 'FrequencyOfMedication', etc. - * + * * @param relationType the relationType value to set. * @return the HealthcareRelation object itself. */ @@ -62,7 +64,7 @@ public HealthcareRelation setRelationType(HealthcareEntityRelationType relationT /** * Get the confidenceScore property: Confidence score between 0 and 1 of the extracted relation. - * + * * @return the confidenceScore value. */ public Double getConfidenceScore() { @@ -71,7 +73,7 @@ public Double getConfidenceScore() { /** * Set the confidenceScore property: Confidence score between 0 and 1 of the extracted relation. - * + * * @param confidenceScore the confidenceScore value to set. * @return the HealthcareRelation object itself. */ @@ -82,7 +84,7 @@ public HealthcareRelation setConfidenceScore(Double confidenceScore) { /** * Get the entities property: The entities in the relation. - * + * * @return the entities value. */ public List getEntities() { @@ -91,7 +93,7 @@ public List getEntities() { /** * Set the entities property: The entities in the relation. - * + * * @param entities the entities value to set. * @return the HealthcareRelation object itself. */ @@ -100,10 +102,13 @@ public HealthcareRelation setEntities(List entities) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("relationType", Objects.toString(this.relationType, null)); + jsonWriter.writeStringField("relationType", this.relationType == null ? null : this.relationType.toString()); jsonWriter.writeArrayField("entities", this.entities, (writer, element) -> writer.writeJson(element)); jsonWriter.writeNumberField("confidenceScore", this.confidenceScore); return jsonWriter.writeEndObject(); @@ -111,36 +116,35 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of HealthcareRelation from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of HealthcareRelation if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 HealthcareRelation. */ public static HealthcareRelation fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - HealthcareRelation deserializedHealthcareRelation = new HealthcareRelation(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("relationType".equals(fieldName)) { - deserializedHealthcareRelation.relationType = - HealthcareEntityRelationType.fromString(reader.getString()); - } else if ("entities".equals(fieldName)) { - List entities = - reader.readArray(reader1 -> HealthcareRelationEntity.fromJson(reader1)); - deserializedHealthcareRelation.entities = entities; - } else if ("confidenceScore".equals(fieldName)) { - deserializedHealthcareRelation.confidenceScore = reader.getNullable(JsonReader::getDouble); - } else { - reader.skipChildren(); - } - } - - return deserializedHealthcareRelation; - }); + return jsonReader.readObject(reader -> { + HealthcareRelation deserializedHealthcareRelation = new HealthcareRelation(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("relationType".equals(fieldName)) { + deserializedHealthcareRelation.relationType + = HealthcareEntityRelationType.fromString(reader.getString()); + } else if ("entities".equals(fieldName)) { + List entities + = reader.readArray(reader1 -> HealthcareRelationEntity.fromJson(reader1)); + deserializedHealthcareRelation.entities = entities; + } else if ("confidenceScore".equals(fieldName)) { + deserializedHealthcareRelation.confidenceScore = reader.getNullable(JsonReader::getDouble); + } else { + reader.skipChildren(); + } + } + + return deserializedHealthcareRelation; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareRelationEntity.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareRelationEntity.java index dbd366ebaedb..4e08906a22f6 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareRelationEntity.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareRelationEntity.java @@ -11,29 +11,31 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** The HealthcareRelationEntity model. */ +/** + * The HealthcareRelationEntity model. + */ @Fluent public final class HealthcareRelationEntity implements JsonSerializable { /* - * Reference link object, using a JSON pointer RFC 6901 (URI Fragment Identifier Representation), pointing to the - * entity . + * Reference link object, using a JSON pointer RFC 6901 (URI Fragment Identifier Representation), pointing to the entity . */ private String ref; /* - * Role of entity in the relationship. For example: 'CD20-positive diffuse large B-cell lymphoma' has the following - * entities with their roles in parenthesis: CD20 (GeneOrProtein), Positive (Expression), diffuse large B-cell - * lymphoma (Diagnosis). + * Role of entity in the relationship. For example: 'CD20-positive diffuse large B-cell lymphoma' has the following entities with their roles in parenthesis: CD20 (GeneOrProtein), Positive (Expression), diffuse large B-cell lymphoma (Diagnosis). */ private String role; - /** Creates an instance of HealthcareRelationEntity class. */ - public HealthcareRelationEntity() {} + /** + * Creates an instance of HealthcareRelationEntity class. + */ + public HealthcareRelationEntity() { + } /** * Get the ref property: Reference link object, using a JSON pointer RFC 6901 (URI Fragment Identifier * Representation), pointing to the entity . - * + * * @return the ref value. */ public String getRef() { @@ -43,7 +45,7 @@ public String getRef() { /** * Set the ref property: Reference link object, using a JSON pointer RFC 6901 (URI Fragment Identifier * Representation), pointing to the entity . - * + * * @param ref the ref value to set. * @return the HealthcareRelationEntity object itself. */ @@ -56,7 +58,7 @@ public HealthcareRelationEntity setRef(String ref) { * Get the role property: Role of entity in the relationship. For example: 'CD20-positive diffuse large B-cell * lymphoma' has the following entities with their roles in parenthesis: CD20 (GeneOrProtein), Positive * (Expression), diffuse large B-cell lymphoma (Diagnosis). - * + * * @return the role value. */ public String getRole() { @@ -67,7 +69,7 @@ public String getRole() { * Set the role property: Role of entity in the relationship. For example: 'CD20-positive diffuse large B-cell * lymphoma' has the following entities with their roles in parenthesis: CD20 (GeneOrProtein), Positive * (Expression), diffuse large B-cell lymphoma (Diagnosis). - * + * * @param role the role value to set. * @return the HealthcareRelationEntity object itself. */ @@ -76,6 +78,9 @@ public HealthcareRelationEntity setRole(String role) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -86,31 +91,30 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of HealthcareRelationEntity from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of HealthcareRelationEntity if the JsonReader was pointing to an instance of it, or null if - * it was pointing to JSON null. + * 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 HealthcareRelationEntity. */ public static HealthcareRelationEntity fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - HealthcareRelationEntity deserializedHealthcareRelationEntity = new HealthcareRelationEntity(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + HealthcareRelationEntity deserializedHealthcareRelationEntity = new HealthcareRelationEntity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("ref".equals(fieldName)) { - deserializedHealthcareRelationEntity.ref = reader.getString(); - } else if ("role".equals(fieldName)) { - deserializedHealthcareRelationEntity.role = reader.getString(); - } else { - reader.skipChildren(); - } - } + if ("ref".equals(fieldName)) { + deserializedHealthcareRelationEntity.ref = reader.getString(); + } else if ("role".equals(fieldName)) { + deserializedHealthcareRelationEntity.role = reader.getString(); + } else { + reader.skipChildren(); + } + } - return deserializedHealthcareRelationEntity; - }); + return deserializedHealthcareRelationEntity; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareResult.java index c90309d8d35b..ad539c3c488c 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareResult.java @@ -11,7 +11,9 @@ import java.io.IOException; import java.util.List; -/** The HealthcareResult model. */ +/** + * The HealthcareResult model. + */ @Fluent public final class HealthcareResult extends PreBuiltResult { /* @@ -19,12 +21,15 @@ public final class HealthcareResult extends PreBuiltResult { */ private List documents; - /** Creates an instance of HealthcareResult class. */ - public HealthcareResult() {} + /** + * Creates an instance of HealthcareResult class. + */ + public HealthcareResult() { + } /** * Get the documents property: The documents property. - * + * * @return the documents value. */ public List getDocuments() { @@ -33,7 +38,7 @@ public List getDocuments() { /** * Set the documents property: The documents property. - * + * * @param documents the documents value to set. * @return the HealthcareResult object itself. */ @@ -42,27 +47,36 @@ public HealthcareResult setDocuments(List documen return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public HealthcareResult setErrors(List errors) { super.setErrors(errors); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public HealthcareResult setStatistics(RequestStatistics statistics) { super.setStatistics(statistics); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public HealthcareResult setModelVersion(String modelVersion) { super.setModelVersion(modelVersion); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -75,38 +89,37 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of HealthcareResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of HealthcareResult if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 HealthcareResult. */ public static HealthcareResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - HealthcareResult deserializedHealthcareResult = new HealthcareResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + HealthcareResult deserializedHealthcareResult = new HealthcareResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("errors".equals(fieldName)) { - List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); - deserializedHealthcareResult.setErrors(errors); - } else if ("modelVersion".equals(fieldName)) { - deserializedHealthcareResult.setModelVersion(reader.getString()); - } else if ("statistics".equals(fieldName)) { - deserializedHealthcareResult.setStatistics(RequestStatistics.fromJson(reader)); - } else if ("documents".equals(fieldName)) { - List documents = - reader.readArray(reader1 -> HealthcareResultDocumentsItem.fromJson(reader1)); - deserializedHealthcareResult.documents = documents; - } else { - reader.skipChildren(); - } - } + if ("errors".equals(fieldName)) { + List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); + deserializedHealthcareResult.setErrors(errors); + } else if ("modelVersion".equals(fieldName)) { + deserializedHealthcareResult.setModelVersion(reader.getString()); + } else if ("statistics".equals(fieldName)) { + deserializedHealthcareResult.setStatistics(RequestStatistics.fromJson(reader)); + } else if ("documents".equals(fieldName)) { + List documents + = reader.readArray(reader1 -> HealthcareResultDocumentsItem.fromJson(reader1)); + deserializedHealthcareResult.documents = documents; + } else { + reader.skipChildren(); + } + } - return deserializedHealthcareResult; - }); + return deserializedHealthcareResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareResultDocumentsItem.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareResultDocumentsItem.java index cb487c3a5841..8b6ebc11f41f 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareResultDocumentsItem.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareResultDocumentsItem.java @@ -11,47 +11,65 @@ import java.io.IOException; import java.util.List; -/** The HealthcareResultDocumentsItem model. */ +/** + * The HealthcareResultDocumentsItem model. + */ @Fluent public final class HealthcareResultDocumentsItem extends HealthcareEntitiesDocumentResult { - /** Creates an instance of HealthcareResultDocumentsItem class. */ - public HealthcareResultDocumentsItem() {} + /** + * Creates an instance of HealthcareResultDocumentsItem class. + */ + public HealthcareResultDocumentsItem() { + } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public HealthcareResultDocumentsItem setEntities(List entities) { super.setEntities(entities); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public HealthcareResultDocumentsItem setRelations(List relations) { super.setRelations(relations); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public HealthcareResultDocumentsItem setId(String id) { super.setId(id); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public HealthcareResultDocumentsItem setWarnings(List warnings) { super.setWarnings(warnings); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public HealthcareResultDocumentsItem setStatistics(DocumentStatistics statistics) { super.setStatistics(statistics); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -65,45 +83,41 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of HealthcareResultDocumentsItem from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of HealthcareResultDocumentsItem if the JsonReader was pointing to an instance of it, or null - * if it was pointing to JSON 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 HealthcareResultDocumentsItem. */ public static HealthcareResultDocumentsItem fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - HealthcareResultDocumentsItem deserializedHealthcareResultDocumentsItem = - new HealthcareResultDocumentsItem(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + HealthcareResultDocumentsItem deserializedHealthcareResultDocumentsItem + = new HealthcareResultDocumentsItem(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("id".equals(fieldName)) { - deserializedHealthcareResultDocumentsItem.setId(reader.getString()); - } else if ("warnings".equals(fieldName)) { - List warnings = - reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); - deserializedHealthcareResultDocumentsItem.setWarnings(warnings); - } else if ("entities".equals(fieldName)) { - List entities = - reader.readArray(reader1 -> HealthcareEntity.fromJson(reader1)); - deserializedHealthcareResultDocumentsItem.setEntities(entities); - } else if ("relations".equals(fieldName)) { - List relations = - reader.readArray(reader1 -> HealthcareRelation.fromJson(reader1)); - deserializedHealthcareResultDocumentsItem.setRelations(relations); - } else if ("statistics".equals(fieldName)) { - deserializedHealthcareResultDocumentsItem.setStatistics( - DocumentStatistics.fromJson(reader)); - } else { - reader.skipChildren(); - } - } + if ("id".equals(fieldName)) { + deserializedHealthcareResultDocumentsItem.setId(reader.getString()); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedHealthcareResultDocumentsItem.setWarnings(warnings); + } else if ("entities".equals(fieldName)) { + List entities = reader.readArray(reader1 -> HealthcareEntity.fromJson(reader1)); + deserializedHealthcareResultDocumentsItem.setEntities(entities); + } else if ("relations".equals(fieldName)) { + List relations + = reader.readArray(reader1 -> HealthcareRelation.fromJson(reader1)); + deserializedHealthcareResultDocumentsItem.setRelations(relations); + } else if ("statistics".equals(fieldName)) { + deserializedHealthcareResultDocumentsItem.setStatistics(DocumentStatistics.fromJson(reader)); + } else { + reader.skipChildren(); + } + } - return deserializedHealthcareResultDocumentsItem; - }); + return deserializedHealthcareResultDocumentsItem; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareTaskParameters.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareTaskParameters.java index 8fd9a2d38910..9995fb5b2429 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareTaskParameters.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/HealthcareTaskParameters.java @@ -9,25 +9,28 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** Supported parameters for a Healthcare task. */ +/** + * Supported parameters for a Healthcare task. + */ @Fluent public final class HealthcareTaskParameters extends PreBuiltTaskParameters { /* - * Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to - * Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. + * Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. */ private StringIndexType stringIndexType; - /** Creates an instance of HealthcareTaskParameters class. */ - public HealthcareTaskParameters() {} + /** + * Creates an instance of HealthcareTaskParameters class. + */ + public HealthcareTaskParameters() { + } /** * Get the stringIndexType property: Specifies the method used to interpret string offsets. Defaults to Text * Elements (Graphemes) according to Unicode v8.0.0. For additional information see * https://aka.ms/text-analytics-offsets. - * + * * @return the stringIndexType value. */ public StringIndexType getStringIndexType() { @@ -38,7 +41,7 @@ public StringIndexType getStringIndexType() { * Set the stringIndexType property: Specifies the method used to interpret string offsets. Defaults to Text * Elements (Graphemes) according to Unicode v8.0.0. For additional information see * https://aka.ms/text-analytics-offsets. - * + * * @param stringIndexType the stringIndexType value to set. * @return the HealthcareTaskParameters object itself. */ @@ -47,59 +50,65 @@ public HealthcareTaskParameters setStringIndexType(StringIndexType stringIndexTy return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public HealthcareTaskParameters setModelVersion(String modelVersion) { super.setModelVersion(modelVersion); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public HealthcareTaskParameters setLoggingOptOut(Boolean loggingOptOut) { super.setLoggingOptOut(loggingOptOut); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); jsonWriter.writeBooleanField("loggingOptOut", isLoggingOptOut()); jsonWriter.writeStringField("modelVersion", getModelVersion()); - jsonWriter.writeStringField("stringIndexType", Objects.toString(this.stringIndexType, null)); + jsonWriter.writeStringField("stringIndexType", + this.stringIndexType == null ? null : this.stringIndexType.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of HealthcareTaskParameters from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of HealthcareTaskParameters if the JsonReader was pointing to an instance of it, or null if - * it was pointing to JSON null. + * it was pointing to JSON null. * @throws IOException If an error occurs while reading the HealthcareTaskParameters. */ public static HealthcareTaskParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - HealthcareTaskParameters deserializedHealthcareTaskParameters = new HealthcareTaskParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + HealthcareTaskParameters deserializedHealthcareTaskParameters = new HealthcareTaskParameters(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("loggingOptOut".equals(fieldName)) { - deserializedHealthcareTaskParameters.setLoggingOptOut( - reader.getNullable(JsonReader::getBoolean)); - } else if ("modelVersion".equals(fieldName)) { - deserializedHealthcareTaskParameters.setModelVersion(reader.getString()); - } else if ("stringIndexType".equals(fieldName)) { - deserializedHealthcareTaskParameters.stringIndexType = - StringIndexType.fromString(reader.getString()); - } else { - reader.skipChildren(); - } - } + if ("loggingOptOut".equals(fieldName)) { + deserializedHealthcareTaskParameters.setLoggingOptOut(reader.getNullable(JsonReader::getBoolean)); + } else if ("modelVersion".equals(fieldName)) { + deserializedHealthcareTaskParameters.setModelVersion(reader.getString()); + } else if ("stringIndexType".equals(fieldName)) { + deserializedHealthcareTaskParameters.stringIndexType + = StringIndexType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedHealthcareTaskParameters; - }); + return deserializedHealthcareTaskParameters; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/InnerErrorCode.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/InnerErrorCode.java index b2bfa609c75f..44a3f70156bc 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/InnerErrorCode.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/InnerErrorCode.java @@ -7,61 +7,92 @@ import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; -/** Human-readable error code. */ +/** + * Human-readable error code. + */ public final class InnerErrorCode extends ExpandableStringEnum { - /** Static value InvalidRequest for InnerErrorCode. */ + /** + * Static value InvalidRequest for InnerErrorCode. + */ public static final InnerErrorCode INVALID_REQUEST = fromString("InvalidRequest"); - /** Static value InvalidParameterValue for InnerErrorCode. */ + /** + * Static value InvalidParameterValue for InnerErrorCode. + */ public static final InnerErrorCode INVALID_PARAMETER_VALUE = fromString("InvalidParameterValue"); - /** Static value KnowledgeBaseNotFound for InnerErrorCode. */ + /** + * Static value KnowledgeBaseNotFound for InnerErrorCode. + */ public static final InnerErrorCode KNOWLEDGE_BASE_NOT_FOUND = fromString("KnowledgeBaseNotFound"); - /** Static value AzureCognitiveSearchNotFound for InnerErrorCode. */ + /** + * Static value AzureCognitiveSearchNotFound for InnerErrorCode. + */ public static final InnerErrorCode AZURE_COGNITIVE_SEARCH_NOT_FOUND = fromString("AzureCognitiveSearchNotFound"); - /** Static value AzureCognitiveSearchThrottling for InnerErrorCode. */ + /** + * Static value AzureCognitiveSearchThrottling for InnerErrorCode. + */ public static final InnerErrorCode AZURE_COGNITIVE_SEARCH_THROTTLING = fromString("AzureCognitiveSearchThrottling"); - /** Static value ExtractionFailure for InnerErrorCode. */ + /** + * Static value ExtractionFailure for InnerErrorCode. + */ public static final InnerErrorCode EXTRACTION_FAILURE = fromString("ExtractionFailure"); - /** Static value InvalidRequestBodyFormat for InnerErrorCode. */ + /** + * Static value InvalidRequestBodyFormat for InnerErrorCode. + */ public static final InnerErrorCode INVALID_REQUEST_BODY_FORMAT = fromString("InvalidRequestBodyFormat"); - /** Static value EmptyRequest for InnerErrorCode. */ + /** + * Static value EmptyRequest for InnerErrorCode. + */ public static final InnerErrorCode EMPTY_REQUEST = fromString("EmptyRequest"); - /** Static value MissingInputDocuments for InnerErrorCode. */ + /** + * Static value MissingInputDocuments for InnerErrorCode. + */ public static final InnerErrorCode MISSING_INPUT_DOCUMENTS = fromString("MissingInputDocuments"); - /** Static value InvalidDocument for InnerErrorCode. */ + /** + * Static value InvalidDocument for InnerErrorCode. + */ public static final InnerErrorCode INVALID_DOCUMENT = fromString("InvalidDocument"); - /** Static value ModelVersionIncorrect for InnerErrorCode. */ + /** + * Static value ModelVersionIncorrect for InnerErrorCode. + */ public static final InnerErrorCode MODEL_VERSION_INCORRECT = fromString("ModelVersionIncorrect"); - /** Static value InvalidDocumentBatch for InnerErrorCode. */ + /** + * Static value InvalidDocumentBatch for InnerErrorCode. + */ public static final InnerErrorCode INVALID_DOCUMENT_BATCH = fromString("InvalidDocumentBatch"); - /** Static value UnsupportedLanguageCode for InnerErrorCode. */ + /** + * Static value UnsupportedLanguageCode for InnerErrorCode. + */ public static final InnerErrorCode UNSUPPORTED_LANGUAGE_CODE = fromString("UnsupportedLanguageCode"); - /** Static value InvalidCountryHint for InnerErrorCode. */ + /** + * Static value InvalidCountryHint for InnerErrorCode. + */ public static final InnerErrorCode INVALID_COUNTRY_HINT = fromString("InvalidCountryHint"); /** * Creates a new instance of InnerErrorCode value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated - public InnerErrorCode() {} + public InnerErrorCode() { + } /** * Creates or finds a InnerErrorCode from its string representation. - * + * * @param name a name to look for. * @return the corresponding InnerErrorCode. */ @@ -71,7 +102,7 @@ public static InnerErrorCode fromString(String name) { /** * Gets known InnerErrorCode values. - * + * * @return known InnerErrorCode values. */ public static Collection values() { diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/InnerErrorModel.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/InnerErrorModel.java index 595e2deda041..e8f5bcdc3138 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/InnerErrorModel.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/InnerErrorModel.java @@ -11,7 +11,6 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.util.Map; -import java.util.Objects; /** * An object containing more specific information about the error. As per Microsoft One API guidelines - @@ -44,12 +43,15 @@ public final class InnerErrorModel implements JsonSerializable */ private InnerErrorModel innererror; - /** Creates an instance of InnerErrorModel class. */ - public InnerErrorModel() {} + /** + * Creates an instance of InnerErrorModel class. + */ + public InnerErrorModel() { + } /** * Get the code property: One of a server-defined set of error codes. - * + * * @return the code value. */ public InnerErrorCode getCode() { @@ -58,7 +60,7 @@ public InnerErrorCode getCode() { /** * Set the code property: One of a server-defined set of error codes. - * + * * @param code the code value to set. * @return the InnerErrorModel object itself. */ @@ -69,7 +71,7 @@ public InnerErrorModel setCode(InnerErrorCode code) { /** * Get the message property: Error message. - * + * * @return the message value. */ public String getMessage() { @@ -78,7 +80,7 @@ public String getMessage() { /** * Set the message property: Error message. - * + * * @param message the message value to set. * @return the InnerErrorModel object itself. */ @@ -89,7 +91,7 @@ public InnerErrorModel setMessage(String message) { /** * Get the details property: Error details. - * + * * @return the details value. */ public Map getDetails() { @@ -98,7 +100,7 @@ public Map getDetails() { /** * Set the details property: Error details. - * + * * @param details the details value to set. * @return the InnerErrorModel object itself. */ @@ -109,7 +111,7 @@ public InnerErrorModel setDetails(Map details) { /** * Get the target property: Error target. - * + * * @return the target value. */ public String getTarget() { @@ -118,7 +120,7 @@ public String getTarget() { /** * Set the target property: Error target. - * + * * @param target the target value to set. * @return the InnerErrorModel object itself. */ @@ -130,7 +132,7 @@ public InnerErrorModel setTarget(String target) { /** * Get the innererror property: An object containing more specific information than the current object about the * error. - * + * * @return the innererror value. */ public InnerErrorModel getInnererror() { @@ -140,7 +142,7 @@ public InnerErrorModel getInnererror() { /** * Set the innererror property: An object containing more specific information than the current object about the * error. - * + * * @param innererror the innererror value to set. * @return the InnerErrorModel object itself. */ @@ -149,10 +151,13 @@ public InnerErrorModel setInnererror(InnerErrorModel innererror) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("code", Objects.toString(this.code, null)); + jsonWriter.writeStringField("code", this.code == null ? null : this.code.toString()); jsonWriter.writeStringField("message", this.message); jsonWriter.writeMapField("details", this.details, (writer, element) -> writer.writeString(element)); jsonWriter.writeStringField("target", this.target); @@ -162,38 +167,37 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of InnerErrorModel from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of InnerErrorModel if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 InnerErrorModel. */ public static InnerErrorModel fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - InnerErrorModel deserializedInnerErrorModel = new InnerErrorModel(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("code".equals(fieldName)) { - deserializedInnerErrorModel.code = InnerErrorCode.fromString(reader.getString()); - } else if ("message".equals(fieldName)) { - deserializedInnerErrorModel.message = reader.getString(); - } else if ("details".equals(fieldName)) { - Map details = reader.readMap(reader1 -> reader1.getString()); - deserializedInnerErrorModel.details = details; - } else if ("target".equals(fieldName)) { - deserializedInnerErrorModel.target = reader.getString(); - } else if ("innererror".equals(fieldName)) { - deserializedInnerErrorModel.innererror = InnerErrorModel.fromJson(reader); - } else { - reader.skipChildren(); - } - } - - return deserializedInnerErrorModel; - }); + return jsonReader.readObject(reader -> { + InnerErrorModel deserializedInnerErrorModel = new InnerErrorModel(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("code".equals(fieldName)) { + deserializedInnerErrorModel.code = InnerErrorCode.fromString(reader.getString()); + } else if ("message".equals(fieldName)) { + deserializedInnerErrorModel.message = reader.getString(); + } else if ("details".equals(fieldName)) { + Map details = reader.readMap(reader1 -> reader1.getString()); + deserializedInnerErrorModel.details = details; + } else if ("target".equals(fieldName)) { + deserializedInnerErrorModel.target = reader.getString(); + } else if ("innererror".equals(fieldName)) { + deserializedInnerErrorModel.innererror = InnerErrorModel.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedInnerErrorModel; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/JobDescriptor.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/JobDescriptor.java index 0b067a390dca..b64ca7ddfcdc 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/JobDescriptor.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/JobDescriptor.java @@ -1,19 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 JobDescriptor model. */ @Fluent -public class JobDescriptor { +public class JobDescriptor implements JsonSerializable { /* * Optional display name for the analysis job. */ - @JsonProperty(value = "displayName") private String displayName; /** @@ -35,4 +38,41 @@ public JobDescriptor setDisplayName(String displayName) { this.displayName = displayName; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("displayName", this.displayName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of JobDescriptor from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of JobDescriptor 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 JobDescriptor. + */ + public static JobDescriptor fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + JobDescriptor deserializedJobDescriptor = new JobDescriptor(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("displayName".equals(fieldName)) { + deserializedJobDescriptor.displayName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedJobDescriptor; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/JobErrors.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/JobErrors.java index 5a96bc60f062..607796754bc1 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/JobErrors.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/JobErrors.java @@ -12,7 +12,9 @@ import java.io.IOException; import java.util.List; -/** The JobErrors model. */ +/** + * The JobErrors model. + */ @Fluent public final class JobErrors implements JsonSerializable { /* @@ -20,12 +22,15 @@ public final class JobErrors implements JsonSerializable { */ private List errors; - /** Creates an instance of JobErrors class. */ - public JobErrors() {} + /** + * Creates an instance of JobErrors class. + */ + public JobErrors() { + } /** * Get the errors property: The errors property. - * + * * @return the errors value. */ public List getErrors() { @@ -34,7 +39,7 @@ public List getErrors() { /** * Set the errors property: The errors property. - * + * * @param errors the errors value to set. * @return the JobErrors object itself. */ @@ -43,6 +48,9 @@ public JobErrors setErrors(List errors) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -52,29 +60,28 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of JobErrors from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of JobErrors if the JsonReader was pointing to an instance of it, or null if it was pointing - * to JSON null. + * to JSON null. * @throws IOException If an error occurs while reading the JobErrors. */ public static JobErrors fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - JobErrors deserializedJobErrors = new JobErrors(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + JobErrors deserializedJobErrors = new JobErrors(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("errors".equals(fieldName)) { - List errors = reader.readArray(reader1 -> Error.fromJson(reader1)); - deserializedJobErrors.errors = errors; - } else { - reader.skipChildren(); - } - } + if ("errors".equals(fieldName)) { + List errors = reader.readArray(reader1 -> Error.fromJson(reader1)); + deserializedJobErrors.errors = errors; + } else { + reader.skipChildren(); + } + } - return deserializedJobErrors; - }); + return deserializedJobErrors; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/JobManifestTasks.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/JobManifestTasks.java index 78a5c4032135..5373e0a381c0 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/JobManifestTasks.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/JobManifestTasks.java @@ -1,68 +1,63 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 set of tasks to execute on the input documents. Cannot specify the same task more than once. */ @Fluent -public final class JobManifestTasks { +public final class JobManifestTasks implements JsonSerializable { /* * The entityRecognitionTasks property. */ - @JsonProperty(value = "entityRecognitionTasks") private List entityRecognitionTasks; /* * The entityRecognitionPiiTasks property. */ - @JsonProperty(value = "entityRecognitionPiiTasks") private List entityRecognitionPiiTasks; /* * The keyPhraseExtractionTasks property. */ - @JsonProperty(value = "keyPhraseExtractionTasks") private List keyPhraseExtractionTasks; /* * The entityLinkingTasks property. */ - @JsonProperty(value = "entityLinkingTasks") private List entityLinkingTasks; /* * The sentimentAnalysisTasks property. */ - @JsonProperty(value = "sentimentAnalysisTasks") private List sentimentAnalysisTasks; /* * The extractiveSummarizationTasks property. */ - @JsonProperty(value = "extractiveSummarizationTasks") private List extractiveSummarizationTasks; /* * The customEntityRecognitionTasks property. */ - @JsonProperty(value = "customEntityRecognitionTasks") private List customEntityRecognitionTasks; /* * The customSingleClassificationTasks property. */ - @JsonProperty(value = "customSingleClassificationTasks") private List customSingleClassificationTasks; /* * The customMultiClassificationTasks property. */ - @JsonProperty(value = "customMultiClassificationTasks") private List customMultiClassificationTasks; /** @@ -247,4 +242,74 @@ public JobManifestTasks setCustomMultiClassificationTasks( this.customMultiClassificationTasks = customMultiClassificationTasks; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("entityRecognitionTasks", this.entityRecognitionTasks, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("entityRecognitionPiiTasks", this.entityRecognitionPiiTasks, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("keyPhraseExtractionTasks", this.keyPhraseExtractionTasks, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("entityLinkingTasks", this.entityLinkingTasks, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("sentimentAnalysisTasks", this.sentimentAnalysisTasks, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("extractiveSummarizationTasks", this.extractiveSummarizationTasks, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("customEntityRecognitionTasks", this.customEntityRecognitionTasks, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("customSingleClassificationTasks", this.customSingleClassificationTasks, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("customMultiClassificationTasks", this.customMultiClassificationTasks, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of JobManifestTasks from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of JobManifestTasks 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 JobManifestTasks. + */ + public static JobManifestTasks fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + JobManifestTasks deserializedJobManifestTasks = new JobManifestTasks(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("entityRecognitionTasks".equals(fieldName)) { + deserializedJobManifestTasks.entityRecognitionTasks = + reader.readArray(reader1 -> EntitiesTask.fromJson(reader1)); + } else if ("entityRecognitionPiiTasks".equals(fieldName)) { + deserializedJobManifestTasks.entityRecognitionPiiTasks = + reader.readArray(reader1 -> PiiTask.fromJson(reader1)); + } else if ("keyPhraseExtractionTasks".equals(fieldName)) { + deserializedJobManifestTasks.keyPhraseExtractionTasks = + reader.readArray(reader1 -> KeyPhrasesTask.fromJson(reader1)); + } else if ("entityLinkingTasks".equals(fieldName)) { + deserializedJobManifestTasks.entityLinkingTasks = + reader.readArray(reader1 -> EntityLinkingTask.fromJson(reader1)); + } else if ("sentimentAnalysisTasks".equals(fieldName)) { + deserializedJobManifestTasks.sentimentAnalysisTasks = + reader.readArray(reader1 -> SentimentAnalysisTask.fromJson(reader1)); + } else if ("extractiveSummarizationTasks".equals(fieldName)) { + deserializedJobManifestTasks.extractiveSummarizationTasks = + reader.readArray(reader1 -> ExtractiveSummarizationTask.fromJson(reader1)); + } else if ("customEntityRecognitionTasks".equals(fieldName)) { + deserializedJobManifestTasks.customEntityRecognitionTasks = + reader.readArray(reader1 -> CustomEntitiesTask.fromJson(reader1)); + } else if ("customSingleClassificationTasks".equals(fieldName)) { + deserializedJobManifestTasks.customSingleClassificationTasks = + reader.readArray(reader1 -> CustomSingleClassificationTask.fromJson(reader1)); + } else if ("customMultiClassificationTasks".equals(fieldName)) { + deserializedJobManifestTasks.customMultiClassificationTasks = + reader.readArray(reader1 -> CustomMultiClassificationTask.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + + return deserializedJobManifestTasks; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/JobMetadata.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/JobMetadata.java index 02f612ac8061..0937c46b168a 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/JobMetadata.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/JobMetadata.java @@ -1,51 +1,50 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; import java.util.UUID; /** The JobMetadata model. */ @Fluent -public class JobMetadata { +public class JobMetadata implements JsonSerializable { /* * The displayName property. */ - @JsonProperty(value = "displayName") private String displayName; /* * The createdDateTime property. */ - @JsonProperty(value = "createdDateTime", required = true) private OffsetDateTime createdDateTime; /* * The expirationDateTime property. */ - @JsonProperty(value = "expirationDateTime") private OffsetDateTime expirationDateTime; /* * The jobId property. */ - @JsonProperty(value = "jobId", required = true) private UUID jobId; /* * The lastUpdateDateTime property. */ - @JsonProperty(value = "lastUpdateDateTime", required = true) private OffsetDateTime lastUpdateDateTime; /* * The status property. */ - @JsonProperty(value = "status", required = true) private State status; /** @@ -167,4 +166,57 @@ public JobMetadata setStatus(State status) { this.status = status; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("displayName", this.displayName); + jsonWriter.writeStringField("createdDateTime", + this.createdDateTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.createdDateTime)); + jsonWriter.writeStringField("expirationDateTime", + this.expirationDateTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.expirationDateTime)); + jsonWriter.writeStringField("jobId", this.jobId == null ? null : this.jobId.toString()); + jsonWriter.writeStringField("lastUpdateDateTime", + this.lastUpdateDateTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.lastUpdateDateTime)); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of JobMetadata from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of JobMetadata 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 JobMetadata. + */ + public static JobMetadata fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + JobMetadata jobMetadata = new JobMetadata(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("displayName".equals(fieldName)) { + jobMetadata.displayName = reader.getString(); + } else if ("createdDateTime".equals(fieldName)) { + jobMetadata.createdDateTime = reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString())); + } else if ("expirationDateTime".equals(fieldName)) { + jobMetadata.expirationDateTime = reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString())); + } else if ("jobId".equals(fieldName)) { + jobMetadata.jobId = UUID.fromString(reader.getString()); + } else if ("lastUpdateDateTime".equals(fieldName)) { + jobMetadata.lastUpdateDateTime = reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString())); + } else if ("status".equals(fieldName)) { + jobMetadata.status = State.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return jobMetadata; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/JobState.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/JobState.java index eda98414b974..6225958b3911 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/JobState.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/JobState.java @@ -11,10 +11,12 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; import java.util.List; -import java.util.Objects; -/** The JobState model. */ +/** + * The JobState model. + */ @Fluent public class JobState implements JsonSerializable { /* @@ -57,12 +59,15 @@ public class JobState implements JsonSerializable { */ private String nextLink; - /** Creates an instance of JobState class. */ - public JobState() {} + /** + * Creates an instance of JobState class. + */ + public JobState() { + } /** * Get the displayName property: The displayName property. - * + * * @return the displayName value. */ public String getDisplayName() { @@ -71,7 +76,7 @@ public String getDisplayName() { /** * Set the displayName property: The displayName property. - * + * * @param displayName the displayName value to set. * @return the JobState object itself. */ @@ -82,7 +87,7 @@ public JobState setDisplayName(String displayName) { /** * Get the createdDateTime property: The createdDateTime property. - * + * * @return the createdDateTime value. */ public OffsetDateTime getCreatedDateTime() { @@ -91,7 +96,7 @@ public OffsetDateTime getCreatedDateTime() { /** * Set the createdDateTime property: The createdDateTime property. - * + * * @param createdDateTime the createdDateTime value to set. * @return the JobState object itself. */ @@ -102,7 +107,7 @@ public JobState setCreatedDateTime(OffsetDateTime createdDateTime) { /** * Get the expirationDateTime property: The expirationDateTime property. - * + * * @return the expirationDateTime value. */ public OffsetDateTime getExpirationDateTime() { @@ -111,7 +116,7 @@ public OffsetDateTime getExpirationDateTime() { /** * Set the expirationDateTime property: The expirationDateTime property. - * + * * @param expirationDateTime the expirationDateTime value to set. * @return the JobState object itself. */ @@ -122,7 +127,7 @@ public JobState setExpirationDateTime(OffsetDateTime expirationDateTime) { /** * Get the jobId property: The jobId property. - * + * * @return the jobId value. */ public String getJobId() { @@ -131,7 +136,7 @@ public String getJobId() { /** * Set the jobId property: The jobId property. - * + * * @param jobId the jobId value to set. * @return the JobState object itself. */ @@ -142,7 +147,7 @@ public JobState setJobId(String jobId) { /** * Get the lastUpdatedDateTime property: The lastUpdatedDateTime property. - * + * * @return the lastUpdatedDateTime value. */ public OffsetDateTime getLastUpdatedDateTime() { @@ -151,7 +156,7 @@ public OffsetDateTime getLastUpdatedDateTime() { /** * Set the lastUpdatedDateTime property: The lastUpdatedDateTime property. - * + * * @param lastUpdatedDateTime the lastUpdatedDateTime value to set. * @return the JobState object itself. */ @@ -162,7 +167,7 @@ public JobState setLastUpdatedDateTime(OffsetDateTime lastUpdatedDateTime) { /** * Get the status property: The status property. - * + * * @return the status value. */ public State getStatus() { @@ -171,7 +176,7 @@ public State getStatus() { /** * Set the status property: The status property. - * + * * @param status the status value to set. * @return the JobState object itself. */ @@ -182,7 +187,7 @@ public JobState setStatus(State status) { /** * Get the errors property: The errors property. - * + * * @return the errors value. */ public List getErrors() { @@ -191,7 +196,7 @@ public List getErrors() { /** * Set the errors property: The errors property. - * + * * @param errors the errors value to set. * @return the JobState object itself. */ @@ -202,7 +207,7 @@ public JobState setErrors(List errors) { /** * Get the nextLink property: The nextLink property. - * + * * @return the nextLink value. */ public String getNextLink() { @@ -211,7 +216,7 @@ public String getNextLink() { /** * Set the nextLink property: The nextLink property. - * + * * @param nextLink the nextLink value to set. * @return the JobState object itself. */ @@ -220,15 +225,25 @@ public JobState setNextLink(String nextLink) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("createdDateTime", Objects.toString(this.createdDateTime, null)); + jsonWriter.writeStringField("createdDateTime", + this.createdDateTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.createdDateTime)); jsonWriter.writeStringField("jobId", this.jobId); - jsonWriter.writeStringField("lastUpdatedDateTime", Objects.toString(this.lastUpdatedDateTime, null)); - jsonWriter.writeStringField("status", Objects.toString(this.status, null)); + jsonWriter.writeStringField("lastUpdatedDateTime", + this.lastUpdatedDateTime == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.lastUpdatedDateTime)); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); jsonWriter.writeStringField("displayName", this.displayName); - jsonWriter.writeStringField("expirationDateTime", Objects.toString(this.expirationDateTime, null)); + jsonWriter.writeStringField("expirationDateTime", + this.expirationDateTime == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.expirationDateTime)); jsonWriter.writeArrayField("errors", this.errors, (writer, element) -> writer.writeJson(element)); jsonWriter.writeStringField("nextLink", this.nextLink); return jsonWriter.writeEndObject(); @@ -236,50 +251,46 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of JobState from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of JobState if the JsonReader was pointing to an instance of it, or null if it was pointing - * to JSON null. + * to JSON null. * @throws IllegalStateException If the deserialized JSON object was missing any required properties. * @throws IOException If an error occurs while reading the JobState. */ public static JobState fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - JobState deserializedJobState = new JobState(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + JobState deserializedJobState = new JobState(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("createdDateTime".equals(fieldName)) { - deserializedJobState.createdDateTime = - reader.getNullable( - nonNullReader -> OffsetDateTime.parse(nonNullReader.getString())); - } else if ("jobId".equals(fieldName)) { - deserializedJobState.jobId = reader.getString(); - } else if ("lastUpdatedDateTime".equals(fieldName)) { - deserializedJobState.lastUpdatedDateTime = - reader.getNullable( - nonNullReader -> OffsetDateTime.parse(nonNullReader.getString())); - } else if ("status".equals(fieldName)) { - deserializedJobState.status = State.fromString(reader.getString()); - } else if ("displayName".equals(fieldName)) { - deserializedJobState.displayName = reader.getString(); - } else if ("expirationDateTime".equals(fieldName)) { - deserializedJobState.expirationDateTime = - reader.getNullable( - nonNullReader -> OffsetDateTime.parse(nonNullReader.getString())); - } else if ("errors".equals(fieldName)) { - List errors = reader.readArray(reader1 -> Error.fromJson(reader1)); - deserializedJobState.errors = errors; - } else if ("nextLink".equals(fieldName)) { - deserializedJobState.nextLink = reader.getString(); - } else { - reader.skipChildren(); - } - } + if ("createdDateTime".equals(fieldName)) { + deserializedJobState.createdDateTime + = reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString())); + } else if ("jobId".equals(fieldName)) { + deserializedJobState.jobId = reader.getString(); + } else if ("lastUpdatedDateTime".equals(fieldName)) { + deserializedJobState.lastUpdatedDateTime + = reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString())); + } else if ("status".equals(fieldName)) { + deserializedJobState.status = State.fromString(reader.getString()); + } else if ("displayName".equals(fieldName)) { + deserializedJobState.displayName = reader.getString(); + } else if ("expirationDateTime".equals(fieldName)) { + deserializedJobState.expirationDateTime + = reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString())); + } else if ("errors".equals(fieldName)) { + List errors = reader.readArray(reader1 -> Error.fromJson(reader1)); + deserializedJobState.errors = errors; + } else if ("nextLink".equals(fieldName)) { + deserializedJobState.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } - return deserializedJobState; - }); + return deserializedJobState; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseExtractionLROResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseExtractionLROResult.java index 4bf4d50791b5..cc1ae9267864 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseExtractionLROResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseExtractionLROResult.java @@ -10,22 +10,42 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.time.OffsetDateTime; -import java.util.Objects; +import java.time.format.DateTimeFormatter; -/** The KeyPhraseExtractionLROResult model. */ +/** + * The KeyPhraseExtractionLROResult model. + */ @Fluent public final class KeyPhraseExtractionLROResult extends AnalyzeTextLROResult { + /* + * Enumeration of supported Text Analysis long-running operation task results. + */ + private AnalyzeTextLROResultsKind kind = AnalyzeTextLROResultsKind.KEY_PHRASE_EXTRACTION_LRORESULTS; + /* * The results property. */ private KeyPhraseResult results; - /** Creates an instance of KeyPhraseExtractionLROResult class. */ - public KeyPhraseExtractionLROResult() {} + /** + * Creates an instance of KeyPhraseExtractionLROResult class. + */ + public KeyPhraseExtractionLROResult() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis long-running operation task results. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROResultsKind getKind() { + return this.kind; + } /** * Get the results property: The results property. - * + * * @return the results value. */ public KeyPhraseResult getResults() { @@ -34,7 +54,7 @@ public KeyPhraseResult getResults() { /** * Set the results property: The results property. - * + * * @param results the results value to set. * @return the KeyPhraseExtractionLROResult object itself. */ @@ -43,82 +63,84 @@ public KeyPhraseExtractionLROResult setResults(KeyPhraseResult results) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public KeyPhraseExtractionLROResult setTaskName(String taskName) { super.setTaskName(taskName); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public KeyPhraseExtractionLROResult setLastUpdateDateTime(OffsetDateTime lastUpdateDateTime) { super.setLastUpdateDateTime(lastUpdateDateTime); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public KeyPhraseExtractionLROResult setStatus(State status) { super.setStatus(status); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField( - "kind", Objects.toString(AnalyzeTextLROResultsKind.KEY_PHRASE_EXTRACTION_LRORESULTS, null)); - jsonWriter.writeStringField("lastUpdateDateTime", Objects.toString(getLastUpdateDateTime(), null)); - jsonWriter.writeStringField("status", Objects.toString(getStatus(), null)); + jsonWriter.writeStringField("lastUpdateDateTime", + getLastUpdateDateTime() == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(getLastUpdateDateTime())); + jsonWriter.writeStringField("status", getStatus() == null ? null : getStatus().toString()); jsonWriter.writeStringField("taskName", getTaskName()); jsonWriter.writeJsonField("results", this.results); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of KeyPhraseExtractionLROResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of KeyPhraseExtractionLROResult 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 or the - * polymorphic discriminator. + * 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 KeyPhraseExtractionLROResult. */ public static KeyPhraseExtractionLROResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - KeyPhraseExtractionLROResult deserializedKeyPhraseExtractionLROResult = - new KeyPhraseExtractionLROResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + KeyPhraseExtractionLROResult deserializedKeyPhraseExtractionLROResult = new KeyPhraseExtractionLROResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"KeyPhraseExtractionLROResults".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'KeyPhraseExtractionLROResults'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("lastUpdateDateTime".equals(fieldName)) { - deserializedKeyPhraseExtractionLROResult.setLastUpdateDateTime( - reader.getNullable( - nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); - } else if ("status".equals(fieldName)) { - deserializedKeyPhraseExtractionLROResult.setStatus(State.fromString(reader.getString())); - } else if ("taskName".equals(fieldName)) { - deserializedKeyPhraseExtractionLROResult.setTaskName(reader.getString()); - } else if ("results".equals(fieldName)) { - deserializedKeyPhraseExtractionLROResult.results = KeyPhraseResult.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("lastUpdateDateTime".equals(fieldName)) { + deserializedKeyPhraseExtractionLROResult.setLastUpdateDateTime( + reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); + } else if ("status".equals(fieldName)) { + deserializedKeyPhraseExtractionLROResult.setStatus(State.fromString(reader.getString())); + } else if ("taskName".equals(fieldName)) { + deserializedKeyPhraseExtractionLROResult.setTaskName(reader.getString()); + } else if ("results".equals(fieldName)) { + deserializedKeyPhraseExtractionLROResult.results = KeyPhraseResult.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedKeyPhraseExtractionLROResult.kind + = AnalyzeTextLROResultsKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedKeyPhraseExtractionLROResult; - }); + return deserializedKeyPhraseExtractionLROResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseLROTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseLROTask.java index 0d2fc289c7c8..e791dcf06633 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseLROTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseLROTask.java @@ -9,22 +9,41 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** An object representing the task definition for a Key Phrase Extraction task. */ +/** + * An object representing the task definition for a Key Phrase Extraction task. + */ @Fluent public final class KeyPhraseLROTask extends AnalyzeTextLROTask { + /* + * Enumeration of supported long-running Text Analysis tasks. + */ + private AnalyzeTextLROTaskKind kind = AnalyzeTextLROTaskKind.KEY_PHRASE_EXTRACTION; + /* * Supported parameters for a Key Phrase Extraction task. */ private KeyPhraseTaskParameters parameters; - /** Creates an instance of KeyPhraseLROTask class. */ - public KeyPhraseLROTask() {} + /** + * Creates an instance of KeyPhraseLROTask class. + */ + public KeyPhraseLROTask() { + } + + /** + * Get the kind property: Enumeration of supported long-running Text Analysis tasks. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROTaskKind getKind() { + return this.kind; + } /** * Get the parameters property: Supported parameters for a Key Phrase Extraction task. - * + * * @return the parameters value. */ public KeyPhraseTaskParameters getParameters() { @@ -33,7 +52,7 @@ public KeyPhraseTaskParameters getParameters() { /** * Set the parameters property: Supported parameters for a Key Phrase Extraction task. - * + * * @param parameters the parameters value to set. * @return the KeyPhraseLROTask object itself. */ @@ -42,57 +61,54 @@ public KeyPhraseLROTask setParameters(KeyPhraseTaskParameters parameters) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public KeyPhraseLROTask setTaskName(String taskName) { super.setTaskName(taskName); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("kind", Objects.toString(AnalyzeTextLROTaskKind.KEY_PHRASE_EXTRACTION, null)); jsonWriter.writeStringField("taskName", getTaskName()); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); jsonWriter.writeJsonField("parameters", this.parameters); return jsonWriter.writeEndObject(); } /** * Reads an instance of KeyPhraseLROTask from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of KeyPhraseLROTask 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 the polymorphic discriminator. + * pointing to JSON null. * @throws IOException If an error occurs while reading the KeyPhraseLROTask. */ public static KeyPhraseLROTask fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - KeyPhraseLROTask deserializedKeyPhraseLROTask = new KeyPhraseLROTask(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + KeyPhraseLROTask deserializedKeyPhraseLROTask = new KeyPhraseLROTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"KeyPhraseExtraction".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'KeyPhraseExtraction'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("taskName".equals(fieldName)) { - deserializedKeyPhraseLROTask.setTaskName(reader.getString()); - } else if ("parameters".equals(fieldName)) { - deserializedKeyPhraseLROTask.parameters = KeyPhraseTaskParameters.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("taskName".equals(fieldName)) { + deserializedKeyPhraseLROTask.setTaskName(reader.getString()); + } else if ("kind".equals(fieldName)) { + deserializedKeyPhraseLROTask.kind = AnalyzeTextLROTaskKind.fromString(reader.getString()); + } else if ("parameters".equals(fieldName)) { + deserializedKeyPhraseLROTask.parameters = KeyPhraseTaskParameters.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedKeyPhraseLROTask; - }); + return deserializedKeyPhraseLROTask; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseResult.java index f929f9468b69..e12100459c39 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseResult.java @@ -11,7 +11,9 @@ import java.io.IOException; import java.util.List; -/** The KeyPhraseResult model. */ +/** + * The KeyPhraseResult model. + */ @Fluent public final class KeyPhraseResult extends PreBuiltResult { /* @@ -19,12 +21,15 @@ public final class KeyPhraseResult extends PreBuiltResult { */ private List documents; - /** Creates an instance of KeyPhraseResult class. */ - public KeyPhraseResult() {} + /** + * Creates an instance of KeyPhraseResult class. + */ + public KeyPhraseResult() { + } /** * Get the documents property: Response by document. - * + * * @return the documents value. */ public List getDocuments() { @@ -33,7 +38,7 @@ public List getDocuments() { /** * Set the documents property: Response by document. - * + * * @param documents the documents value to set. * @return the KeyPhraseResult object itself. */ @@ -42,27 +47,36 @@ public KeyPhraseResult setDocuments(List documents return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public KeyPhraseResult setErrors(List errors) { super.setErrors(errors); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public KeyPhraseResult setStatistics(RequestStatistics statistics) { super.setStatistics(statistics); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public KeyPhraseResult setModelVersion(String modelVersion) { super.setModelVersion(modelVersion); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -75,38 +89,37 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of KeyPhraseResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of KeyPhraseResult if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 KeyPhraseResult. */ public static KeyPhraseResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - KeyPhraseResult deserializedKeyPhraseResult = new KeyPhraseResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + KeyPhraseResult deserializedKeyPhraseResult = new KeyPhraseResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("errors".equals(fieldName)) { - List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); - deserializedKeyPhraseResult.setErrors(errors); - } else if ("modelVersion".equals(fieldName)) { - deserializedKeyPhraseResult.setModelVersion(reader.getString()); - } else if ("statistics".equals(fieldName)) { - deserializedKeyPhraseResult.setStatistics(RequestStatistics.fromJson(reader)); - } else if ("documents".equals(fieldName)) { - List documents = - reader.readArray(reader1 -> KeyPhraseResultDocumentsItem.fromJson(reader1)); - deserializedKeyPhraseResult.documents = documents; - } else { - reader.skipChildren(); - } - } + if ("errors".equals(fieldName)) { + List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); + deserializedKeyPhraseResult.setErrors(errors); + } else if ("modelVersion".equals(fieldName)) { + deserializedKeyPhraseResult.setModelVersion(reader.getString()); + } else if ("statistics".equals(fieldName)) { + deserializedKeyPhraseResult.setStatistics(RequestStatistics.fromJson(reader)); + } else if ("documents".equals(fieldName)) { + List documents + = reader.readArray(reader1 -> KeyPhraseResultDocumentsItem.fromJson(reader1)); + deserializedKeyPhraseResult.documents = documents; + } else { + reader.skipChildren(); + } + } - return deserializedKeyPhraseResult; - }); + return deserializedKeyPhraseResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseResultDocumentsItem.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseResultDocumentsItem.java index 906dfe0e58eb..45a4611a5808 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseResultDocumentsItem.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseResultDocumentsItem.java @@ -11,40 +11,56 @@ import java.io.IOException; import java.util.List; -/** The KeyPhraseResultDocumentsItem model. */ +/** + * The KeyPhraseResultDocumentsItem model. + */ @Fluent public final class KeyPhraseResultDocumentsItem extends KeyPhrasesDocumentResult { - /** Creates an instance of KeyPhraseResultDocumentsItem class. */ - public KeyPhraseResultDocumentsItem() {} + /** + * Creates an instance of KeyPhraseResultDocumentsItem class. + */ + public KeyPhraseResultDocumentsItem() { + } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public KeyPhraseResultDocumentsItem setKeyPhrases(List keyPhrases) { super.setKeyPhrases(keyPhrases); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public KeyPhraseResultDocumentsItem setId(String id) { super.setId(id); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public KeyPhraseResultDocumentsItem setWarnings(List warnings) { super.setWarnings(warnings); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public KeyPhraseResultDocumentsItem setStatistics(DocumentStatistics statistics) { super.setStatistics(statistics); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -57,39 +73,36 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of KeyPhraseResultDocumentsItem from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of KeyPhraseResultDocumentsItem if the JsonReader was pointing to an instance of it, or null - * if it was pointing to JSON 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 KeyPhraseResultDocumentsItem. */ public static KeyPhraseResultDocumentsItem fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - KeyPhraseResultDocumentsItem deserializedKeyPhraseResultDocumentsItem = - new KeyPhraseResultDocumentsItem(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + KeyPhraseResultDocumentsItem deserializedKeyPhraseResultDocumentsItem = new KeyPhraseResultDocumentsItem(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("id".equals(fieldName)) { - deserializedKeyPhraseResultDocumentsItem.setId(reader.getString()); - } else if ("warnings".equals(fieldName)) { - List warnings = - reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); - deserializedKeyPhraseResultDocumentsItem.setWarnings(warnings); - } else if ("keyPhrases".equals(fieldName)) { - List keyPhrases = reader.readArray(reader1 -> reader1.getString()); - deserializedKeyPhraseResultDocumentsItem.setKeyPhrases(keyPhrases); - } else if ("statistics".equals(fieldName)) { - deserializedKeyPhraseResultDocumentsItem.setStatistics(DocumentStatistics.fromJson(reader)); - } else { - reader.skipChildren(); - } - } + if ("id".equals(fieldName)) { + deserializedKeyPhraseResultDocumentsItem.setId(reader.getString()); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedKeyPhraseResultDocumentsItem.setWarnings(warnings); + } else if ("keyPhrases".equals(fieldName)) { + List keyPhrases = reader.readArray(reader1 -> reader1.getString()); + deserializedKeyPhraseResultDocumentsItem.setKeyPhrases(keyPhrases); + } else if ("statistics".equals(fieldName)) { + deserializedKeyPhraseResultDocumentsItem.setStatistics(DocumentStatistics.fromJson(reader)); + } else { + reader.skipChildren(); + } + } - return deserializedKeyPhraseResultDocumentsItem; - }); + return deserializedKeyPhraseResultDocumentsItem; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseTaskParameters.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseTaskParameters.java index 59ad7e2b62fa..1db4e03c0573 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseTaskParameters.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseTaskParameters.java @@ -10,26 +10,38 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** Supported parameters for a Key Phrase Extraction task. */ +/** + * Supported parameters for a Key Phrase Extraction task. + */ @Fluent public final class KeyPhraseTaskParameters extends PreBuiltTaskParameters { - /** Creates an instance of KeyPhraseTaskParameters class. */ - public KeyPhraseTaskParameters() {} + /** + * Creates an instance of KeyPhraseTaskParameters class. + */ + public KeyPhraseTaskParameters() { + } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public KeyPhraseTaskParameters setModelVersion(String modelVersion) { super.setModelVersion(modelVersion); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public KeyPhraseTaskParameters setLoggingOptOut(Boolean loggingOptOut) { super.setLoggingOptOut(loggingOptOut); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -40,31 +52,29 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of KeyPhraseTaskParameters from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of KeyPhraseTaskParameters if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. + * was pointing to JSON null. * @throws IOException If an error occurs while reading the KeyPhraseTaskParameters. */ public static KeyPhraseTaskParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - KeyPhraseTaskParameters deserializedKeyPhraseTaskParameters = new KeyPhraseTaskParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + KeyPhraseTaskParameters deserializedKeyPhraseTaskParameters = new KeyPhraseTaskParameters(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("loggingOptOut".equals(fieldName)) { - deserializedKeyPhraseTaskParameters.setLoggingOptOut( - reader.getNullable(JsonReader::getBoolean)); - } else if ("modelVersion".equals(fieldName)) { - deserializedKeyPhraseTaskParameters.setModelVersion(reader.getString()); - } else { - reader.skipChildren(); - } - } + if ("loggingOptOut".equals(fieldName)) { + deserializedKeyPhraseTaskParameters.setLoggingOptOut(reader.getNullable(JsonReader::getBoolean)); + } else if ("modelVersion".equals(fieldName)) { + deserializedKeyPhraseTaskParameters.setModelVersion(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedKeyPhraseTaskParameters; - }); + return deserializedKeyPhraseTaskParameters; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseTaskResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseTaskResult.java index af66fb21721a..d3eba8f823ac 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseTaskResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhraseTaskResult.java @@ -9,22 +9,41 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** The KeyPhraseTaskResult model. */ +/** + * The KeyPhraseTaskResult model. + */ @Fluent public final class KeyPhraseTaskResult extends AnalyzeTextTaskResult { + /* + * Enumeration of supported Text Analysis task results. + */ + private AnalyzeTextTaskResultsKind kind = AnalyzeTextTaskResultsKind.KEY_PHRASE_EXTRACTION_RESULTS; + /* * The results property. */ private KeyPhraseResult results; - /** Creates an instance of KeyPhraseTaskResult class. */ - public KeyPhraseTaskResult() {} + /** + * Creates an instance of KeyPhraseTaskResult class. + */ + public KeyPhraseTaskResult() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis task results. + * + * @return the kind value. + */ + @Override + public AnalyzeTextTaskResultsKind getKind() { + return this.kind; + } /** * Get the results property: The results property. - * + * * @return the results value. */ public KeyPhraseResult getResults() { @@ -33,7 +52,7 @@ public KeyPhraseResult getResults() { /** * Set the results property: The results property. - * + * * @param results the results value to set. * @return the KeyPhraseTaskResult object itself. */ @@ -42,49 +61,43 @@ public KeyPhraseTaskResult setResults(KeyPhraseResult results) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField( - "kind", Objects.toString(AnalyzeTextTaskResultsKind.KEY_PHRASE_EXTRACTION_RESULTS, null)); jsonWriter.writeJsonField("results", this.results); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of KeyPhraseTaskResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of KeyPhraseTaskResult 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 or the - * polymorphic discriminator. + * 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 KeyPhraseTaskResult. */ public static KeyPhraseTaskResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - KeyPhraseTaskResult deserializedKeyPhraseTaskResult = new KeyPhraseTaskResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + KeyPhraseTaskResult deserializedKeyPhraseTaskResult = new KeyPhraseTaskResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"KeyPhraseExtractionResults".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'KeyPhraseExtractionResults'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("results".equals(fieldName)) { - deserializedKeyPhraseTaskResult.results = KeyPhraseResult.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("results".equals(fieldName)) { + deserializedKeyPhraseTaskResult.results = KeyPhraseResult.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedKeyPhraseTaskResult.kind = AnalyzeTextTaskResultsKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedKeyPhraseTaskResult; - }); + return deserializedKeyPhraseTaskResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhrasesDocumentResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhrasesDocumentResult.java index 12c734e347df..65020e45d3a9 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhrasesDocumentResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhrasesDocumentResult.java @@ -11,22 +11,26 @@ import java.io.IOException; import java.util.List; -/** The KeyPhrasesDocumentResult model. */ +/** + * The KeyPhrasesDocumentResult model. + */ @Fluent public class KeyPhrasesDocumentResult extends DocumentResult { /* - * A list of representative words or phrases. The number of key phrases returned is proportional to the number of - * words in the input document. + * A list of representative words or phrases. The number of key phrases returned is proportional to the number of words in the input document. */ private List keyPhrases; - /** Creates an instance of KeyPhrasesDocumentResult class. */ - public KeyPhrasesDocumentResult() {} + /** + * Creates an instance of KeyPhrasesDocumentResult class. + */ + public KeyPhrasesDocumentResult() { + } /** * Get the keyPhrases property: A list of representative words or phrases. The number of key phrases returned is * proportional to the number of words in the input document. - * + * * @return the keyPhrases value. */ public List getKeyPhrases() { @@ -36,7 +40,7 @@ public List getKeyPhrases() { /** * Set the keyPhrases property: A list of representative words or phrases. The number of key phrases returned is * proportional to the number of words in the input document. - * + * * @param keyPhrases the keyPhrases value to set. * @return the KeyPhrasesDocumentResult object itself. */ @@ -45,27 +49,36 @@ public KeyPhrasesDocumentResult setKeyPhrases(List keyPhrases) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public KeyPhrasesDocumentResult setId(String id) { super.setId(id); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public KeyPhrasesDocumentResult setWarnings(List warnings) { super.setWarnings(warnings); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public KeyPhrasesDocumentResult setStatistics(DocumentStatistics statistics) { super.setStatistics(statistics); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -78,38 +91,36 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of KeyPhrasesDocumentResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of KeyPhrasesDocumentResult if the JsonReader was pointing to an instance of it, or null if - * it was pointing to JSON null. + * 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 KeyPhrasesDocumentResult. */ public static KeyPhrasesDocumentResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - KeyPhrasesDocumentResult deserializedKeyPhrasesDocumentResult = new KeyPhrasesDocumentResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + KeyPhrasesDocumentResult deserializedKeyPhrasesDocumentResult = new KeyPhrasesDocumentResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("id".equals(fieldName)) { - deserializedKeyPhrasesDocumentResult.setId(reader.getString()); - } else if ("warnings".equals(fieldName)) { - List warnings = - reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); - deserializedKeyPhrasesDocumentResult.setWarnings(warnings); - } else if ("statistics".equals(fieldName)) { - deserializedKeyPhrasesDocumentResult.setStatistics(DocumentStatistics.fromJson(reader)); - } else if ("keyPhrases".equals(fieldName)) { - List keyPhrases = reader.readArray(reader1 -> reader1.getString()); - deserializedKeyPhrasesDocumentResult.keyPhrases = keyPhrases; - } else { - reader.skipChildren(); - } - } + if ("id".equals(fieldName)) { + deserializedKeyPhrasesDocumentResult.setId(reader.getString()); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedKeyPhrasesDocumentResult.setWarnings(warnings); + } else if ("statistics".equals(fieldName)) { + deserializedKeyPhrasesDocumentResult.setStatistics(DocumentStatistics.fromJson(reader)); + } else if ("keyPhrases".equals(fieldName)) { + List keyPhrases = reader.readArray(reader1 -> reader1.getString()); + deserializedKeyPhrasesDocumentResult.keyPhrases = keyPhrases; + } else { + reader.skipChildren(); + } + } - return deserializedKeyPhrasesDocumentResult; - }); + return deserializedKeyPhrasesDocumentResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhrasesTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhrasesTask.java index cc44a728d580..7afab02dbd76 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhrasesTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/KeyPhrasesTask.java @@ -1,25 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 KeyPhrasesTask model. */ @Fluent -public final class KeyPhrasesTask { +public final class KeyPhrasesTask implements JsonSerializable { /* * The parameters property. */ - @JsonProperty(value = "parameters") private KeyPhraseTaskParameters parameters; /* * The taskName property. */ - @JsonProperty(value = "taskName") private String taskName; /** @@ -61,4 +63,44 @@ public KeyPhrasesTask setTaskName(String taskName) { this.taskName = taskName; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("parameters", parameters); + jsonWriter.writeStringField("taskName", this.taskName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of KeyPhrasesTask from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of KeyPhrasesTask 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 KeyPhrasesTask. + */ + public static KeyPhrasesTask fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + KeyPhrasesTask deserializedKeyPhrasesTask = new KeyPhrasesTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("parameters".equals(fieldName)) { + deserializedKeyPhrasesTask.parameters = KeyPhraseTaskParameters.fromJson(reader); + } else if ("taskName".equals(fieldName)) { + deserializedKeyPhrasesTask.taskName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedKeyPhrasesTask; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageBatchInput.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageBatchInput.java index 2e1bde460b17..b90070583acf 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageBatchInput.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageBatchInput.java @@ -1,20 +1,23 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 LanguageBatchInput model. */ @Fluent -public final class LanguageBatchInput { +public final class LanguageBatchInput implements JsonSerializable { /* * The documents property. */ - @JsonProperty(value = "documents", required = true) private List documents; /** @@ -36,4 +39,42 @@ public LanguageBatchInput setDocuments(List documents) { this.documents = documents; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("documents", this.documents, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of LanguageBatchInput from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of LanguageBatchInput 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 LanguageBatchInput. + */ + public static LanguageBatchInput fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + LanguageBatchInput deserializedLanguageBatchInput = new LanguageBatchInput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("documents".equals(fieldName)) { + deserializedLanguageBatchInput.documents = + reader.readArray(reader1 -> LanguageInput.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + + return deserializedLanguageBatchInput; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageDetectionAnalysisInput.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageDetectionAnalysisInput.java index b14693e4f0d7..48a24c3506a4 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageDetectionAnalysisInput.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageDetectionAnalysisInput.java @@ -12,7 +12,9 @@ import java.io.IOException; import java.util.List; -/** The LanguageDetectionAnalysisInput model. */ +/** + * The LanguageDetectionAnalysisInput model. + */ @Fluent public final class LanguageDetectionAnalysisInput implements JsonSerializable { /* @@ -20,12 +22,15 @@ public final class LanguageDetectionAnalysisInput implements JsonSerializable documents; - /** Creates an instance of LanguageDetectionAnalysisInput class. */ - public LanguageDetectionAnalysisInput() {} + /** + * Creates an instance of LanguageDetectionAnalysisInput class. + */ + public LanguageDetectionAnalysisInput() { + } /** * Get the documents property: The documents property. - * + * * @return the documents value. */ public List getDocuments() { @@ -34,7 +39,7 @@ public List getDocuments() { /** * Set the documents property: The documents property. - * + * * @param documents the documents value to set. * @return the LanguageDetectionAnalysisInput object itself. */ @@ -43,6 +48,9 @@ public LanguageDetectionAnalysisInput setDocuments(List documents return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -52,31 +60,29 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of LanguageDetectionAnalysisInput from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of LanguageDetectionAnalysisInput if the JsonReader was pointing to an instance of it, or - * null if it was pointing to JSON null. + * null if it was pointing to JSON null. * @throws IOException If an error occurs while reading the LanguageDetectionAnalysisInput. */ public static LanguageDetectionAnalysisInput fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - LanguageDetectionAnalysisInput deserializedLanguageDetectionAnalysisInput = - new LanguageDetectionAnalysisInput(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + LanguageDetectionAnalysisInput deserializedLanguageDetectionAnalysisInput + = new LanguageDetectionAnalysisInput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("documents".equals(fieldName)) { - List documents = - reader.readArray(reader1 -> LanguageInput.fromJson(reader1)); - deserializedLanguageDetectionAnalysisInput.documents = documents; - } else { - reader.skipChildren(); - } - } + if ("documents".equals(fieldName)) { + List documents = reader.readArray(reader1 -> LanguageInput.fromJson(reader1)); + deserializedLanguageDetectionAnalysisInput.documents = documents; + } else { + reader.skipChildren(); + } + } - return deserializedLanguageDetectionAnalysisInput; - }); + return deserializedLanguageDetectionAnalysisInput; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageDetectionDocumentResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageDetectionDocumentResult.java index db71c721b46d..f95677b9fe73 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageDetectionDocumentResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageDetectionDocumentResult.java @@ -11,7 +11,9 @@ import java.io.IOException; import java.util.List; -/** The LanguageDetectionDocumentResult model. */ +/** + * The LanguageDetectionDocumentResult model. + */ @Fluent public final class LanguageDetectionDocumentResult extends DocumentResult { /* @@ -19,12 +21,15 @@ public final class LanguageDetectionDocumentResult extends DocumentResult { */ private DetectedLanguage detectedLanguage; - /** Creates an instance of LanguageDetectionDocumentResult class. */ - public LanguageDetectionDocumentResult() {} + /** + * Creates an instance of LanguageDetectionDocumentResult class. + */ + public LanguageDetectionDocumentResult() { + } /** * Get the detectedLanguage property: Detected Language. - * + * * @return the detectedLanguage value. */ public DetectedLanguage getDetectedLanguage() { @@ -33,7 +38,7 @@ public DetectedLanguage getDetectedLanguage() { /** * Set the detectedLanguage property: Detected Language. - * + * * @param detectedLanguage the detectedLanguage value to set. * @return the LanguageDetectionDocumentResult object itself. */ @@ -42,27 +47,36 @@ public LanguageDetectionDocumentResult setDetectedLanguage(DetectedLanguage dete return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public LanguageDetectionDocumentResult setId(String id) { super.setId(id); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public LanguageDetectionDocumentResult setWarnings(List warnings) { super.setWarnings(warnings); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public LanguageDetectionDocumentResult setStatistics(DocumentStatistics statistics) { super.setStatistics(statistics); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -75,40 +89,36 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of LanguageDetectionDocumentResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of LanguageDetectionDocumentResult if the JsonReader was pointing to an instance of it, or - * null if it was pointing to JSON null. + * 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 LanguageDetectionDocumentResult. */ public static LanguageDetectionDocumentResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - LanguageDetectionDocumentResult deserializedLanguageDetectionDocumentResult = - new LanguageDetectionDocumentResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + LanguageDetectionDocumentResult deserializedLanguageDetectionDocumentResult + = new LanguageDetectionDocumentResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("id".equals(fieldName)) { - deserializedLanguageDetectionDocumentResult.setId(reader.getString()); - } else if ("warnings".equals(fieldName)) { - List warnings = - reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); - deserializedLanguageDetectionDocumentResult.setWarnings(warnings); - } else if ("statistics".equals(fieldName)) { - deserializedLanguageDetectionDocumentResult.setStatistics( - DocumentStatistics.fromJson(reader)); - } else if ("detectedLanguage".equals(fieldName)) { - deserializedLanguageDetectionDocumentResult.detectedLanguage = - DetectedLanguage.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("id".equals(fieldName)) { + deserializedLanguageDetectionDocumentResult.setId(reader.getString()); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedLanguageDetectionDocumentResult.setWarnings(warnings); + } else if ("statistics".equals(fieldName)) { + deserializedLanguageDetectionDocumentResult.setStatistics(DocumentStatistics.fromJson(reader)); + } else if ("detectedLanguage".equals(fieldName)) { + deserializedLanguageDetectionDocumentResult.detectedLanguage = DetectedLanguage.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedLanguageDetectionDocumentResult; - }); + return deserializedLanguageDetectionDocumentResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageDetectionResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageDetectionResult.java index 016999f36c01..e2bf226fe160 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageDetectionResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageDetectionResult.java @@ -11,7 +11,9 @@ import java.io.IOException; import java.util.List; -/** The LanguageDetectionResult model. */ +/** + * The LanguageDetectionResult model. + */ @Fluent public final class LanguageDetectionResult extends PreBuiltResult { /* @@ -19,12 +21,15 @@ public final class LanguageDetectionResult extends PreBuiltResult { */ private List documents; - /** Creates an instance of LanguageDetectionResult class. */ - public LanguageDetectionResult() {} + /** + * Creates an instance of LanguageDetectionResult class. + */ + public LanguageDetectionResult() { + } /** * Get the documents property: Response by document. - * + * * @return the documents value. */ public List getDocuments() { @@ -33,7 +38,7 @@ public List getDocuments() { /** * Set the documents property: Response by document. - * + * * @param documents the documents value to set. * @return the LanguageDetectionResult object itself. */ @@ -42,27 +47,36 @@ public LanguageDetectionResult setDocuments(List errors) { super.setErrors(errors); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public LanguageDetectionResult setStatistics(RequestStatistics statistics) { super.setStatistics(statistics); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public LanguageDetectionResult setModelVersion(String modelVersion) { super.setModelVersion(modelVersion); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -75,38 +89,37 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of LanguageDetectionResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of LanguageDetectionResult if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. + * 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 LanguageDetectionResult. */ public static LanguageDetectionResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - LanguageDetectionResult deserializedLanguageDetectionResult = new LanguageDetectionResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + LanguageDetectionResult deserializedLanguageDetectionResult = new LanguageDetectionResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("errors".equals(fieldName)) { - List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); - deserializedLanguageDetectionResult.setErrors(errors); - } else if ("modelVersion".equals(fieldName)) { - deserializedLanguageDetectionResult.setModelVersion(reader.getString()); - } else if ("statistics".equals(fieldName)) { - deserializedLanguageDetectionResult.setStatistics(RequestStatistics.fromJson(reader)); - } else if ("documents".equals(fieldName)) { - List documents = - reader.readArray(reader1 -> LanguageDetectionDocumentResult.fromJson(reader1)); - deserializedLanguageDetectionResult.documents = documents; - } else { - reader.skipChildren(); - } - } + if ("errors".equals(fieldName)) { + List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); + deserializedLanguageDetectionResult.setErrors(errors); + } else if ("modelVersion".equals(fieldName)) { + deserializedLanguageDetectionResult.setModelVersion(reader.getString()); + } else if ("statistics".equals(fieldName)) { + deserializedLanguageDetectionResult.setStatistics(RequestStatistics.fromJson(reader)); + } else if ("documents".equals(fieldName)) { + List documents + = reader.readArray(reader1 -> LanguageDetectionDocumentResult.fromJson(reader1)); + deserializedLanguageDetectionResult.documents = documents; + } else { + reader.skipChildren(); + } + } - return deserializedLanguageDetectionResult; - }); + return deserializedLanguageDetectionResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageDetectionTaskParameters.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageDetectionTaskParameters.java index 69729667aa69..8eafb514de6a 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageDetectionTaskParameters.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageDetectionTaskParameters.java @@ -10,26 +10,38 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** Supported parameters for a Language Detection task. */ +/** + * Supported parameters for a Language Detection task. + */ @Fluent public final class LanguageDetectionTaskParameters extends PreBuiltTaskParameters { - /** Creates an instance of LanguageDetectionTaskParameters class. */ - public LanguageDetectionTaskParameters() {} + /** + * Creates an instance of LanguageDetectionTaskParameters class. + */ + public LanguageDetectionTaskParameters() { + } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public LanguageDetectionTaskParameters setModelVersion(String modelVersion) { super.setModelVersion(modelVersion); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public LanguageDetectionTaskParameters setLoggingOptOut(Boolean loggingOptOut) { super.setLoggingOptOut(loggingOptOut); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -40,32 +52,31 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of LanguageDetectionTaskParameters from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of LanguageDetectionTaskParameters if the JsonReader was pointing to an instance of it, or - * null if it was pointing to JSON null. + * null if it was pointing to JSON null. * @throws IOException If an error occurs while reading the LanguageDetectionTaskParameters. */ public static LanguageDetectionTaskParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - LanguageDetectionTaskParameters deserializedLanguageDetectionTaskParameters = - new LanguageDetectionTaskParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + LanguageDetectionTaskParameters deserializedLanguageDetectionTaskParameters + = new LanguageDetectionTaskParameters(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("loggingOptOut".equals(fieldName)) { - deserializedLanguageDetectionTaskParameters.setLoggingOptOut( - reader.getNullable(JsonReader::getBoolean)); - } else if ("modelVersion".equals(fieldName)) { - deserializedLanguageDetectionTaskParameters.setModelVersion(reader.getString()); - } else { - reader.skipChildren(); - } - } + if ("loggingOptOut".equals(fieldName)) { + deserializedLanguageDetectionTaskParameters + .setLoggingOptOut(reader.getNullable(JsonReader::getBoolean)); + } else if ("modelVersion".equals(fieldName)) { + deserializedLanguageDetectionTaskParameters.setModelVersion(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedLanguageDetectionTaskParameters; - }); + return deserializedLanguageDetectionTaskParameters; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageDetectionTaskResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageDetectionTaskResult.java index eeff5be97fde..f6b3c8faa0bc 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageDetectionTaskResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageDetectionTaskResult.java @@ -9,22 +9,41 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** The LanguageDetectionTaskResult model. */ +/** + * The LanguageDetectionTaskResult model. + */ @Fluent public final class LanguageDetectionTaskResult extends AnalyzeTextTaskResult { + /* + * Enumeration of supported Text Analysis task results. + */ + private AnalyzeTextTaskResultsKind kind = AnalyzeTextTaskResultsKind.LANGUAGE_DETECTION_RESULTS; + /* * The results property. */ private LanguageDetectionResult results; - /** Creates an instance of LanguageDetectionTaskResult class. */ - public LanguageDetectionTaskResult() {} + /** + * Creates an instance of LanguageDetectionTaskResult class. + */ + public LanguageDetectionTaskResult() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis task results. + * + * @return the kind value. + */ + @Override + public AnalyzeTextTaskResultsKind getKind() { + return this.kind; + } /** * Get the results property: The results property. - * + * * @return the results value. */ public LanguageDetectionResult getResults() { @@ -33,7 +52,7 @@ public LanguageDetectionResult getResults() { /** * Set the results property: The results property. - * + * * @param results the results value to set. * @return the LanguageDetectionTaskResult object itself. */ @@ -42,50 +61,44 @@ public LanguageDetectionTaskResult setResults(LanguageDetectionResult results) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField( - "kind", Objects.toString(AnalyzeTextTaskResultsKind.LANGUAGE_DETECTION_RESULTS, null)); jsonWriter.writeJsonField("results", this.results); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of LanguageDetectionTaskResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of LanguageDetectionTaskResult 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 or the - * polymorphic discriminator. + * 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 LanguageDetectionTaskResult. */ public static LanguageDetectionTaskResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - LanguageDetectionTaskResult deserializedLanguageDetectionTaskResult = - new LanguageDetectionTaskResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + LanguageDetectionTaskResult deserializedLanguageDetectionTaskResult = new LanguageDetectionTaskResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"LanguageDetectionResults".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'LanguageDetectionResults'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("results".equals(fieldName)) { - deserializedLanguageDetectionTaskResult.results = LanguageDetectionResult.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("results".equals(fieldName)) { + deserializedLanguageDetectionTaskResult.results = LanguageDetectionResult.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedLanguageDetectionTaskResult.kind + = AnalyzeTextTaskResultsKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedLanguageDetectionTaskResult; - }); + return deserializedLanguageDetectionTaskResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageInput.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageInput.java index c4765e23991c..8e6e12cf162f 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageInput.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageInput.java @@ -11,7 +11,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** The LanguageInput model. */ +/** + * The LanguageInput model. + */ @Fluent public final class LanguageInput implements JsonSerializable { /* @@ -29,12 +31,15 @@ public final class LanguageInput implements JsonSerializable { */ private String countryHint; - /** Creates an instance of LanguageInput class. */ - public LanguageInput() {} + /** + * Creates an instance of LanguageInput class. + */ + public LanguageInput() { + } /** * Get the id property: Unique, non-empty document identifier. - * + * * @return the id value. */ public String getId() { @@ -43,7 +48,7 @@ public String getId() { /** * Set the id property: Unique, non-empty document identifier. - * + * * @param id the id value to set. * @return the LanguageInput object itself. */ @@ -54,7 +59,7 @@ public LanguageInput setId(String id) { /** * Get the text property: The text property. - * + * * @return the text value. */ public String getText() { @@ -63,7 +68,7 @@ public String getText() { /** * Set the text property: The text property. - * + * * @param text the text value to set. * @return the LanguageInput object itself. */ @@ -74,7 +79,7 @@ public LanguageInput setText(String text) { /** * Get the countryHint property: The countryHint property. - * + * * @return the countryHint value. */ public String getCountryHint() { @@ -83,7 +88,7 @@ public String getCountryHint() { /** * Set the countryHint property: The countryHint property. - * + * * @param countryHint the countryHint value to set. * @return the LanguageInput object itself. */ @@ -92,6 +97,9 @@ public LanguageInput setCountryHint(String countryHint) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -103,33 +111,32 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of LanguageInput from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of LanguageInput if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 LanguageInput. */ public static LanguageInput fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - LanguageInput deserializedLanguageInput = new LanguageInput(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - deserializedLanguageInput.id = reader.getString(); - } else if ("text".equals(fieldName)) { - deserializedLanguageInput.text = reader.getString(); - } else if ("countryHint".equals(fieldName)) { - deserializedLanguageInput.countryHint = reader.getString(); - } else { - reader.skipChildren(); - } - } - - return deserializedLanguageInput; - }); + return jsonReader.readObject(reader -> { + LanguageInput deserializedLanguageInput = new LanguageInput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedLanguageInput.id = reader.getString(); + } else if ("text".equals(fieldName)) { + deserializedLanguageInput.text = reader.getString(); + } else if ("countryHint".equals(fieldName)) { + deserializedLanguageInput.countryHint = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedLanguageInput; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageResult.java index be55cd24b5d2..91d3a548f37f 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LanguageResult.java @@ -1,39 +1,39 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 LanguageResult model. */ @Fluent -public final class LanguageResult { +public final class LanguageResult implements JsonSerializable { /* * Response by document */ - @JsonProperty(value = "documents", required = true) private List documents; /* * Errors by document id. */ - @JsonProperty(value = "errors", required = true) private List errors; /* * if showStats=true was specified in the request this field will contain * information about the request payload. */ - @JsonProperty(value = "statistics") private RequestStatistics statistics; /* * This field indicates which model is used for scoring. */ - @JsonProperty(value = "modelVersion", required = true) private String modelVersion; /** @@ -117,4 +117,49 @@ public LanguageResult setModelVersion(String modelVersion) { this.modelVersion = modelVersion; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("documents", this.documents, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("errors", this.errors, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("statistics", this.statistics); + jsonWriter.writeStringField("modelVersion", this.modelVersion); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of LanguageResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of LanguageResult 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 LanguageResult. + */ + public static LanguageResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + LanguageResult deserializedLanguageResult = new LanguageResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("documents".equals(fieldName)) { + deserializedLanguageResult.documents = reader.readArray(reader1 -> DocumentLanguage.fromJson(reader1)); + } else if ("errors".equals(fieldName)) { + deserializedLanguageResult.errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); + } else if ("statistics".equals(fieldName)) { + deserializedLanguageResult.statistics = RequestStatistics.fromJson(reader); + } else if ("modelVersion".equals(fieldName)) { + deserializedLanguageResult.modelVersion = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedLanguageResult; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LinkedEntitiesDocumentResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LinkedEntitiesDocumentResult.java index fa4a59faf2ea..a7cc11c3ac26 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LinkedEntitiesDocumentResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LinkedEntitiesDocumentResult.java @@ -11,7 +11,9 @@ import java.io.IOException; import java.util.List; -/** The LinkedEntitiesDocumentResult model. */ +/** + * The LinkedEntitiesDocumentResult model. + */ @Fluent public class LinkedEntitiesDocumentResult extends DocumentResult { /* @@ -19,12 +21,15 @@ public class LinkedEntitiesDocumentResult extends DocumentResult { */ private List entities; - /** Creates an instance of LinkedEntitiesDocumentResult class. */ - public LinkedEntitiesDocumentResult() {} + /** + * Creates an instance of LinkedEntitiesDocumentResult class. + */ + public LinkedEntitiesDocumentResult() { + } /** * Get the entities property: Recognized well known entities in the document. - * + * * @return the entities value. */ public List getEntities() { @@ -33,7 +38,7 @@ public List getEntities() { /** * Set the entities property: Recognized well known entities in the document. - * + * * @param entities the entities value to set. * @return the LinkedEntitiesDocumentResult object itself. */ @@ -42,27 +47,36 @@ public LinkedEntitiesDocumentResult setEntities(List entities) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public LinkedEntitiesDocumentResult setId(String id) { super.setId(id); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public LinkedEntitiesDocumentResult setWarnings(List warnings) { super.setWarnings(warnings); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public LinkedEntitiesDocumentResult setStatistics(DocumentStatistics statistics) { super.setStatistics(statistics); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -75,39 +89,36 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of LinkedEntitiesDocumentResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of LinkedEntitiesDocumentResult if the JsonReader was pointing to an instance of it, or null - * if it was pointing to JSON 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 LinkedEntitiesDocumentResult. */ public static LinkedEntitiesDocumentResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - LinkedEntitiesDocumentResult deserializedLinkedEntitiesDocumentResult = - new LinkedEntitiesDocumentResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + LinkedEntitiesDocumentResult deserializedLinkedEntitiesDocumentResult = new LinkedEntitiesDocumentResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("id".equals(fieldName)) { - deserializedLinkedEntitiesDocumentResult.setId(reader.getString()); - } else if ("warnings".equals(fieldName)) { - List warnings = - reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); - deserializedLinkedEntitiesDocumentResult.setWarnings(warnings); - } else if ("statistics".equals(fieldName)) { - deserializedLinkedEntitiesDocumentResult.setStatistics(DocumentStatistics.fromJson(reader)); - } else if ("entities".equals(fieldName)) { - List entities = reader.readArray(reader1 -> LinkedEntity.fromJson(reader1)); - deserializedLinkedEntitiesDocumentResult.entities = entities; - } else { - reader.skipChildren(); - } - } + if ("id".equals(fieldName)) { + deserializedLinkedEntitiesDocumentResult.setId(reader.getString()); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedLinkedEntitiesDocumentResult.setWarnings(warnings); + } else if ("statistics".equals(fieldName)) { + deserializedLinkedEntitiesDocumentResult.setStatistics(DocumentStatistics.fromJson(reader)); + } else if ("entities".equals(fieldName)) { + List entities = reader.readArray(reader1 -> LinkedEntity.fromJson(reader1)); + deserializedLinkedEntitiesDocumentResult.entities = entities; + } else { + reader.skipChildren(); + } + } - return deserializedLinkedEntitiesDocumentResult; - }); + return deserializedLinkedEntitiesDocumentResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LinkedEntity.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LinkedEntity.java index d0982a8e26d9..52f46d8a96a9 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LinkedEntity.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/LinkedEntity.java @@ -12,7 +12,9 @@ import java.io.IOException; import java.util.List; -/** The LinkedEntity model. */ +/** + * The LinkedEntity model. + */ @Fluent public final class LinkedEntity implements JsonSerializable { /* @@ -50,12 +52,15 @@ public final class LinkedEntity implements JsonSerializable { */ private String bingId; - /** Creates an instance of LinkedEntity class. */ - public LinkedEntity() {} + /** + * Creates an instance of LinkedEntity class. + */ + public LinkedEntity() { + } /** * Get the name property: Entity Linking formal name. - * + * * @return the name value. */ public String getName() { @@ -64,7 +69,7 @@ public String getName() { /** * Set the name property: Entity Linking formal name. - * + * * @param name the name value to set. * @return the LinkedEntity object itself. */ @@ -75,7 +80,7 @@ public LinkedEntity setName(String name) { /** * Get the matches property: List of instances this entity appears in the text. - * + * * @return the matches value. */ public List getMatches() { @@ -84,7 +89,7 @@ public List getMatches() { /** * Set the matches property: List of instances this entity appears in the text. - * + * * @param matches the matches value to set. * @return the LinkedEntity object itself. */ @@ -95,7 +100,7 @@ public LinkedEntity setMatches(List matches) { /** * Get the language property: Language used in the data source. - * + * * @return the language value. */ public String getLanguage() { @@ -104,7 +109,7 @@ public String getLanguage() { /** * Set the language property: Language used in the data source. - * + * * @param language the language value to set. * @return the LinkedEntity object itself. */ @@ -115,7 +120,7 @@ public LinkedEntity setLanguage(String language) { /** * Get the id property: Unique identifier of the recognized entity from the data source. - * + * * @return the id value. */ public String getId() { @@ -124,7 +129,7 @@ public String getId() { /** * Set the id property: Unique identifier of the recognized entity from the data source. - * + * * @param id the id value to set. * @return the LinkedEntity object itself. */ @@ -135,7 +140,7 @@ public LinkedEntity setId(String id) { /** * Get the url property: URL for the entity's page from the data source. - * + * * @return the url value. */ public String getUrl() { @@ -144,7 +149,7 @@ public String getUrl() { /** * Set the url property: URL for the entity's page from the data source. - * + * * @param url the url value to set. * @return the LinkedEntity object itself. */ @@ -155,7 +160,7 @@ public LinkedEntity setUrl(String url) { /** * Get the dataSource property: Data source used to extract entity linking, such as Wiki/Bing etc. - * + * * @return the dataSource value. */ public String getDataSource() { @@ -164,7 +169,7 @@ public String getDataSource() { /** * Set the dataSource property: Data source used to extract entity linking, such as Wiki/Bing etc. - * + * * @param dataSource the dataSource value to set. * @return the LinkedEntity object itself. */ @@ -175,7 +180,7 @@ public LinkedEntity setDataSource(String dataSource) { /** * Get the bingId property: Bing Entity Search API unique identifier of the recognized entity. - * + * * @return the bingId value. */ public String getBingId() { @@ -184,7 +189,7 @@ public String getBingId() { /** * Set the bingId property: Bing Entity Search API unique identifier of the recognized entity. - * + * * @param bingId the bingId value to set. * @return the LinkedEntity object itself. */ @@ -193,6 +198,9 @@ public LinkedEntity setBingId(String bingId) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -208,42 +216,41 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of LinkedEntity from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of LinkedEntity if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 LinkedEntity. */ public static LinkedEntity fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - LinkedEntity deserializedLinkedEntity = new LinkedEntity(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("name".equals(fieldName)) { - deserializedLinkedEntity.name = reader.getString(); - } else if ("matches".equals(fieldName)) { - List matches = reader.readArray(reader1 -> Match.fromJson(reader1)); - deserializedLinkedEntity.matches = matches; - } else if ("language".equals(fieldName)) { - deserializedLinkedEntity.language = reader.getString(); - } else if ("url".equals(fieldName)) { - deserializedLinkedEntity.url = reader.getString(); - } else if ("dataSource".equals(fieldName)) { - deserializedLinkedEntity.dataSource = reader.getString(); - } else if ("id".equals(fieldName)) { - deserializedLinkedEntity.id = reader.getString(); - } else if ("bingId".equals(fieldName)) { - deserializedLinkedEntity.bingId = reader.getString(); - } else { - reader.skipChildren(); - } - } - - return deserializedLinkedEntity; - }); + return jsonReader.readObject(reader -> { + LinkedEntity deserializedLinkedEntity = new LinkedEntity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedLinkedEntity.name = reader.getString(); + } else if ("matches".equals(fieldName)) { + List matches = reader.readArray(reader1 -> Match.fromJson(reader1)); + deserializedLinkedEntity.matches = matches; + } else if ("language".equals(fieldName)) { + deserializedLinkedEntity.language = reader.getString(); + } else if ("url".equals(fieldName)) { + deserializedLinkedEntity.url = reader.getString(); + } else if ("dataSource".equals(fieldName)) { + deserializedLinkedEntity.dataSource = reader.getString(); + } else if ("id".equals(fieldName)) { + deserializedLinkedEntity.id = reader.getString(); + } else if ("bingId".equals(fieldName)) { + deserializedLinkedEntity.bingId = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedLinkedEntity; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Match.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Match.java index 401ef471c7e3..804af9725a5c 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Match.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Match.java @@ -11,12 +11,13 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** The Match model. */ +/** + * The Match model. + */ @Fluent public final class Match implements JsonSerializable { /* - * If a well known item is recognized, a decimal number denoting the confidence level between 0 and 1 will be - * returned. + * If a well known item is recognized, a decimal number denoting the confidence level between 0 and 1 will be returned. */ private double confidenceScore; @@ -35,13 +36,16 @@ public final class Match implements JsonSerializable { */ private int length; - /** Creates an instance of Match class. */ - public Match() {} + /** + * Creates an instance of Match class. + */ + public Match() { + } /** * Get the confidenceScore property: If a well known item is recognized, a decimal number denoting the confidence * level between 0 and 1 will be returned. - * + * * @return the confidenceScore value. */ public double getConfidenceScore() { @@ -51,7 +55,7 @@ public double getConfidenceScore() { /** * Set the confidenceScore property: If a well known item is recognized, a decimal number denoting the confidence * level between 0 and 1 will be returned. - * + * * @param confidenceScore the confidenceScore value to set. * @return the Match object itself. */ @@ -62,7 +66,7 @@ public Match setConfidenceScore(double confidenceScore) { /** * Get the text property: Entity text as appears in the request. - * + * * @return the text value. */ public String getText() { @@ -71,7 +75,7 @@ public String getText() { /** * Set the text property: Entity text as appears in the request. - * + * * @param text the text value to set. * @return the Match object itself. */ @@ -82,7 +86,7 @@ public Match setText(String text) { /** * Get the offset property: Start position for the entity match text. - * + * * @return the offset value. */ public int getOffset() { @@ -91,7 +95,7 @@ public int getOffset() { /** * Set the offset property: Start position for the entity match text. - * + * * @param offset the offset value to set. * @return the Match object itself. */ @@ -102,7 +106,7 @@ public Match setOffset(int offset) { /** * Get the length property: Length for the entity match text. - * + * * @return the length value. */ public int getLength() { @@ -111,7 +115,7 @@ public int getLength() { /** * Set the length property: Length for the entity match text. - * + * * @param length the length value to set. * @return the Match object itself. */ @@ -120,6 +124,9 @@ public Match setLength(int length) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -132,35 +139,34 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of Match from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of Match if the JsonReader was pointing to an instance of it, or null if it was pointing to - * JSON null. + * JSON null. * @throws IllegalStateException If the deserialized JSON object was missing any required properties. * @throws IOException If an error occurs while reading the Match. */ public static Match fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - Match deserializedMatch = new Match(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("confidenceScore".equals(fieldName)) { - deserializedMatch.confidenceScore = reader.getDouble(); - } else if ("text".equals(fieldName)) { - deserializedMatch.text = reader.getString(); - } else if ("offset".equals(fieldName)) { - deserializedMatch.offset = reader.getInt(); - } else if ("length".equals(fieldName)) { - deserializedMatch.length = reader.getInt(); - } else { - reader.skipChildren(); - } - } - - return deserializedMatch; - }); + return jsonReader.readObject(reader -> { + Match deserializedMatch = new Match(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("confidenceScore".equals(fieldName)) { + deserializedMatch.confidenceScore = reader.getDouble(); + } else if ("text".equals(fieldName)) { + deserializedMatch.text = reader.getString(); + } else if ("offset".equals(fieldName)) { + deserializedMatch.offset = reader.getInt(); + } else if ("length".equals(fieldName)) { + deserializedMatch.length = reader.getInt(); + } else { + reader.skipChildren(); + } + } + + return deserializedMatch; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/MultiClassificationDocument.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/MultiClassificationDocument.java index 342e572f9225..46062f866bbb 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/MultiClassificationDocument.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/MultiClassificationDocument.java @@ -1,39 +1,39 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 MultiClassificationDocument model. */ @Fluent -public final class MultiClassificationDocument { +public final class MultiClassificationDocument implements JsonSerializable { /* * Unique, non-empty document identifier. */ - @JsonProperty(value = "id", required = true) private String id; /* * Recognized classification results in the document. */ - @JsonProperty(value = "classifications", required = true) private List classifications; /* * Warnings encountered while processing document. */ - @JsonProperty(value = "warnings", required = true) private List warnings; /* * if showStats=true was specified in the request this field will contain * information about the document payload. */ - @JsonProperty(value = "statistics") private DocumentStatistics statistics; /** @@ -117,4 +117,52 @@ public MultiClassificationDocument setStatistics(DocumentStatistics statistics) this.statistics = statistics; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeArrayField("classifications", this.classifications, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("warnings", this.warnings, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("statistics", this.statistics); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MultiClassificationDocument from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MultiClassificationDocument 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 MultiClassificationDocument. + */ + public static MultiClassificationDocument fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MultiClassificationDocument deserializedMultiClassificationDocument = new MultiClassificationDocument(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedMultiClassificationDocument.id = reader.getString(); + } else if ("classification".equals(fieldName)) { + deserializedMultiClassificationDocument.classifications = reader.readArray( + reader1 -> ClassificationResult.fromJson(reader1)); + } else if ("warnings".equals(fieldName)) { + deserializedMultiClassificationDocument.warnings = reader.readArray( + reader1 -> DocumentWarning.fromJson(reader1)); + } else if ("statistics".equals(fieldName)) { + deserializedMultiClassificationDocument.statistics = DocumentStatistics.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return deserializedMultiClassificationDocument; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/MultiClassificationDocumentResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/MultiClassificationDocumentResult.java deleted file mode 100644 index a8460102c553..000000000000 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/MultiClassificationDocumentResult.java +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.ai.textanalytics.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -/** The MultiClassificationDocumentResult model. */ -@Fluent -public class MultiClassificationDocumentResult extends DocumentResult { - /* - * The class property. - */ - @JsonProperty(value = "class", required = true) - private List classProperty; - - /** - * Get the classProperty property: The class property. - * - * @return the classProperty value. - */ - public List getClassProperty() { - return this.classProperty; - } - - /** - * Set the classProperty property: The class property. - * - * @param classProperty the classProperty value to set. - * @return the MultiClassificationDocumentResult object itself. - */ - public MultiClassificationDocumentResult setClassProperty(List classProperty) { - this.classProperty = classProperty; - return this; - } - - /** {@inheritDoc} */ - @Override - public MultiClassificationDocumentResult setId(String id) { - super.setId(id); - return this; - } - - /** {@inheritDoc} */ - @Override - public MultiClassificationDocumentResult setWarnings(List warnings) { - super.setWarnings(warnings); - return this; - } - - /** {@inheritDoc} */ - @Override - public MultiClassificationDocumentResult setStatistics(DocumentStatistics statistics) { - super.setStatistics(statistics); - return this; - } -} diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/MultiLanguageAnalysisInput.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/MultiLanguageAnalysisInput.java index a0d7646ae6ed..4c740a4b5527 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/MultiLanguageAnalysisInput.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/MultiLanguageAnalysisInput.java @@ -12,7 +12,9 @@ import java.io.IOException; import java.util.List; -/** The MultiLanguageAnalysisInput model. */ +/** + * The MultiLanguageAnalysisInput model. + */ @Fluent public final class MultiLanguageAnalysisInput implements JsonSerializable { /* @@ -20,12 +22,15 @@ public final class MultiLanguageAnalysisInput implements JsonSerializable documents; - /** Creates an instance of MultiLanguageAnalysisInput class. */ - public MultiLanguageAnalysisInput() {} + /** + * Creates an instance of MultiLanguageAnalysisInput class. + */ + public MultiLanguageAnalysisInput() { + } /** * Get the documents property: The documents property. - * + * * @return the documents value. */ public List getDocuments() { @@ -34,7 +39,7 @@ public List getDocuments() { /** * Set the documents property: The documents property. - * + * * @param documents the documents value to set. * @return the MultiLanguageAnalysisInput object itself. */ @@ -43,6 +48,9 @@ public MultiLanguageAnalysisInput setDocuments(List document return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -52,31 +60,29 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of MultiLanguageAnalysisInput from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of MultiLanguageAnalysisInput if the JsonReader was pointing to an instance of it, or null if - * it was pointing to JSON null. + * it was pointing to JSON null. * @throws IOException If an error occurs while reading the MultiLanguageAnalysisInput. */ public static MultiLanguageAnalysisInput fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - MultiLanguageAnalysisInput deserializedMultiLanguageAnalysisInput = - new MultiLanguageAnalysisInput(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + MultiLanguageAnalysisInput deserializedMultiLanguageAnalysisInput = new MultiLanguageAnalysisInput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("documents".equals(fieldName)) { - List documents = - reader.readArray(reader1 -> MultiLanguageInput.fromJson(reader1)); - deserializedMultiLanguageAnalysisInput.documents = documents; - } else { - reader.skipChildren(); - } - } + if ("documents".equals(fieldName)) { + List documents + = reader.readArray(reader1 -> MultiLanguageInput.fromJson(reader1)); + deserializedMultiLanguageAnalysisInput.documents = documents; + } else { + reader.skipChildren(); + } + } - return deserializedMultiLanguageAnalysisInput; - }); + return deserializedMultiLanguageAnalysisInput; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/MultiLanguageBatchInput.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/MultiLanguageBatchInput.java index 58c907583fdc..3c1ebf64390d 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/MultiLanguageBatchInput.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/MultiLanguageBatchInput.java @@ -1,20 +1,23 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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; /** Contains a set of input documents to be analyzed by the service. */ @Fluent -public final class MultiLanguageBatchInput { +public final class MultiLanguageBatchInput implements JsonSerializable { /* * The set of documents to process as part of this batch. */ - @JsonProperty(value = "documents", required = true) private List documents; /** @@ -36,4 +39,42 @@ public MultiLanguageBatchInput setDocuments(List documents) this.documents = documents; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("documents", this.documents, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MultiLanguageBatchInput from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MultiLanguageBatchInput 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 MultiLanguageBatchInput. + */ + public static MultiLanguageBatchInput fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MultiLanguageBatchInput deserializedMultiLanguageBatchInput = new MultiLanguageBatchInput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("documents".equals(fieldName)) { + deserializedMultiLanguageBatchInput.documents + = reader.readArray(reader1 -> MultiLanguageInput.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + + return deserializedMultiLanguageBatchInput; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/MultiLanguageInput.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/MultiLanguageInput.java index 723c0c7e3716..eec14993bc70 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/MultiLanguageInput.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/MultiLanguageInput.java @@ -11,7 +11,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** Contains an input document to be analyzed by the service. */ +/** + * Contains an input document to be analyzed by the service. + */ @Fluent public final class MultiLanguageInput implements JsonSerializable { /* @@ -25,17 +27,19 @@ public final class MultiLanguageInput implements JsonSerializable { - MultiLanguageInput deserializedMultiLanguageInput = new MultiLanguageInput(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - deserializedMultiLanguageInput.id = reader.getString(); - } else if ("text".equals(fieldName)) { - deserializedMultiLanguageInput.text = reader.getString(); - } else if ("language".equals(fieldName)) { - deserializedMultiLanguageInput.language = reader.getString(); - } else { - reader.skipChildren(); - } - } - - return deserializedMultiLanguageInput; - }); + return jsonReader.readObject(reader -> { + MultiLanguageInput deserializedMultiLanguageInput = new MultiLanguageInput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedMultiLanguageInput.id = reader.getString(); + } else if ("text".equals(fieldName)) { + deserializedMultiLanguageInput.text = reader.getString(); + } else if ("language".equals(fieldName)) { + deserializedMultiLanguageInput.language = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedMultiLanguageInput; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Pagination.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Pagination.java index c538d97c3316..c130ad497efd 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Pagination.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/Pagination.java @@ -11,7 +11,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** The Pagination model. */ +/** + * The Pagination model. + */ @Fluent public final class Pagination implements JsonSerializable { /* @@ -19,12 +21,15 @@ public final class Pagination implements JsonSerializable { */ private String nextLink; - /** Creates an instance of Pagination class. */ - public Pagination() {} + /** + * Creates an instance of Pagination class. + */ + public Pagination() { + } /** * Get the nextLink property: The nextLink property. - * + * * @return the nextLink value. */ public String getNextLink() { @@ -33,7 +38,7 @@ public String getNextLink() { /** * Set the nextLink property: The nextLink property. - * + * * @param nextLink the nextLink value to set. * @return the Pagination object itself. */ @@ -42,6 +47,9 @@ public Pagination setNextLink(String nextLink) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -51,28 +59,27 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of Pagination from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of Pagination if the JsonReader was pointing to an instance of it, or null if it was pointing - * to JSON null. + * to JSON null. * @throws IOException If an error occurs while reading the Pagination. */ public static Pagination fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - Pagination deserializedPagination = new Pagination(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + Pagination deserializedPagination = new Pagination(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("nextLink".equals(fieldName)) { - deserializedPagination.nextLink = reader.getString(); - } else { - reader.skipChildren(); - } - } + if ("nextLink".equals(fieldName)) { + deserializedPagination.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } - return deserializedPagination; - }); + return deserializedPagination; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiCategory.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiCategory.java index e5292756fc1f..de3b214567b8 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiCategory.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiCategory.java @@ -7,545 +7,894 @@ import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; -/** Defines values for PiiCategory. */ +/** + * Defines values for PiiCategory. + */ public final class PiiCategory extends ExpandableStringEnum { - /** Static value ABARoutingNumber for PiiCategory. */ + /** + * Static value ABARoutingNumber for PiiCategory. + */ public static final PiiCategory ABAROUTING_NUMBER = fromString("ABARoutingNumber"); - /** Static value ARNationalIdentityNumber for PiiCategory. */ + /** + * Static value ARNationalIdentityNumber for PiiCategory. + */ public static final PiiCategory ARNATIONAL_IDENTITY_NUMBER = fromString("ARNationalIdentityNumber"); - /** Static value AUBankAccountNumber for PiiCategory. */ + /** + * Static value AUBankAccountNumber for PiiCategory. + */ public static final PiiCategory AUBANK_ACCOUNT_NUMBER = fromString("AUBankAccountNumber"); - /** Static value AUDriversLicenseNumber for PiiCategory. */ + /** + * Static value AUDriversLicenseNumber for PiiCategory. + */ public static final PiiCategory AUDRIVERS_LICENSE_NUMBER = fromString("AUDriversLicenseNumber"); - /** Static value AUMedicalAccountNumber for PiiCategory. */ + /** + * Static value AUMedicalAccountNumber for PiiCategory. + */ public static final PiiCategory AUMEDICAL_ACCOUNT_NUMBER = fromString("AUMedicalAccountNumber"); - /** Static value AUPassportNumber for PiiCategory. */ + /** + * Static value AUPassportNumber for PiiCategory. + */ public static final PiiCategory AUPASSPORT_NUMBER = fromString("AUPassportNumber"); - /** Static value AUTaxFileNumber for PiiCategory. */ + /** + * Static value AUTaxFileNumber for PiiCategory. + */ public static final PiiCategory AUTAX_FILE_NUMBER = fromString("AUTaxFileNumber"); - /** Static value AUBusinessNumber for PiiCategory. */ + /** + * Static value AUBusinessNumber for PiiCategory. + */ public static final PiiCategory AUBUSINESS_NUMBER = fromString("AUBusinessNumber"); - /** Static value AUCompanyNumber for PiiCategory. */ + /** + * Static value AUCompanyNumber for PiiCategory. + */ public static final PiiCategory AUCOMPANY_NUMBER = fromString("AUCompanyNumber"); - /** Static value ATIdentityCard for PiiCategory. */ + /** + * Static value ATIdentityCard for PiiCategory. + */ public static final PiiCategory ATIDENTITY_CARD = fromString("ATIdentityCard"); - /** Static value ATTaxIdentificationNumber for PiiCategory. */ + /** + * Static value ATTaxIdentificationNumber for PiiCategory. + */ public static final PiiCategory ATTAX_IDENTIFICATION_NUMBER = fromString("ATTaxIdentificationNumber"); - /** Static value ATValueAddedTaxNumber for PiiCategory. */ + /** + * Static value ATValueAddedTaxNumber for PiiCategory. + */ public static final PiiCategory ATVALUE_ADDED_TAX_NUMBER = fromString("ATValueAddedTaxNumber"); - /** Static value AzureDocumentDBAuthKey for PiiCategory. */ + /** + * Static value AzureDocumentDBAuthKey for PiiCategory. + */ public static final PiiCategory AZURE_DOCUMENT_DBAUTH_KEY = fromString("AzureDocumentDBAuthKey"); - /** Static value AzureIAASDatabaseConnectionAndSQLString for PiiCategory. */ - public static final PiiCategory AZURE_IAAS_DATABASE_CONNECTION_AND_SQLSTRING = - fromString("AzureIAASDatabaseConnectionAndSQLString"); + /** + * Static value AzureIAASDatabaseConnectionAndSQLString for PiiCategory. + */ + public static final PiiCategory AZURE_IAAS_DATABASE_CONNECTION_AND_SQLSTRING + = fromString("AzureIAASDatabaseConnectionAndSQLString"); - /** Static value AzureIoTConnectionString for PiiCategory. */ + /** + * Static value AzureIoTConnectionString for PiiCategory. + */ public static final PiiCategory AZURE_IO_TCONNECTION_STRING = fromString("AzureIoTConnectionString"); - /** Static value AzurePublishSettingPassword for PiiCategory. */ + /** + * Static value AzurePublishSettingPassword for PiiCategory. + */ public static final PiiCategory AZURE_PUBLISH_SETTING_PASSWORD = fromString("AzurePublishSettingPassword"); - /** Static value AzureRedisCacheString for PiiCategory. */ + /** + * Static value AzureRedisCacheString for PiiCategory. + */ public static final PiiCategory AZURE_REDIS_CACHE_STRING = fromString("AzureRedisCacheString"); - /** Static value AzureSAS for PiiCategory. */ + /** + * Static value AzureSAS for PiiCategory. + */ public static final PiiCategory AZURE_SAS = fromString("AzureSAS"); - /** Static value AzureServiceBusString for PiiCategory. */ + /** + * Static value AzureServiceBusString for PiiCategory. + */ public static final PiiCategory AZURE_SERVICE_BUS_STRING = fromString("AzureServiceBusString"); - /** Static value AzureStorageAccountKey for PiiCategory. */ + /** + * Static value AzureStorageAccountKey for PiiCategory. + */ public static final PiiCategory AZURE_STORAGE_ACCOUNT_KEY = fromString("AzureStorageAccountKey"); - /** Static value AzureStorageAccountGeneric for PiiCategory. */ + /** + * Static value AzureStorageAccountGeneric for PiiCategory. + */ public static final PiiCategory AZURE_STORAGE_ACCOUNT_GENERIC = fromString("AzureStorageAccountGeneric"); - /** Static value BENationalNumber for PiiCategory. */ + /** + * Static value BENationalNumber for PiiCategory. + */ public static final PiiCategory BENATIONAL_NUMBER = fromString("BENationalNumber"); - /** Static value BENationalNumberV2 for PiiCategory. */ + /** + * Static value BENationalNumberV2 for PiiCategory. + */ public static final PiiCategory BENATIONAL_NUMBER_V2 = fromString("BENationalNumberV2"); - /** Static value BEValueAddedTaxNumber for PiiCategory. */ + /** + * Static value BEValueAddedTaxNumber for PiiCategory. + */ public static final PiiCategory BEVALUE_ADDED_TAX_NUMBER = fromString("BEValueAddedTaxNumber"); - /** Static value BRCPFNumber for PiiCategory. */ + /** + * Static value BRCPFNumber for PiiCategory. + */ public static final PiiCategory BRCPF_NUMBER = fromString("BRCPFNumber"); - /** Static value BRLegalEntityNumber for PiiCategory. */ + /** + * Static value BRLegalEntityNumber for PiiCategory. + */ public static final PiiCategory BRLEGAL_ENTITY_NUMBER = fromString("BRLegalEntityNumber"); - /** Static value BRNationalIDRG for PiiCategory. */ + /** + * Static value BRNationalIDRG for PiiCategory. + */ public static final PiiCategory BRNATIONAL_IDRG = fromString("BRNationalIDRG"); - /** Static value BGUniformCivilNumber for PiiCategory. */ + /** + * Static value BGUniformCivilNumber for PiiCategory. + */ public static final PiiCategory BGUNIFORM_CIVIL_NUMBER = fromString("BGUniformCivilNumber"); - /** Static value CABankAccountNumber for PiiCategory. */ + /** + * Static value CABankAccountNumber for PiiCategory. + */ public static final PiiCategory CABANK_ACCOUNT_NUMBER = fromString("CABankAccountNumber"); - /** Static value CADriversLicenseNumber for PiiCategory. */ + /** + * Static value CADriversLicenseNumber for PiiCategory. + */ public static final PiiCategory CADRIVERS_LICENSE_NUMBER = fromString("CADriversLicenseNumber"); - /** Static value CAHealthServiceNumber for PiiCategory. */ + /** + * Static value CAHealthServiceNumber for PiiCategory. + */ public static final PiiCategory CAHEALTH_SERVICE_NUMBER = fromString("CAHealthServiceNumber"); - /** Static value CAPassportNumber for PiiCategory. */ + /** + * Static value CAPassportNumber for PiiCategory. + */ public static final PiiCategory CAPASSPORT_NUMBER = fromString("CAPassportNumber"); - /** Static value CAPersonalHealthIdentification for PiiCategory. */ + /** + * Static value CAPersonalHealthIdentification for PiiCategory. + */ public static final PiiCategory CAPERSONAL_HEALTH_IDENTIFICATION = fromString("CAPersonalHealthIdentification"); - /** Static value CASocialInsuranceNumber for PiiCategory. */ + /** + * Static value CASocialInsuranceNumber for PiiCategory. + */ public static final PiiCategory CASOCIAL_INSURANCE_NUMBER = fromString("CASocialInsuranceNumber"); - /** Static value CLIdentityCardNumber for PiiCategory. */ + /** + * Static value CLIdentityCardNumber for PiiCategory. + */ public static final PiiCategory CLIDENTITY_CARD_NUMBER = fromString("CLIdentityCardNumber"); - /** Static value CNResidentIdentityCardNumber for PiiCategory. */ + /** + * Static value CNResidentIdentityCardNumber for PiiCategory. + */ public static final PiiCategory CNRESIDENT_IDENTITY_CARD_NUMBER = fromString("CNResidentIdentityCardNumber"); - /** Static value CreditCardNumber for PiiCategory. */ + /** + * Static value CreditCardNumber for PiiCategory. + */ public static final PiiCategory CREDIT_CARD_NUMBER = fromString("CreditCardNumber"); - /** Static value HRIdentityCardNumber for PiiCategory. */ + /** + * Static value HRIdentityCardNumber for PiiCategory. + */ public static final PiiCategory HRIDENTITY_CARD_NUMBER = fromString("HRIdentityCardNumber"); - /** Static value HRNationalIDNumber for PiiCategory. */ + /** + * Static value HRNationalIDNumber for PiiCategory. + */ public static final PiiCategory HRNATIONAL_IDNUMBER = fromString("HRNationalIDNumber"); - /** Static value HRPersonalIdentificationNumber for PiiCategory. */ + /** + * Static value HRPersonalIdentificationNumber for PiiCategory. + */ public static final PiiCategory HRPERSONAL_IDENTIFICATION_NUMBER = fromString("HRPersonalIdentificationNumber"); - /** Static value HRPersonalIdentificationOIBNumberV2 for PiiCategory. */ - public static final PiiCategory HRPERSONAL_IDENTIFICATION_OIBNUMBER_V2 = - fromString("HRPersonalIdentificationOIBNumberV2"); + /** + * Static value HRPersonalIdentificationOIBNumberV2 for PiiCategory. + */ + public static final PiiCategory HRPERSONAL_IDENTIFICATION_OIBNUMBER_V2 + = fromString("HRPersonalIdentificationOIBNumberV2"); - /** Static value CYIdentityCard for PiiCategory. */ + /** + * Static value CYIdentityCard for PiiCategory. + */ public static final PiiCategory CYIDENTITY_CARD = fromString("CYIdentityCard"); - /** Static value CYTaxIdentificationNumber for PiiCategory. */ + /** + * Static value CYTaxIdentificationNumber for PiiCategory. + */ public static final PiiCategory CYTAX_IDENTIFICATION_NUMBER = fromString("CYTaxIdentificationNumber"); - /** Static value CZPersonalIdentityNumber for PiiCategory. */ + /** + * Static value CZPersonalIdentityNumber for PiiCategory. + */ public static final PiiCategory CZPERSONAL_IDENTITY_NUMBER = fromString("CZPersonalIdentityNumber"); - /** Static value CZPersonalIdentityV2 for PiiCategory. */ + /** + * Static value CZPersonalIdentityV2 for PiiCategory. + */ public static final PiiCategory CZPERSONAL_IDENTITY_V2 = fromString("CZPersonalIdentityV2"); - /** Static value DKPersonalIdentificationNumber for PiiCategory. */ + /** + * Static value DKPersonalIdentificationNumber for PiiCategory. + */ public static final PiiCategory DKPERSONAL_IDENTIFICATION_NUMBER = fromString("DKPersonalIdentificationNumber"); - /** Static value DKPersonalIdentificationV2 for PiiCategory. */ + /** + * Static value DKPersonalIdentificationV2 for PiiCategory. + */ public static final PiiCategory DKPERSONAL_IDENTIFICATION_V2 = fromString("DKPersonalIdentificationV2"); - /** Static value DrugEnforcementAgencyNumber for PiiCategory. */ + /** + * Static value DrugEnforcementAgencyNumber for PiiCategory. + */ public static final PiiCategory DRUG_ENFORCEMENT_AGENCY_NUMBER = fromString("DrugEnforcementAgencyNumber"); - /** Static value EEPersonalIdentificationCode for PiiCategory. */ + /** + * Static value EEPersonalIdentificationCode for PiiCategory. + */ public static final PiiCategory EEPERSONAL_IDENTIFICATION_CODE = fromString("EEPersonalIdentificationCode"); - /** Static value EUDebitCardNumber for PiiCategory. */ + /** + * Static value EUDebitCardNumber for PiiCategory. + */ public static final PiiCategory EUDEBIT_CARD_NUMBER = fromString("EUDebitCardNumber"); - /** Static value EUDriversLicenseNumber for PiiCategory. */ + /** + * Static value EUDriversLicenseNumber for PiiCategory. + */ public static final PiiCategory EUDRIVERS_LICENSE_NUMBER = fromString("EUDriversLicenseNumber"); - /** Static value EUGPSCoordinates for PiiCategory. */ + /** + * Static value EUGPSCoordinates for PiiCategory. + */ public static final PiiCategory EUGPS_COORDINATES = fromString("EUGPSCoordinates"); - /** Static value EUNationalIdentificationNumber for PiiCategory. */ + /** + * Static value EUNationalIdentificationNumber for PiiCategory. + */ public static final PiiCategory EUNATIONAL_IDENTIFICATION_NUMBER = fromString("EUNationalIdentificationNumber"); - /** Static value EUPassportNumber for PiiCategory. */ + /** + * Static value EUPassportNumber for PiiCategory. + */ public static final PiiCategory EUPASSPORT_NUMBER = fromString("EUPassportNumber"); - /** Static value EUSocialSecurityNumber for PiiCategory. */ + /** + * Static value EUSocialSecurityNumber for PiiCategory. + */ public static final PiiCategory EUSOCIAL_SECURITY_NUMBER = fromString("EUSocialSecurityNumber"); - /** Static value EUTaxIdentificationNumber for PiiCategory. */ + /** + * Static value EUTaxIdentificationNumber for PiiCategory. + */ public static final PiiCategory EUTAX_IDENTIFICATION_NUMBER = fromString("EUTaxIdentificationNumber"); - /** Static value FIEuropeanHealthNumber for PiiCategory. */ + /** + * Static value FIEuropeanHealthNumber for PiiCategory. + */ public static final PiiCategory FIEUROPEAN_HEALTH_NUMBER = fromString("FIEuropeanHealthNumber"); - /** Static value FINationalID for PiiCategory. */ + /** + * Static value FINationalID for PiiCategory. + */ public static final PiiCategory FINATIONAL_ID = fromString("FINationalID"); - /** Static value FINationalIDV2 for PiiCategory. */ + /** + * Static value FINationalIDV2 for PiiCategory. + */ public static final PiiCategory FINATIONAL_IDV2 = fromString("FINationalIDV2"); - /** Static value FIPassportNumber for PiiCategory. */ + /** + * Static value FIPassportNumber for PiiCategory. + */ public static final PiiCategory FIPASSPORT_NUMBER = fromString("FIPassportNumber"); - /** Static value FRDriversLicenseNumber for PiiCategory. */ + /** + * Static value FRDriversLicenseNumber for PiiCategory. + */ public static final PiiCategory FRDRIVERS_LICENSE_NUMBER = fromString("FRDriversLicenseNumber"); - /** Static value FRHealthInsuranceNumber for PiiCategory. */ + /** + * Static value FRHealthInsuranceNumber for PiiCategory. + */ public static final PiiCategory FRHEALTH_INSURANCE_NUMBER = fromString("FRHealthInsuranceNumber"); - /** Static value FRNationalID for PiiCategory. */ + /** + * Static value FRNationalID for PiiCategory. + */ public static final PiiCategory FRNATIONAL_ID = fromString("FRNationalID"); - /** Static value FRPassportNumber for PiiCategory. */ + /** + * Static value FRPassportNumber for PiiCategory. + */ public static final PiiCategory FRPASSPORT_NUMBER = fromString("FRPassportNumber"); - /** Static value FRSocialSecurityNumber for PiiCategory. */ + /** + * Static value FRSocialSecurityNumber for PiiCategory. + */ public static final PiiCategory FRSOCIAL_SECURITY_NUMBER = fromString("FRSocialSecurityNumber"); - /** Static value FRTaxIdentificationNumber for PiiCategory. */ + /** + * Static value FRTaxIdentificationNumber for PiiCategory. + */ public static final PiiCategory FRTAX_IDENTIFICATION_NUMBER = fromString("FRTaxIdentificationNumber"); - /** Static value FRValueAddedTaxNumber for PiiCategory. */ + /** + * Static value FRValueAddedTaxNumber for PiiCategory. + */ public static final PiiCategory FRVALUE_ADDED_TAX_NUMBER = fromString("FRValueAddedTaxNumber"); - /** Static value DEDriversLicenseNumber for PiiCategory. */ + /** + * Static value DEDriversLicenseNumber for PiiCategory. + */ public static final PiiCategory DEDRIVERS_LICENSE_NUMBER = fromString("DEDriversLicenseNumber"); - /** Static value DEPassportNumber for PiiCategory. */ + /** + * Static value DEPassportNumber for PiiCategory. + */ public static final PiiCategory DEPASSPORT_NUMBER = fromString("DEPassportNumber"); - /** Static value DEIdentityCardNumber for PiiCategory. */ + /** + * Static value DEIdentityCardNumber for PiiCategory. + */ public static final PiiCategory DEIDENTITY_CARD_NUMBER = fromString("DEIdentityCardNumber"); - /** Static value DETaxIdentificationNumber for PiiCategory. */ + /** + * Static value DETaxIdentificationNumber for PiiCategory. + */ public static final PiiCategory DETAX_IDENTIFICATION_NUMBER = fromString("DETaxIdentificationNumber"); - /** Static value DEValueAddedNumber for PiiCategory. */ + /** + * Static value DEValueAddedNumber for PiiCategory. + */ public static final PiiCategory DEVALUE_ADDED_NUMBER = fromString("DEValueAddedNumber"); - /** Static value GRNationalIDCard for PiiCategory. */ + /** + * Static value GRNationalIDCard for PiiCategory. + */ public static final PiiCategory GRNATIONAL_IDCARD = fromString("GRNationalIDCard"); - /** Static value GRNationalIDV2 for PiiCategory. */ + /** + * Static value GRNationalIDV2 for PiiCategory. + */ public static final PiiCategory GRNATIONAL_IDV2 = fromString("GRNationalIDV2"); - /** Static value GRTaxIdentificationNumber for PiiCategory. */ + /** + * Static value GRTaxIdentificationNumber for PiiCategory. + */ public static final PiiCategory GRTAX_IDENTIFICATION_NUMBER = fromString("GRTaxIdentificationNumber"); - /** Static value HKIdentityCardNumber for PiiCategory. */ + /** + * Static value HKIdentityCardNumber for PiiCategory. + */ public static final PiiCategory HKIDENTITY_CARD_NUMBER = fromString("HKIdentityCardNumber"); - /** Static value HUValueAddedNumber for PiiCategory. */ + /** + * Static value HUValueAddedNumber for PiiCategory. + */ public static final PiiCategory HUVALUE_ADDED_NUMBER = fromString("HUValueAddedNumber"); - /** Static value HUPersonalIdentificationNumber for PiiCategory. */ + /** + * Static value HUPersonalIdentificationNumber for PiiCategory. + */ public static final PiiCategory HUPERSONAL_IDENTIFICATION_NUMBER = fromString("HUPersonalIdentificationNumber"); - /** Static value HUTaxIdentificationNumber for PiiCategory. */ + /** + * Static value HUTaxIdentificationNumber for PiiCategory. + */ public static final PiiCategory HUTAX_IDENTIFICATION_NUMBER = fromString("HUTaxIdentificationNumber"); - /** Static value INPermanentAccount for PiiCategory. */ + /** + * Static value INPermanentAccount for PiiCategory. + */ public static final PiiCategory INPERMANENT_ACCOUNT = fromString("INPermanentAccount"); - /** Static value INUniqueIdentificationNumber for PiiCategory. */ + /** + * Static value INUniqueIdentificationNumber for PiiCategory. + */ public static final PiiCategory INUNIQUE_IDENTIFICATION_NUMBER = fromString("INUniqueIdentificationNumber"); - /** Static value IDIdentityCardNumber for PiiCategory. */ + /** + * Static value IDIdentityCardNumber for PiiCategory. + */ public static final PiiCategory IDIDENTITY_CARD_NUMBER = fromString("IDIdentityCardNumber"); - /** Static value InternationalBankingAccountNumber for PiiCategory. */ - public static final PiiCategory INTERNATIONAL_BANKING_ACCOUNT_NUMBER = - fromString("InternationalBankingAccountNumber"); + /** + * Static value InternationalBankingAccountNumber for PiiCategory. + */ + public static final PiiCategory INTERNATIONAL_BANKING_ACCOUNT_NUMBER + = fromString("InternationalBankingAccountNumber"); - /** Static value IEPersonalPublicServiceNumber for PiiCategory. */ + /** + * Static value IEPersonalPublicServiceNumber for PiiCategory. + */ public static final PiiCategory IEPERSONAL_PUBLIC_SERVICE_NUMBER = fromString("IEPersonalPublicServiceNumber"); - /** Static value IEPersonalPublicServiceNumberV2 for PiiCategory. */ + /** + * Static value IEPersonalPublicServiceNumberV2 for PiiCategory. + */ public static final PiiCategory IEPERSONAL_PUBLIC_SERVICE_NUMBER_V2 = fromString("IEPersonalPublicServiceNumberV2"); - /** Static value ILBankAccountNumber for PiiCategory. */ + /** + * Static value ILBankAccountNumber for PiiCategory. + */ public static final PiiCategory ILBANK_ACCOUNT_NUMBER = fromString("ILBankAccountNumber"); - /** Static value ILNationalID for PiiCategory. */ + /** + * Static value ILNationalID for PiiCategory. + */ public static final PiiCategory ILNATIONAL_ID = fromString("ILNationalID"); - /** Static value ITDriversLicenseNumber for PiiCategory. */ + /** + * Static value ITDriversLicenseNumber for PiiCategory. + */ public static final PiiCategory ITDRIVERS_LICENSE_NUMBER = fromString("ITDriversLicenseNumber"); - /** Static value ITFiscalCode for PiiCategory. */ + /** + * Static value ITFiscalCode for PiiCategory. + */ public static final PiiCategory ITFISCAL_CODE = fromString("ITFiscalCode"); - /** Static value ITValueAddedTaxNumber for PiiCategory. */ + /** + * Static value ITValueAddedTaxNumber for PiiCategory. + */ public static final PiiCategory ITVALUE_ADDED_TAX_NUMBER = fromString("ITValueAddedTaxNumber"); - /** Static value JPBankAccountNumber for PiiCategory. */ + /** + * Static value JPBankAccountNumber for PiiCategory. + */ public static final PiiCategory JPBANK_ACCOUNT_NUMBER = fromString("JPBankAccountNumber"); - /** Static value JPDriversLicenseNumber for PiiCategory. */ + /** + * Static value JPDriversLicenseNumber for PiiCategory. + */ public static final PiiCategory JPDRIVERS_LICENSE_NUMBER = fromString("JPDriversLicenseNumber"); - /** Static value JPPassportNumber for PiiCategory. */ + /** + * Static value JPPassportNumber for PiiCategory. + */ public static final PiiCategory JPPASSPORT_NUMBER = fromString("JPPassportNumber"); - /** Static value JPResidentRegistrationNumber for PiiCategory. */ + /** + * Static value JPResidentRegistrationNumber for PiiCategory. + */ public static final PiiCategory JPRESIDENT_REGISTRATION_NUMBER = fromString("JPResidentRegistrationNumber"); - /** Static value JPSocialInsuranceNumber for PiiCategory. */ + /** + * Static value JPSocialInsuranceNumber for PiiCategory. + */ public static final PiiCategory JPSOCIAL_INSURANCE_NUMBER = fromString("JPSocialInsuranceNumber"); - /** Static value JPMyNumberCorporate for PiiCategory. */ + /** + * Static value JPMyNumberCorporate for PiiCategory. + */ public static final PiiCategory JPMY_NUMBER_CORPORATE = fromString("JPMyNumberCorporate"); - /** Static value JPMyNumberPersonal for PiiCategory. */ + /** + * Static value JPMyNumberPersonal for PiiCategory. + */ public static final PiiCategory JPMY_NUMBER_PERSONAL = fromString("JPMyNumberPersonal"); - /** Static value JPResidenceCardNumber for PiiCategory. */ + /** + * Static value JPResidenceCardNumber for PiiCategory. + */ public static final PiiCategory JPRESIDENCE_CARD_NUMBER = fromString("JPResidenceCardNumber"); - /** Static value LVPersonalCode for PiiCategory. */ + /** + * Static value LVPersonalCode for PiiCategory. + */ public static final PiiCategory LVPERSONAL_CODE = fromString("LVPersonalCode"); - /** Static value LTPersonalCode for PiiCategory. */ + /** + * Static value LTPersonalCode for PiiCategory. + */ public static final PiiCategory LTPERSONAL_CODE = fromString("LTPersonalCode"); - /** Static value LUNationalIdentificationNumberNatural for PiiCategory. */ - public static final PiiCategory LUNATIONAL_IDENTIFICATION_NUMBER_NATURAL = - fromString("LUNationalIdentificationNumberNatural"); + /** + * Static value LUNationalIdentificationNumberNatural for PiiCategory. + */ + public static final PiiCategory LUNATIONAL_IDENTIFICATION_NUMBER_NATURAL + = fromString("LUNationalIdentificationNumberNatural"); - /** Static value LUNationalIdentificationNumberNonNatural for PiiCategory. */ - public static final PiiCategory LUNATIONAL_IDENTIFICATION_NUMBER_NON_NATURAL = - fromString("LUNationalIdentificationNumberNonNatural"); + /** + * Static value LUNationalIdentificationNumberNonNatural for PiiCategory. + */ + public static final PiiCategory LUNATIONAL_IDENTIFICATION_NUMBER_NON_NATURAL + = fromString("LUNationalIdentificationNumberNonNatural"); - /** Static value MYIdentityCardNumber for PiiCategory. */ + /** + * Static value MYIdentityCardNumber for PiiCategory. + */ public static final PiiCategory MYIDENTITY_CARD_NUMBER = fromString("MYIdentityCardNumber"); - /** Static value MTIdentityCardNumber for PiiCategory. */ + /** + * Static value MTIdentityCardNumber for PiiCategory. + */ public static final PiiCategory MTIDENTITY_CARD_NUMBER = fromString("MTIdentityCardNumber"); - /** Static value MTTaxIDNumber for PiiCategory. */ + /** + * Static value MTTaxIDNumber for PiiCategory. + */ public static final PiiCategory MTTAX_IDNUMBER = fromString("MTTaxIDNumber"); - /** Static value NLCitizensServiceNumber for PiiCategory. */ + /** + * Static value NLCitizensServiceNumber for PiiCategory. + */ public static final PiiCategory NLCITIZENS_SERVICE_NUMBER = fromString("NLCitizensServiceNumber"); - /** Static value NLCitizensServiceNumberV2 for PiiCategory. */ + /** + * Static value NLCitizensServiceNumberV2 for PiiCategory. + */ public static final PiiCategory NLCITIZENS_SERVICE_NUMBER_V2 = fromString("NLCitizensServiceNumberV2"); - /** Static value NLTaxIdentificationNumber for PiiCategory. */ + /** + * Static value NLTaxIdentificationNumber for PiiCategory. + */ public static final PiiCategory NLTAX_IDENTIFICATION_NUMBER = fromString("NLTaxIdentificationNumber"); - /** Static value NLValueAddedTaxNumber for PiiCategory. */ + /** + * Static value NLValueAddedTaxNumber for PiiCategory. + */ public static final PiiCategory NLVALUE_ADDED_TAX_NUMBER = fromString("NLValueAddedTaxNumber"); - /** Static value NZBankAccountNumber for PiiCategory. */ + /** + * Static value NZBankAccountNumber for PiiCategory. + */ public static final PiiCategory NZBANK_ACCOUNT_NUMBER = fromString("NZBankAccountNumber"); - /** Static value NZDriversLicenseNumber for PiiCategory. */ + /** + * Static value NZDriversLicenseNumber for PiiCategory. + */ public static final PiiCategory NZDRIVERS_LICENSE_NUMBER = fromString("NZDriversLicenseNumber"); - /** Static value NZInlandRevenueNumber for PiiCategory. */ + /** + * Static value NZInlandRevenueNumber for PiiCategory. + */ public static final PiiCategory NZINLAND_REVENUE_NUMBER = fromString("NZInlandRevenueNumber"); - /** Static value NZMinistryOfHealthNumber for PiiCategory. */ + /** + * Static value NZMinistryOfHealthNumber for PiiCategory. + */ public static final PiiCategory NZMINISTRY_OF_HEALTH_NUMBER = fromString("NZMinistryOfHealthNumber"); - /** Static value NZSocialWelfareNumber for PiiCategory. */ + /** + * Static value NZSocialWelfareNumber for PiiCategory. + */ public static final PiiCategory NZSOCIAL_WELFARE_NUMBER = fromString("NZSocialWelfareNumber"); - /** Static value NOIdentityNumber for PiiCategory. */ + /** + * Static value NOIdentityNumber for PiiCategory. + */ public static final PiiCategory NOIDENTITY_NUMBER = fromString("NOIdentityNumber"); - /** Static value PHUnifiedMultiPurposeIDNumber for PiiCategory. */ + /** + * Static value PHUnifiedMultiPurposeIDNumber for PiiCategory. + */ public static final PiiCategory PHUNIFIED_MULTI_PURPOSE_IDNUMBER = fromString("PHUnifiedMultiPurposeIDNumber"); - /** Static value PLIdentityCard for PiiCategory. */ + /** + * Static value PLIdentityCard for PiiCategory. + */ public static final PiiCategory PLIDENTITY_CARD = fromString("PLIdentityCard"); - /** Static value PLNationalID for PiiCategory. */ + /** + * Static value PLNationalID for PiiCategory. + */ public static final PiiCategory PLNATIONAL_ID = fromString("PLNationalID"); - /** Static value PLNationalIDV2 for PiiCategory. */ + /** + * Static value PLNationalIDV2 for PiiCategory. + */ public static final PiiCategory PLNATIONAL_IDV2 = fromString("PLNationalIDV2"); - /** Static value PLPassportNumber for PiiCategory. */ + /** + * Static value PLPassportNumber for PiiCategory. + */ public static final PiiCategory PLPASSPORT_NUMBER = fromString("PLPassportNumber"); - /** Static value PLTaxIdentificationNumber for PiiCategory. */ + /** + * Static value PLTaxIdentificationNumber for PiiCategory. + */ public static final PiiCategory PLTAX_IDENTIFICATION_NUMBER = fromString("PLTaxIdentificationNumber"); - /** Static value PLREGONNumber for PiiCategory. */ + /** + * Static value PLREGONNumber for PiiCategory. + */ public static final PiiCategory PLREGON_NUMBER = fromString("PLREGONNumber"); - /** Static value PTCitizenCardNumber for PiiCategory. */ + /** + * Static value PTCitizenCardNumber for PiiCategory. + */ public static final PiiCategory PTCITIZEN_CARD_NUMBER = fromString("PTCitizenCardNumber"); - /** Static value PTCitizenCardNumberV2 for PiiCategory. */ + /** + * Static value PTCitizenCardNumberV2 for PiiCategory. + */ public static final PiiCategory PTCITIZEN_CARD_NUMBER_V2 = fromString("PTCitizenCardNumberV2"); - /** Static value PTTaxIdentificationNumber for PiiCategory. */ + /** + * Static value PTTaxIdentificationNumber for PiiCategory. + */ public static final PiiCategory PTTAX_IDENTIFICATION_NUMBER = fromString("PTTaxIdentificationNumber"); - /** Static value ROPersonalNumericalCode for PiiCategory. */ + /** + * Static value ROPersonalNumericalCode for PiiCategory. + */ public static final PiiCategory ROPERSONAL_NUMERICAL_CODE = fromString("ROPersonalNumericalCode"); - /** Static value RUPassportNumberDomestic for PiiCategory. */ + /** + * Static value RUPassportNumberDomestic for PiiCategory. + */ public static final PiiCategory RUPASSPORT_NUMBER_DOMESTIC = fromString("RUPassportNumberDomestic"); - /** Static value RUPassportNumberInternational for PiiCategory. */ + /** + * Static value RUPassportNumberInternational for PiiCategory. + */ public static final PiiCategory RUPASSPORT_NUMBER_INTERNATIONAL = fromString("RUPassportNumberInternational"); - /** Static value SANationalID for PiiCategory. */ + /** + * Static value SANationalID for PiiCategory. + */ public static final PiiCategory SANATIONAL_ID = fromString("SANationalID"); - /** Static value SGNationalRegistrationIdentityCardNumber for PiiCategory. */ - public static final PiiCategory SGNATIONAL_REGISTRATION_IDENTITY_CARD_NUMBER = - fromString("SGNationalRegistrationIdentityCardNumber"); + /** + * Static value SGNationalRegistrationIdentityCardNumber for PiiCategory. + */ + public static final PiiCategory SGNATIONAL_REGISTRATION_IDENTITY_CARD_NUMBER + = fromString("SGNationalRegistrationIdentityCardNumber"); - /** Static value SKPersonalNumber for PiiCategory. */ + /** + * Static value SKPersonalNumber for PiiCategory. + */ public static final PiiCategory SKPERSONAL_NUMBER = fromString("SKPersonalNumber"); - /** Static value SITaxIdentificationNumber for PiiCategory. */ + /** + * Static value SITaxIdentificationNumber for PiiCategory. + */ public static final PiiCategory SITAX_IDENTIFICATION_NUMBER = fromString("SITaxIdentificationNumber"); - /** Static value SIUniqueMasterCitizenNumber for PiiCategory. */ + /** + * Static value SIUniqueMasterCitizenNumber for PiiCategory. + */ public static final PiiCategory SIUNIQUE_MASTER_CITIZEN_NUMBER = fromString("SIUniqueMasterCitizenNumber"); - /** Static value ZAIdentificationNumber for PiiCategory. */ + /** + * Static value ZAIdentificationNumber for PiiCategory. + */ public static final PiiCategory ZAIDENTIFICATION_NUMBER = fromString("ZAIdentificationNumber"); - /** Static value KRResidentRegistrationNumber for PiiCategory. */ + /** + * Static value KRResidentRegistrationNumber for PiiCategory. + */ public static final PiiCategory KRRESIDENT_REGISTRATION_NUMBER = fromString("KRResidentRegistrationNumber"); - /** Static value ESDNI for PiiCategory. */ + /** + * Static value ESDNI for PiiCategory. + */ public static final PiiCategory ESDNI = fromString("ESDNI"); - /** Static value ESSocialSecurityNumber for PiiCategory. */ + /** + * Static value ESSocialSecurityNumber for PiiCategory. + */ public static final PiiCategory ESSOCIAL_SECURITY_NUMBER = fromString("ESSocialSecurityNumber"); - /** Static value ESTaxIdentificationNumber for PiiCategory. */ + /** + * Static value ESTaxIdentificationNumber for PiiCategory. + */ public static final PiiCategory ESTAX_IDENTIFICATION_NUMBER = fromString("ESTaxIdentificationNumber"); - /** Static value SQLServerConnectionString for PiiCategory. */ + /** + * Static value SQLServerConnectionString for PiiCategory. + */ public static final PiiCategory SQLSERVER_CONNECTION_STRING = fromString("SQLServerConnectionString"); - /** Static value SENationalID for PiiCategory. */ + /** + * Static value SENationalID for PiiCategory. + */ public static final PiiCategory SENATIONAL_ID = fromString("SENationalID"); - /** Static value SENationalIDV2 for PiiCategory. */ + /** + * Static value SENationalIDV2 for PiiCategory. + */ public static final PiiCategory SENATIONAL_IDV2 = fromString("SENationalIDV2"); - /** Static value SEPassportNumber for PiiCategory. */ + /** + * Static value SEPassportNumber for PiiCategory. + */ public static final PiiCategory SEPASSPORT_NUMBER = fromString("SEPassportNumber"); - /** Static value SETaxIdentificationNumber for PiiCategory. */ + /** + * Static value SETaxIdentificationNumber for PiiCategory. + */ public static final PiiCategory SETAX_IDENTIFICATION_NUMBER = fromString("SETaxIdentificationNumber"); - /** Static value SWIFTCode for PiiCategory. */ + /** + * Static value SWIFTCode for PiiCategory. + */ public static final PiiCategory SWIFT_CODE = fromString("SWIFTCode"); - /** Static value CHSocialSecurityNumber for PiiCategory. */ + /** + * Static value CHSocialSecurityNumber for PiiCategory. + */ public static final PiiCategory CHSOCIAL_SECURITY_NUMBER = fromString("CHSocialSecurityNumber"); - /** Static value TWNationalID for PiiCategory. */ + /** + * Static value TWNationalID for PiiCategory. + */ public static final PiiCategory TWNATIONAL_ID = fromString("TWNationalID"); - /** Static value TWPassportNumber for PiiCategory. */ + /** + * Static value TWPassportNumber for PiiCategory. + */ public static final PiiCategory TWPASSPORT_NUMBER = fromString("TWPassportNumber"); - /** Static value TWResidentCertificate for PiiCategory. */ + /** + * Static value TWResidentCertificate for PiiCategory. + */ public static final PiiCategory TWRESIDENT_CERTIFICATE = fromString("TWResidentCertificate"); - /** Static value THPopulationIdentificationCode for PiiCategory. */ + /** + * Static value THPopulationIdentificationCode for PiiCategory. + */ public static final PiiCategory THPOPULATION_IDENTIFICATION_CODE = fromString("THPopulationIdentificationCode"); - /** Static value TRNationalIdentificationNumber for PiiCategory. */ + /** + * Static value TRNationalIdentificationNumber for PiiCategory. + */ public static final PiiCategory TRNATIONAL_IDENTIFICATION_NUMBER = fromString("TRNationalIdentificationNumber"); - /** Static value UKDriversLicenseNumber for PiiCategory. */ + /** + * Static value UKDriversLicenseNumber for PiiCategory. + */ public static final PiiCategory UKDRIVERS_LICENSE_NUMBER = fromString("UKDriversLicenseNumber"); - /** Static value UKElectoralRollNumber for PiiCategory. */ + /** + * Static value UKElectoralRollNumber for PiiCategory. + */ public static final PiiCategory UKELECTORAL_ROLL_NUMBER = fromString("UKElectoralRollNumber"); - /** Static value UKNationalHealthNumber for PiiCategory. */ + /** + * Static value UKNationalHealthNumber for PiiCategory. + */ public static final PiiCategory UKNATIONAL_HEALTH_NUMBER = fromString("UKNationalHealthNumber"); - /** Static value UKNationalInsuranceNumber for PiiCategory. */ + /** + * Static value UKNationalInsuranceNumber for PiiCategory. + */ public static final PiiCategory UKNATIONAL_INSURANCE_NUMBER = fromString("UKNationalInsuranceNumber"); - /** Static value UKUniqueTaxpayerNumber for PiiCategory. */ + /** + * Static value UKUniqueTaxpayerNumber for PiiCategory. + */ public static final PiiCategory UKUNIQUE_TAXPAYER_NUMBER = fromString("UKUniqueTaxpayerNumber"); - /** Static value USUKPassportNumber for PiiCategory. */ + /** + * Static value USUKPassportNumber for PiiCategory. + */ public static final PiiCategory USUK_PASSPORT_NUMBER = fromString("USUKPassportNumber"); - /** Static value USBankAccountNumber for PiiCategory. */ + /** + * Static value USBankAccountNumber for PiiCategory. + */ public static final PiiCategory USBANK_ACCOUNT_NUMBER = fromString("USBankAccountNumber"); - /** Static value USDriversLicenseNumber for PiiCategory. */ + /** + * Static value USDriversLicenseNumber for PiiCategory. + */ public static final PiiCategory USDRIVERS_LICENSE_NUMBER = fromString("USDriversLicenseNumber"); - /** Static value USIndividualTaxpayerIdentification for PiiCategory. */ - public static final PiiCategory USINDIVIDUAL_TAXPAYER_IDENTIFICATION = - fromString("USIndividualTaxpayerIdentification"); + /** + * Static value USIndividualTaxpayerIdentification for PiiCategory. + */ + public static final PiiCategory USINDIVIDUAL_TAXPAYER_IDENTIFICATION + = fromString("USIndividualTaxpayerIdentification"); - /** Static value USSocialSecurityNumber for PiiCategory. */ + /** + * Static value USSocialSecurityNumber for PiiCategory. + */ public static final PiiCategory USSOCIAL_SECURITY_NUMBER = fromString("USSocialSecurityNumber"); - /** Static value UAPassportNumberDomestic for PiiCategory. */ + /** + * Static value UAPassportNumberDomestic for PiiCategory. + */ public static final PiiCategory UAPASSPORT_NUMBER_DOMESTIC = fromString("UAPassportNumberDomestic"); - /** Static value UAPassportNumberInternational for PiiCategory. */ + /** + * Static value UAPassportNumberInternational for PiiCategory. + */ public static final PiiCategory UAPASSPORT_NUMBER_INTERNATIONAL = fromString("UAPassportNumberInternational"); - /** Static value Organization for PiiCategory. */ + /** + * Static value Organization for PiiCategory. + */ public static final PiiCategory ORGANIZATION = fromString("Organization"); - /** Static value Email for PiiCategory. */ + /** + * Static value Email for PiiCategory. + */ public static final PiiCategory EMAIL = fromString("Email"); - /** Static value URL for PiiCategory. */ + /** + * Static value URL for PiiCategory. + */ public static final PiiCategory URL = fromString("URL"); - /** Static value Age for PiiCategory. */ + /** + * Static value Age for PiiCategory. + */ public static final PiiCategory AGE = fromString("Age"); - /** Static value PhoneNumber for PiiCategory. */ + /** + * Static value PhoneNumber for PiiCategory. + */ public static final PiiCategory PHONE_NUMBER = fromString("PhoneNumber"); - /** Static value IPAddress for PiiCategory. */ + /** + * Static value IPAddress for PiiCategory. + */ public static final PiiCategory IPADDRESS = fromString("IPAddress"); - /** Static value Date for PiiCategory. */ + /** + * Static value Date for PiiCategory. + */ public static final PiiCategory DATE = fromString("Date"); - /** Static value Person for PiiCategory. */ + /** + * Static value Person for PiiCategory. + */ public static final PiiCategory PERSON = fromString("Person"); - /** Static value Address for PiiCategory. */ + /** + * Static value Address for PiiCategory. + */ public static final PiiCategory ADDRESS = fromString("Address"); - /** Static value All for PiiCategory. */ + /** + * Static value All for PiiCategory. + */ public static final PiiCategory ALL = fromString("All"); - /** Static value Default for PiiCategory. */ + /** + * Static value Default for PiiCategory. + */ public static final PiiCategory DEFAULT = fromString("Default"); /** * Creates a new instance of PiiCategory value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated - public PiiCategory() {} + public PiiCategory() { + } /** * Creates or finds a PiiCategory from its string representation. - * + * * @param name a name to look for. * @return the corresponding PiiCategory. */ @@ -555,7 +904,7 @@ public static PiiCategory fromString(String name) { /** * Gets known PiiCategory values. - * + * * @return known PiiCategory values. */ public static Collection values() { diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiDomain.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiDomain.java index 803bcf968b5e..46755a5d849e 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiDomain.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiDomain.java @@ -7,25 +7,32 @@ import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; -/** The PII domain used for PII Entity Recognition. */ +/** + * The PII domain used for PII Entity Recognition. + */ public final class PiiDomain extends ExpandableStringEnum { - /** Indicates that entities in the Personal Health Information domain should be redacted. */ + /** + * Indicates that entities in the Personal Health Information domain should be redacted. + */ public static final PiiDomain PHI = fromString("phi"); - /** Indicates that no domain is specified. */ + /** + * Indicates that no domain is specified. + */ public static final PiiDomain NONE = fromString("none"); /** * Creates a new instance of PiiDomain value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated - public PiiDomain() {} + public PiiDomain() { + } /** * Creates or finds a PiiDomain from its string representation. - * + * * @param name a name to look for. * @return the corresponding PiiDomain. */ @@ -35,7 +42,7 @@ public static PiiDomain fromString(String name) { /** * Gets known PiiDomain values. - * + * * @return known PiiDomain values. */ public static Collection values() { diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiEntitiesDocumentResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiEntitiesDocumentResult.java index b27ac3e99d22..b8c2ee7bbc3f 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiEntitiesDocumentResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiEntitiesDocumentResult.java @@ -11,7 +11,9 @@ import java.io.IOException; import java.util.List; -/** The PiiEntitiesDocumentResult model. */ +/** + * The PiiEntitiesDocumentResult model. + */ @Fluent public class PiiEntitiesDocumentResult extends DocumentResult { /* @@ -24,12 +26,15 @@ public class PiiEntitiesDocumentResult extends DocumentResult { */ private List entities; - /** Creates an instance of PiiEntitiesDocumentResult class. */ - public PiiEntitiesDocumentResult() {} + /** + * Creates an instance of PiiEntitiesDocumentResult class. + */ + public PiiEntitiesDocumentResult() { + } /** * Get the redactedText property: Returns redacted text. - * + * * @return the redactedText value. */ public String getRedactedText() { @@ -38,7 +43,7 @@ public String getRedactedText() { /** * Set the redactedText property: Returns redacted text. - * + * * @param redactedText the redactedText value to set. * @return the PiiEntitiesDocumentResult object itself. */ @@ -49,7 +54,7 @@ public PiiEntitiesDocumentResult setRedactedText(String redactedText) { /** * Get the entities property: Recognized entities in the document. - * + * * @return the entities value. */ public List getEntities() { @@ -58,7 +63,7 @@ public List getEntities() { /** * Set the entities property: Recognized entities in the document. - * + * * @param entities the entities value to set. * @return the PiiEntitiesDocumentResult object itself. */ @@ -67,27 +72,36 @@ public PiiEntitiesDocumentResult setEntities(List entities) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public PiiEntitiesDocumentResult setId(String id) { super.setId(id); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public PiiEntitiesDocumentResult setWarnings(List warnings) { super.setWarnings(warnings); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public PiiEntitiesDocumentResult setStatistics(DocumentStatistics statistics) { super.setStatistics(statistics); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -101,40 +115,38 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of PiiEntitiesDocumentResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of PiiEntitiesDocumentResult if the JsonReader was pointing to an instance of it, or null if - * it was pointing to JSON null. + * 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 PiiEntitiesDocumentResult. */ public static PiiEntitiesDocumentResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - PiiEntitiesDocumentResult deserializedPiiEntitiesDocumentResult = new PiiEntitiesDocumentResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - deserializedPiiEntitiesDocumentResult.setId(reader.getString()); - } else if ("warnings".equals(fieldName)) { - List warnings = - reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); - deserializedPiiEntitiesDocumentResult.setWarnings(warnings); - } else if ("statistics".equals(fieldName)) { - deserializedPiiEntitiesDocumentResult.setStatistics(DocumentStatistics.fromJson(reader)); - } else if ("redactedText".equals(fieldName)) { - deserializedPiiEntitiesDocumentResult.redactedText = reader.getString(); - } else if ("entities".equals(fieldName)) { - List entities = reader.readArray(reader1 -> Entity.fromJson(reader1)); - deserializedPiiEntitiesDocumentResult.entities = entities; - } else { - reader.skipChildren(); - } - } - - return deserializedPiiEntitiesDocumentResult; - }); + return jsonReader.readObject(reader -> { + PiiEntitiesDocumentResult deserializedPiiEntitiesDocumentResult = new PiiEntitiesDocumentResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedPiiEntitiesDocumentResult.setId(reader.getString()); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedPiiEntitiesDocumentResult.setWarnings(warnings); + } else if ("statistics".equals(fieldName)) { + deserializedPiiEntitiesDocumentResult.setStatistics(DocumentStatistics.fromJson(reader)); + } else if ("redactedText".equals(fieldName)) { + deserializedPiiEntitiesDocumentResult.redactedText = reader.getString(); + } else if ("entities".equals(fieldName)) { + List entities = reader.readArray(reader1 -> Entity.fromJson(reader1)); + deserializedPiiEntitiesDocumentResult.entities = entities; + } else { + reader.skipChildren(); + } + } + + return deserializedPiiEntitiesDocumentResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiEntityRecognitionLROResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiEntityRecognitionLROResult.java index 413c35486937..fbd4983ef971 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiEntityRecognitionLROResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiEntityRecognitionLROResult.java @@ -10,22 +10,42 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.time.OffsetDateTime; -import java.util.Objects; +import java.time.format.DateTimeFormatter; -/** The PiiEntityRecognitionLROResult model. */ +/** + * The PiiEntityRecognitionLROResult model. + */ @Fluent public final class PiiEntityRecognitionLROResult extends AnalyzeTextLROResult { + /* + * Enumeration of supported Text Analysis long-running operation task results. + */ + private AnalyzeTextLROResultsKind kind = AnalyzeTextLROResultsKind.PII_ENTITY_RECOGNITION_LRORESULTS; + /* * The results property. */ private PiiResult results; - /** Creates an instance of PiiEntityRecognitionLROResult class. */ - public PiiEntityRecognitionLROResult() {} + /** + * Creates an instance of PiiEntityRecognitionLROResult class. + */ + public PiiEntityRecognitionLROResult() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis long-running operation task results. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROResultsKind getKind() { + return this.kind; + } /** * Get the results property: The results property. - * + * * @return the results value. */ public PiiResult getResults() { @@ -34,7 +54,7 @@ public PiiResult getResults() { /** * Set the results property: The results property. - * + * * @param results the results value to set. * @return the PiiEntityRecognitionLROResult object itself. */ @@ -43,82 +63,85 @@ public PiiEntityRecognitionLROResult setResults(PiiResult results) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public PiiEntityRecognitionLROResult setTaskName(String taskName) { super.setTaskName(taskName); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public PiiEntityRecognitionLROResult setLastUpdateDateTime(OffsetDateTime lastUpdateDateTime) { super.setLastUpdateDateTime(lastUpdateDateTime); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public PiiEntityRecognitionLROResult setStatus(State status) { super.setStatus(status); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField( - "kind", Objects.toString(AnalyzeTextLROResultsKind.PII_ENTITY_RECOGNITION_LRORESULTS, null)); - jsonWriter.writeStringField("lastUpdateDateTime", Objects.toString(getLastUpdateDateTime(), null)); - jsonWriter.writeStringField("status", Objects.toString(getStatus(), null)); + jsonWriter.writeStringField("lastUpdateDateTime", + getLastUpdateDateTime() == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(getLastUpdateDateTime())); + jsonWriter.writeStringField("status", getStatus() == null ? null : getStatus().toString()); jsonWriter.writeStringField("taskName", getTaskName()); jsonWriter.writeJsonField("results", this.results); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of PiiEntityRecognitionLROResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of PiiEntityRecognitionLROResult 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 or the - * polymorphic discriminator. + * 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 PiiEntityRecognitionLROResult. */ public static PiiEntityRecognitionLROResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - PiiEntityRecognitionLROResult deserializedPiiEntityRecognitionLROResult = - new PiiEntityRecognitionLROResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + PiiEntityRecognitionLROResult deserializedPiiEntityRecognitionLROResult + = new PiiEntityRecognitionLROResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"PiiEntityRecognitionLROResults".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'PiiEntityRecognitionLROResults'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("lastUpdateDateTime".equals(fieldName)) { - deserializedPiiEntityRecognitionLROResult.setLastUpdateDateTime( - reader.getNullable( - nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); - } else if ("status".equals(fieldName)) { - deserializedPiiEntityRecognitionLROResult.setStatus(State.fromString(reader.getString())); - } else if ("taskName".equals(fieldName)) { - deserializedPiiEntityRecognitionLROResult.setTaskName(reader.getString()); - } else if ("results".equals(fieldName)) { - deserializedPiiEntityRecognitionLROResult.results = PiiResult.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("lastUpdateDateTime".equals(fieldName)) { + deserializedPiiEntityRecognitionLROResult.setLastUpdateDateTime( + reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); + } else if ("status".equals(fieldName)) { + deserializedPiiEntityRecognitionLROResult.setStatus(State.fromString(reader.getString())); + } else if ("taskName".equals(fieldName)) { + deserializedPiiEntityRecognitionLROResult.setTaskName(reader.getString()); + } else if ("results".equals(fieldName)) { + deserializedPiiEntityRecognitionLROResult.results = PiiResult.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedPiiEntityRecognitionLROResult.kind + = AnalyzeTextLROResultsKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedPiiEntityRecognitionLROResult; - }); + return deserializedPiiEntityRecognitionLROResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiLROTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiLROTask.java index a41fe9a484f8..71f36185e902 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiLROTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiLROTask.java @@ -9,22 +9,41 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** An object representing the task definition for a PII Entities Recognition task. */ +/** + * An object representing the task definition for a PII Entities Recognition task. + */ @Fluent public final class PiiLROTask extends AnalyzeTextLROTask { + /* + * Enumeration of supported long-running Text Analysis tasks. + */ + private AnalyzeTextLROTaskKind kind = AnalyzeTextLROTaskKind.PII_ENTITY_RECOGNITION; + /* * Supported parameters for a PII Entities Recognition task. */ private PiiTaskParameters parameters; - /** Creates an instance of PiiLROTask class. */ - public PiiLROTask() {} + /** + * Creates an instance of PiiLROTask class. + */ + public PiiLROTask() { + } + + /** + * Get the kind property: Enumeration of supported long-running Text Analysis tasks. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROTaskKind getKind() { + return this.kind; + } /** * Get the parameters property: Supported parameters for a PII Entities Recognition task. - * + * * @return the parameters value. */ public PiiTaskParameters getParameters() { @@ -33,7 +52,7 @@ public PiiTaskParameters getParameters() { /** * Set the parameters property: Supported parameters for a PII Entities Recognition task. - * + * * @param parameters the parameters value to set. * @return the PiiLROTask object itself. */ @@ -42,57 +61,54 @@ public PiiLROTask setParameters(PiiTaskParameters parameters) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public PiiLROTask setTaskName(String taskName) { super.setTaskName(taskName); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("kind", Objects.toString(AnalyzeTextLROTaskKind.PII_ENTITY_RECOGNITION, null)); jsonWriter.writeStringField("taskName", getTaskName()); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); jsonWriter.writeJsonField("parameters", this.parameters); return jsonWriter.writeEndObject(); } /** * Reads an instance of PiiLROTask from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of PiiLROTask 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 the polymorphic discriminator. + * to JSON null. * @throws IOException If an error occurs while reading the PiiLROTask. */ public static PiiLROTask fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - PiiLROTask deserializedPiiLROTask = new PiiLROTask(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + PiiLROTask deserializedPiiLROTask = new PiiLROTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"PiiEntityRecognition".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'PiiEntityRecognition'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("taskName".equals(fieldName)) { - deserializedPiiLROTask.setTaskName(reader.getString()); - } else if ("parameters".equals(fieldName)) { - deserializedPiiLROTask.parameters = PiiTaskParameters.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("taskName".equals(fieldName)) { + deserializedPiiLROTask.setTaskName(reader.getString()); + } else if ("kind".equals(fieldName)) { + deserializedPiiLROTask.kind = AnalyzeTextLROTaskKind.fromString(reader.getString()); + } else if ("parameters".equals(fieldName)) { + deserializedPiiLROTask.parameters = PiiTaskParameters.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedPiiLROTask; - }); + return deserializedPiiLROTask; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiResult.java index be1980b48d9b..07a4846e7817 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiResult.java @@ -11,7 +11,9 @@ import java.io.IOException; import java.util.List; -/** The PiiResult model. */ +/** + * The PiiResult model. + */ @Fluent public final class PiiResult extends PreBuiltResult { /* @@ -19,12 +21,15 @@ public final class PiiResult extends PreBuiltResult { */ private List documents; - /** Creates an instance of PiiResult class. */ - public PiiResult() {} + /** + * Creates an instance of PiiResult class. + */ + public PiiResult() { + } /** * Get the documents property: Response by document. - * + * * @return the documents value. */ public List getDocuments() { @@ -33,7 +38,7 @@ public List getDocuments() { /** * Set the documents property: Response by document. - * + * * @param documents the documents value to set. * @return the PiiResult object itself. */ @@ -42,27 +47,36 @@ public PiiResult setDocuments(List documents) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public PiiResult setErrors(List errors) { super.setErrors(errors); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public PiiResult setStatistics(RequestStatistics statistics) { super.setStatistics(statistics); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public PiiResult setModelVersion(String modelVersion) { super.setModelVersion(modelVersion); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -75,38 +89,37 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of PiiResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of PiiResult if the JsonReader was pointing to an instance of it, or null if it was pointing - * to JSON null. + * to JSON null. * @throws IllegalStateException If the deserialized JSON object was missing any required properties. * @throws IOException If an error occurs while reading the PiiResult. */ public static PiiResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - PiiResult deserializedPiiResult = new PiiResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + PiiResult deserializedPiiResult = new PiiResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("errors".equals(fieldName)) { - List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); - deserializedPiiResult.setErrors(errors); - } else if ("modelVersion".equals(fieldName)) { - deserializedPiiResult.setModelVersion(reader.getString()); - } else if ("statistics".equals(fieldName)) { - deserializedPiiResult.setStatistics(RequestStatistics.fromJson(reader)); - } else if ("documents".equals(fieldName)) { - List documents = - reader.readArray(reader1 -> PiiResultDocumentsItem.fromJson(reader1)); - deserializedPiiResult.documents = documents; - } else { - reader.skipChildren(); - } - } + if ("errors".equals(fieldName)) { + List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); + deserializedPiiResult.setErrors(errors); + } else if ("modelVersion".equals(fieldName)) { + deserializedPiiResult.setModelVersion(reader.getString()); + } else if ("statistics".equals(fieldName)) { + deserializedPiiResult.setStatistics(RequestStatistics.fromJson(reader)); + } else if ("documents".equals(fieldName)) { + List documents + = reader.readArray(reader1 -> PiiResultDocumentsItem.fromJson(reader1)); + deserializedPiiResult.documents = documents; + } else { + reader.skipChildren(); + } + } - return deserializedPiiResult; - }); + return deserializedPiiResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiResultDocumentsItem.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiResultDocumentsItem.java index 2d167c8f8cd2..c2d40a4d322b 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiResultDocumentsItem.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiResultDocumentsItem.java @@ -11,47 +11,65 @@ import java.io.IOException; import java.util.List; -/** The PiiResultDocumentsItem model. */ +/** + * The PiiResultDocumentsItem model. + */ @Fluent public final class PiiResultDocumentsItem extends PiiEntitiesDocumentResult { - /** Creates an instance of PiiResultDocumentsItem class. */ - public PiiResultDocumentsItem() {} + /** + * Creates an instance of PiiResultDocumentsItem class. + */ + public PiiResultDocumentsItem() { + } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public PiiResultDocumentsItem setRedactedText(String redactedText) { super.setRedactedText(redactedText); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public PiiResultDocumentsItem setEntities(List entities) { super.setEntities(entities); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public PiiResultDocumentsItem setId(String id) { super.setId(id); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public PiiResultDocumentsItem setWarnings(List warnings) { super.setWarnings(warnings); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public PiiResultDocumentsItem setStatistics(DocumentStatistics statistics) { super.setStatistics(statistics); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -65,40 +83,38 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of PiiResultDocumentsItem from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of PiiResultDocumentsItem if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. + * 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 PiiResultDocumentsItem. */ public static PiiResultDocumentsItem fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - PiiResultDocumentsItem deserializedPiiResultDocumentsItem = new PiiResultDocumentsItem(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + PiiResultDocumentsItem deserializedPiiResultDocumentsItem = new PiiResultDocumentsItem(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("id".equals(fieldName)) { - deserializedPiiResultDocumentsItem.setId(reader.getString()); - } else if ("warnings".equals(fieldName)) { - List warnings = - reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); - deserializedPiiResultDocumentsItem.setWarnings(warnings); - } else if ("redactedText".equals(fieldName)) { - deserializedPiiResultDocumentsItem.setRedactedText(reader.getString()); - } else if ("entities".equals(fieldName)) { - List entities = reader.readArray(reader1 -> Entity.fromJson(reader1)); - deserializedPiiResultDocumentsItem.setEntities(entities); - } else if ("statistics".equals(fieldName)) { - deserializedPiiResultDocumentsItem.setStatistics(DocumentStatistics.fromJson(reader)); - } else { - reader.skipChildren(); - } - } + if ("id".equals(fieldName)) { + deserializedPiiResultDocumentsItem.setId(reader.getString()); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedPiiResultDocumentsItem.setWarnings(warnings); + } else if ("redactedText".equals(fieldName)) { + deserializedPiiResultDocumentsItem.setRedactedText(reader.getString()); + } else if ("entities".equals(fieldName)) { + List entities = reader.readArray(reader1 -> Entity.fromJson(reader1)); + deserializedPiiResultDocumentsItem.setEntities(entities); + } else if ("statistics".equals(fieldName)) { + deserializedPiiResultDocumentsItem.setStatistics(DocumentStatistics.fromJson(reader)); + } else { + reader.skipChildren(); + } + } - return deserializedPiiResultDocumentsItem; - }); + return deserializedPiiResultDocumentsItem; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiTask.java index 0c895291dcb2..38b5e1860682 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiTask.java @@ -1,25 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 PiiTask model. */ @Fluent -public final class PiiTask { +public final class PiiTask implements JsonSerializable { /* * The parameters property. */ - @JsonProperty(value = "parameters") private PiiTaskParameters parameters; /* * The taskName property. */ - @JsonProperty(value = "taskName") private String taskName; /** @@ -61,4 +63,44 @@ public PiiTask setTaskName(String taskName) { this.taskName = taskName; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("parameters", parameters); + jsonWriter.writeStringField("taskName", this.taskName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PiiTask from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PiiTask 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 PiiTask. + */ + public static PiiTask fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PiiTask deserializedPiiTask = new PiiTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("parameters".equals(fieldName)) { + deserializedPiiTask.parameters = PiiTaskParameters.fromJson(reader); + } else if ("taskName".equals(fieldName)) { + deserializedPiiTask.taskName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedPiiTask; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiTaskParameters.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiTaskParameters.java index 605bce6ea63f..8ccb3d91a49e 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiTaskParameters.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiTaskParameters.java @@ -10,9 +10,10 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.util.List; -import java.util.Objects; -/** Supported parameters for a PII Entities Recognition task. */ +/** + * Supported parameters for a PII Entities Recognition task. + */ @Fluent public final class PiiTaskParameters extends PreBuiltTaskParameters { /* @@ -26,17 +27,19 @@ public final class PiiTaskParameters extends PreBuiltTaskParameters { private List piiCategories; /* - * Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to - * Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. + * Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. */ private StringIndexType stringIndexType; - /** Creates an instance of PiiTaskParameters class. */ - public PiiTaskParameters() {} + /** + * Creates an instance of PiiTaskParameters class. + */ + public PiiTaskParameters() { + } /** * Get the domain property: The PII domain used for PII Entity Recognition. - * + * * @return the domain value. */ public PiiDomain getDomain() { @@ -45,7 +48,7 @@ public PiiDomain getDomain() { /** * Set the domain property: The PII domain used for PII Entity Recognition. - * + * * @param domain the domain value to set. * @return the PiiTaskParameters object itself. */ @@ -56,7 +59,7 @@ public PiiTaskParameters setDomain(PiiDomain domain) { /** * Get the piiCategories property: (Optional) describes the PII categories to return. - * + * * @return the piiCategories value. */ public List getPiiCategories() { @@ -65,7 +68,7 @@ public List getPiiCategories() { /** * Set the piiCategories property: (Optional) describes the PII categories to return. - * + * * @param piiCategories the piiCategories value to set. * @return the PiiTaskParameters object itself. */ @@ -78,7 +81,7 @@ public PiiTaskParameters setPiiCategories(List piiCategories) { * Get the stringIndexType property: Specifies the method used to interpret string offsets. Defaults to Text * Elements (Graphemes) according to Unicode v8.0.0. For additional information see * https://aka.ms/text-analytics-offsets. - * + * * @return the stringIndexType value. */ public StringIndexType getStringIndexType() { @@ -89,7 +92,7 @@ public StringIndexType getStringIndexType() { * Set the stringIndexType property: Specifies the method used to interpret string offsets. Defaults to Text * Elements (Graphemes) according to Unicode v8.0.0. For additional information see * https://aka.ms/text-analytics-offsets. - * + * * @param stringIndexType the stringIndexType value to set. * @return the PiiTaskParameters object itself. */ @@ -98,69 +101,73 @@ public PiiTaskParameters setStringIndexType(StringIndexType stringIndexType) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public PiiTaskParameters setModelVersion(String modelVersion) { super.setModelVersion(modelVersion); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public PiiTaskParameters setLoggingOptOut(Boolean loggingOptOut) { super.setLoggingOptOut(loggingOptOut); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); jsonWriter.writeBooleanField("loggingOptOut", isLoggingOptOut()); jsonWriter.writeStringField("modelVersion", getModelVersion()); - jsonWriter.writeStringField("domain", Objects.toString(this.domain, null)); - jsonWriter.writeArrayField( - "piiCategories", - this.piiCategories, - (writer, element) -> writer.writeString(Objects.toString(element, null))); - jsonWriter.writeStringField("stringIndexType", Objects.toString(this.stringIndexType, null)); + jsonWriter.writeStringField("domain", this.domain == null ? null : this.domain.toString()); + jsonWriter.writeArrayField("piiCategories", this.piiCategories, + (writer, element) -> writer.writeString(element == null ? null : element.toString())); + jsonWriter.writeStringField("stringIndexType", + this.stringIndexType == null ? null : this.stringIndexType.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of PiiTaskParameters from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of PiiTaskParameters if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * pointing to JSON null. * @throws IOException If an error occurs while reading the PiiTaskParameters. */ public static PiiTaskParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - PiiTaskParameters deserializedPiiTaskParameters = new PiiTaskParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("loggingOptOut".equals(fieldName)) { - deserializedPiiTaskParameters.setLoggingOptOut(reader.getNullable(JsonReader::getBoolean)); - } else if ("modelVersion".equals(fieldName)) { - deserializedPiiTaskParameters.setModelVersion(reader.getString()); - } else if ("domain".equals(fieldName)) { - deserializedPiiTaskParameters.domain = PiiDomain.fromString(reader.getString()); - } else if ("piiCategories".equals(fieldName)) { - List piiCategories = - reader.readArray(reader1 -> PiiCategory.fromString(reader1.getString())); - deserializedPiiTaskParameters.piiCategories = piiCategories; - } else if ("stringIndexType".equals(fieldName)) { - deserializedPiiTaskParameters.stringIndexType = - StringIndexType.fromString(reader.getString()); - } else { - reader.skipChildren(); - } - } - - return deserializedPiiTaskParameters; - }); + return jsonReader.readObject(reader -> { + PiiTaskParameters deserializedPiiTaskParameters = new PiiTaskParameters(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("loggingOptOut".equals(fieldName)) { + deserializedPiiTaskParameters.setLoggingOptOut(reader.getNullable(JsonReader::getBoolean)); + } else if ("modelVersion".equals(fieldName)) { + deserializedPiiTaskParameters.setModelVersion(reader.getString()); + } else if ("domain".equals(fieldName)) { + deserializedPiiTaskParameters.domain = PiiDomain.fromString(reader.getString()); + } else if ("piiCategories".equals(fieldName)) { + List piiCategories + = reader.readArray(reader1 -> PiiCategory.fromString(reader1.getString())); + deserializedPiiTaskParameters.piiCategories = piiCategories; + } else if ("stringIndexType".equals(fieldName)) { + deserializedPiiTaskParameters.stringIndexType = StringIndexType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedPiiTaskParameters; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiTaskResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiTaskResult.java index 0d84036caaaa..8503b7a57971 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiTaskResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PiiTaskResult.java @@ -9,22 +9,41 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** The PiiTaskResult model. */ +/** + * The PiiTaskResult model. + */ @Fluent public final class PiiTaskResult extends AnalyzeTextTaskResult { + /* + * Enumeration of supported Text Analysis task results. + */ + private AnalyzeTextTaskResultsKind kind = AnalyzeTextTaskResultsKind.PII_ENTITY_RECOGNITION_RESULTS; + /* * The results property. */ private PiiResult results; - /** Creates an instance of PiiTaskResult class. */ - public PiiTaskResult() {} + /** + * Creates an instance of PiiTaskResult class. + */ + public PiiTaskResult() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis task results. + * + * @return the kind value. + */ + @Override + public AnalyzeTextTaskResultsKind getKind() { + return this.kind; + } /** * Get the results property: The results property. - * + * * @return the results value. */ public PiiResult getResults() { @@ -33,7 +52,7 @@ public PiiResult getResults() { /** * Set the results property: The results property. - * + * * @param results the results value to set. * @return the PiiTaskResult object itself. */ @@ -42,49 +61,43 @@ public PiiTaskResult setResults(PiiResult results) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField( - "kind", Objects.toString(AnalyzeTextTaskResultsKind.PII_ENTITY_RECOGNITION_RESULTS, null)); jsonWriter.writeJsonField("results", this.results); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of PiiTaskResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of PiiTaskResult 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 or the - * polymorphic discriminator. + * 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 PiiTaskResult. */ public static PiiTaskResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - PiiTaskResult deserializedPiiTaskResult = new PiiTaskResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + PiiTaskResult deserializedPiiTaskResult = new PiiTaskResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"PiiEntityRecognitionResults".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'PiiEntityRecognitionResults'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("results".equals(fieldName)) { - deserializedPiiTaskResult.results = PiiResult.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("results".equals(fieldName)) { + deserializedPiiTaskResult.results = PiiResult.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedPiiTaskResult.kind = AnalyzeTextTaskResultsKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedPiiTaskResult; - }); + return deserializedPiiTaskResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PreBuiltResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PreBuiltResult.java index db26267c0d44..43d47f35d2ad 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PreBuiltResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PreBuiltResult.java @@ -12,7 +12,9 @@ import java.io.IOException; import java.util.List; -/** The PreBuiltResult model. */ +/** + * The PreBuiltResult model. + */ @Fluent public class PreBuiltResult implements JsonSerializable { /* @@ -30,12 +32,15 @@ public class PreBuiltResult implements JsonSerializable { */ private String modelVersion; - /** Creates an instance of PreBuiltResult class. */ - public PreBuiltResult() {} + /** + * Creates an instance of PreBuiltResult class. + */ + public PreBuiltResult() { + } /** * Get the errors property: Errors by document id. - * + * * @return the errors value. */ public List getErrors() { @@ -44,7 +49,7 @@ public List getErrors() { /** * Set the errors property: Errors by document id. - * + * * @param errors the errors value to set. * @return the PreBuiltResult object itself. */ @@ -56,7 +61,7 @@ public PreBuiltResult setErrors(List errors) { /** * Get the statistics property: if showStats=true was specified in the request this field will contain information * about the request payload. - * + * * @return the statistics value. */ public RequestStatistics getStatistics() { @@ -66,7 +71,7 @@ public RequestStatistics getStatistics() { /** * Set the statistics property: if showStats=true was specified in the request this field will contain information * about the request payload. - * + * * @param statistics the statistics value to set. * @return the PreBuiltResult object itself. */ @@ -77,7 +82,7 @@ public PreBuiltResult setStatistics(RequestStatistics statistics) { /** * Get the modelVersion property: This field indicates which model is used for scoring. - * + * * @return the modelVersion value. */ public String getModelVersion() { @@ -86,7 +91,7 @@ public String getModelVersion() { /** * Set the modelVersion property: This field indicates which model is used for scoring. - * + * * @param modelVersion the modelVersion value to set. * @return the PreBuiltResult object itself. */ @@ -95,6 +100,9 @@ public PreBuiltResult setModelVersion(String modelVersion) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -106,34 +114,33 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of PreBuiltResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of PreBuiltResult if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 PreBuiltResult. */ public static PreBuiltResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - PreBuiltResult deserializedPreBuiltResult = new PreBuiltResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("errors".equals(fieldName)) { - List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); - deserializedPreBuiltResult.errors = errors; - } else if ("modelVersion".equals(fieldName)) { - deserializedPreBuiltResult.modelVersion = reader.getString(); - } else if ("statistics".equals(fieldName)) { - deserializedPreBuiltResult.statistics = RequestStatistics.fromJson(reader); - } else { - reader.skipChildren(); - } - } - - return deserializedPreBuiltResult; - }); + return jsonReader.readObject(reader -> { + PreBuiltResult deserializedPreBuiltResult = new PreBuiltResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("errors".equals(fieldName)) { + List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); + deserializedPreBuiltResult.errors = errors; + } else if ("modelVersion".equals(fieldName)) { + deserializedPreBuiltResult.modelVersion = reader.getString(); + } else if ("statistics".equals(fieldName)) { + deserializedPreBuiltResult.statistics = RequestStatistics.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedPreBuiltResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PreBuiltTaskParameters.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PreBuiltTaskParameters.java index d6bbc79e7e85..dbc3da463507 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PreBuiltTaskParameters.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/PreBuiltTaskParameters.java @@ -10,7 +10,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** Parameters object for a text analysis task using pre-built models. */ +/** + * Parameters object for a text analysis task using pre-built models. + */ @Fluent public class PreBuiltTaskParameters extends TaskParameters { /* @@ -18,12 +20,15 @@ public class PreBuiltTaskParameters extends TaskParameters { */ private String modelVersion; - /** Creates an instance of PreBuiltTaskParameters class. */ - public PreBuiltTaskParameters() {} + /** + * Creates an instance of PreBuiltTaskParameters class. + */ + public PreBuiltTaskParameters() { + } /** * Get the modelVersion property: The modelVersion property. - * + * * @return the modelVersion value. */ public String getModelVersion() { @@ -32,7 +37,7 @@ public String getModelVersion() { /** * Set the modelVersion property: The modelVersion property. - * + * * @param modelVersion the modelVersion value to set. * @return the PreBuiltTaskParameters object itself. */ @@ -41,13 +46,18 @@ public PreBuiltTaskParameters setModelVersion(String modelVersion) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public PreBuiltTaskParameters setLoggingOptOut(Boolean loggingOptOut) { super.setLoggingOptOut(loggingOptOut); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -58,31 +68,29 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of PreBuiltTaskParameters from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of PreBuiltTaskParameters if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. + * was pointing to JSON null. * @throws IOException If an error occurs while reading the PreBuiltTaskParameters. */ public static PreBuiltTaskParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - PreBuiltTaskParameters deserializedPreBuiltTaskParameters = new PreBuiltTaskParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + PreBuiltTaskParameters deserializedPreBuiltTaskParameters = new PreBuiltTaskParameters(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("loggingOptOut".equals(fieldName)) { - deserializedPreBuiltTaskParameters.setLoggingOptOut( - reader.getNullable(JsonReader::getBoolean)); - } else if ("modelVersion".equals(fieldName)) { - deserializedPreBuiltTaskParameters.modelVersion = reader.getString(); - } else { - reader.skipChildren(); - } - } + if ("loggingOptOut".equals(fieldName)) { + deserializedPreBuiltTaskParameters.setLoggingOptOut(reader.getNullable(JsonReader::getBoolean)); + } else if ("modelVersion".equals(fieldName)) { + deserializedPreBuiltTaskParameters.modelVersion = reader.getString(); + } else { + reader.skipChildren(); + } + } - return deserializedPreBuiltTaskParameters; - }); + return deserializedPreBuiltTaskParameters; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/RequestStatistics.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/RequestStatistics.java index 903f493b12d5..c711d4ae3e1d 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/RequestStatistics.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/RequestStatistics.java @@ -11,7 +11,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** if showStats=true was specified in the request this field will contain information about the request payload. */ +/** + * if showStats=true was specified in the request this field will contain information about the request payload. + */ @Fluent public final class RequestStatistics implements JsonSerializable { /* @@ -34,12 +36,15 @@ public final class RequestStatistics implements JsonSerializable { - RequestStatistics deserializedRequestStatistics = new RequestStatistics(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("documentsCount".equals(fieldName)) { - deserializedRequestStatistics.documentsCount = reader.getInt(); - } else if ("validDocumentsCount".equals(fieldName)) { - deserializedRequestStatistics.validDocumentsCount = reader.getInt(); - } else if ("erroneousDocumentsCount".equals(fieldName)) { - deserializedRequestStatistics.erroneousDocumentsCount = reader.getInt(); - } else if ("transactionsCount".equals(fieldName)) { - deserializedRequestStatistics.transactionsCount = reader.getLong(); - } else { - reader.skipChildren(); - } - } - - return deserializedRequestStatistics; - }); + return jsonReader.readObject(reader -> { + RequestStatistics deserializedRequestStatistics = new RequestStatistics(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("documentsCount".equals(fieldName)) { + deserializedRequestStatistics.documentsCount = reader.getInt(); + } else if ("validDocumentsCount".equals(fieldName)) { + deserializedRequestStatistics.validDocumentsCount = reader.getInt(); + } else if ("erroneousDocumentsCount".equals(fieldName)) { + deserializedRequestStatistics.erroneousDocumentsCount = reader.getInt(); + } else if ("transactionsCount".equals(fieldName)) { + deserializedRequestStatistics.transactionsCount = reader.getLong(); + } else { + reader.skipChildren(); + } + } + + return deserializedRequestStatistics; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentenceAssessment.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentenceAssessment.java index 48c16b238c7d..331ca6614680 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentenceAssessment.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentenceAssessment.java @@ -10,9 +10,10 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** The SentenceAssessment model. */ +/** + * The SentenceAssessment model. + */ @Fluent public final class SentenceAssessment implements JsonSerializable { /* @@ -45,12 +46,15 @@ public final class SentenceAssessment implements JsonSerializable { - SentenceAssessment deserializedSentenceAssessment = new SentenceAssessment(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("sentiment".equals(fieldName)) { - deserializedSentenceAssessment.sentiment = - TokenSentimentValue.fromString(reader.getString()); - } else if ("confidenceScores".equals(fieldName)) { - deserializedSentenceAssessment.confidenceScores = - TargetConfidenceScoreLabel.fromJson(reader); - } else if ("offset".equals(fieldName)) { - deserializedSentenceAssessment.offset = reader.getInt(); - } else if ("length".equals(fieldName)) { - deserializedSentenceAssessment.length = reader.getInt(); - } else if ("text".equals(fieldName)) { - deserializedSentenceAssessment.text = reader.getString(); - } else if ("isNegated".equals(fieldName)) { - deserializedSentenceAssessment.isNegated = reader.getBoolean(); - } else { - reader.skipChildren(); - } - } - - return deserializedSentenceAssessment; - }); + return jsonReader.readObject(reader -> { + SentenceAssessment deserializedSentenceAssessment = new SentenceAssessment(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("sentiment".equals(fieldName)) { + deserializedSentenceAssessment.sentiment = TokenSentimentValue.fromString(reader.getString()); + } else if ("confidenceScores".equals(fieldName)) { + deserializedSentenceAssessment.confidenceScores = TargetConfidenceScoreLabel.fromJson(reader); + } else if ("offset".equals(fieldName)) { + deserializedSentenceAssessment.offset = reader.getInt(); + } else if ("length".equals(fieldName)) { + deserializedSentenceAssessment.length = reader.getInt(); + } else if ("text".equals(fieldName)) { + deserializedSentenceAssessment.text = reader.getString(); + } else if ("isNegated".equals(fieldName)) { + deserializedSentenceAssessment.isNegated = reader.getBoolean(); + } else { + reader.skipChildren(); + } + } + + return deserializedSentenceAssessment; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentenceSentiment.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentenceSentiment.java index 94299359608a..4630ac5f26cb 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentenceSentiment.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentenceSentiment.java @@ -11,9 +11,10 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.util.List; -import java.util.Objects; -/** The SentenceSentiment model. */ +/** + * The SentenceSentiment model. + */ @Fluent public final class SentenceSentiment implements JsonSerializable { /* @@ -51,12 +52,15 @@ public final class SentenceSentiment implements JsonSerializable assessments; - /** Creates an instance of SentenceSentiment class. */ - public SentenceSentiment() {} + /** + * Creates an instance of SentenceSentiment class. + */ + public SentenceSentiment() { + } /** * Get the text property: The sentence text. - * + * * @return the text value. */ public String getText() { @@ -65,7 +69,7 @@ public String getText() { /** * Set the text property: The sentence text. - * + * * @param text the text value to set. * @return the SentenceSentiment object itself. */ @@ -76,7 +80,7 @@ public SentenceSentiment setText(String text) { /** * Get the sentiment property: The predicted Sentiment for the sentence. - * + * * @return the sentiment value. */ public SentenceSentimentValue getSentiment() { @@ -85,7 +89,7 @@ public SentenceSentimentValue getSentiment() { /** * Set the sentiment property: The predicted Sentiment for the sentence. - * + * * @param sentiment the sentiment value to set. * @return the SentenceSentiment object itself. */ @@ -97,7 +101,7 @@ public SentenceSentiment setSentiment(SentenceSentimentValue sentiment) { /** * Get the confidenceScores property: The sentiment confidence score between 0 and 1 for the sentence for all * classes. - * + * * @return the confidenceScores value. */ public SentimentConfidenceScorePerLabel getConfidenceScores() { @@ -107,7 +111,7 @@ public SentimentConfidenceScorePerLabel getConfidenceScores() { /** * Set the confidenceScores property: The sentiment confidence score between 0 and 1 for the sentence for all * classes. - * + * * @param confidenceScores the confidenceScores value to set. * @return the SentenceSentiment object itself. */ @@ -118,7 +122,7 @@ public SentenceSentiment setConfidenceScores(SentimentConfidenceScorePerLabel co /** * Get the offset property: The sentence offset from the start of the document. - * + * * @return the offset value. */ public int getOffset() { @@ -127,7 +131,7 @@ public int getOffset() { /** * Set the offset property: The sentence offset from the start of the document. - * + * * @param offset the offset value to set. * @return the SentenceSentiment object itself. */ @@ -138,7 +142,7 @@ public SentenceSentiment setOffset(int offset) { /** * Get the length property: The length of the sentence. - * + * * @return the length value. */ public int getLength() { @@ -147,7 +151,7 @@ public int getLength() { /** * Set the length property: The length of the sentence. - * + * * @param length the length value to set. * @return the SentenceSentiment object itself. */ @@ -158,7 +162,7 @@ public SentenceSentiment setLength(int length) { /** * Get the targets property: The array of sentence targets for the sentence. - * + * * @return the targets value. */ public List getTargets() { @@ -167,7 +171,7 @@ public List getTargets() { /** * Set the targets property: The array of sentence targets for the sentence. - * + * * @param targets the targets value to set. * @return the SentenceSentiment object itself. */ @@ -178,7 +182,7 @@ public SentenceSentiment setTargets(List targets) { /** * Get the assessments property: The array of assessments for the sentence. - * + * * @return the assessments value. */ public List getAssessments() { @@ -187,7 +191,7 @@ public List getAssessments() { /** * Set the assessments property: The array of assessments for the sentence. - * + * * @param assessments the assessments value to set. * @return the SentenceSentiment object itself. */ @@ -196,11 +200,14 @@ public SentenceSentiment setAssessments(List assessments) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); jsonWriter.writeStringField("text", this.text); - jsonWriter.writeStringField("sentiment", Objects.toString(this.sentiment, null)); + jsonWriter.writeStringField("sentiment", this.sentiment == null ? null : this.sentiment.toString()); jsonWriter.writeJsonField("confidenceScores", this.confidenceScores); jsonWriter.writeIntField("offset", this.offset); jsonWriter.writeIntField("length", this.length); @@ -211,47 +218,43 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of SentenceSentiment from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of SentenceSentiment if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 SentenceSentiment. */ public static SentenceSentiment fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - SentenceSentiment deserializedSentenceSentiment = new SentenceSentiment(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + SentenceSentiment deserializedSentenceSentiment = new SentenceSentiment(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("text".equals(fieldName)) { - deserializedSentenceSentiment.text = reader.getString(); - } else if ("sentiment".equals(fieldName)) { - deserializedSentenceSentiment.sentiment = - SentenceSentimentValue.fromString(reader.getString()); - } else if ("confidenceScores".equals(fieldName)) { - deserializedSentenceSentiment.confidenceScores = - SentimentConfidenceScorePerLabel.fromJson(reader); - } else if ("offset".equals(fieldName)) { - deserializedSentenceSentiment.offset = reader.getInt(); - } else if ("length".equals(fieldName)) { - deserializedSentenceSentiment.length = reader.getInt(); - } else if ("targets".equals(fieldName)) { - List targets = - reader.readArray(reader1 -> SentenceTarget.fromJson(reader1)); - deserializedSentenceSentiment.targets = targets; - } else if ("assessments".equals(fieldName)) { - List assessments = - reader.readArray(reader1 -> SentenceAssessment.fromJson(reader1)); - deserializedSentenceSentiment.assessments = assessments; - } else { - reader.skipChildren(); - } - } + if ("text".equals(fieldName)) { + deserializedSentenceSentiment.text = reader.getString(); + } else if ("sentiment".equals(fieldName)) { + deserializedSentenceSentiment.sentiment = SentenceSentimentValue.fromString(reader.getString()); + } else if ("confidenceScores".equals(fieldName)) { + deserializedSentenceSentiment.confidenceScores = SentimentConfidenceScorePerLabel.fromJson(reader); + } else if ("offset".equals(fieldName)) { + deserializedSentenceSentiment.offset = reader.getInt(); + } else if ("length".equals(fieldName)) { + deserializedSentenceSentiment.length = reader.getInt(); + } else if ("targets".equals(fieldName)) { + List targets = reader.readArray(reader1 -> SentenceTarget.fromJson(reader1)); + deserializedSentenceSentiment.targets = targets; + } else if ("assessments".equals(fieldName)) { + List assessments + = reader.readArray(reader1 -> SentenceAssessment.fromJson(reader1)); + deserializedSentenceSentiment.assessments = assessments; + } else { + reader.skipChildren(); + } + } - return deserializedSentenceSentiment; - }); + return deserializedSentenceSentiment; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentenceSentimentValue.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentenceSentimentValue.java index 733d82a6caf2..74625500daf1 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentenceSentimentValue.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentenceSentimentValue.java @@ -4,18 +4,28 @@ package com.azure.ai.textanalytics.implementation.models; -/** The predicted Sentiment for the sentence. */ +/** + * The predicted Sentiment for the sentence. + */ public enum SentenceSentimentValue { - /** Enum value positive. */ + /** + * Enum value positive. + */ POSITIVE("positive"), - /** Enum value neutral. */ + /** + * Enum value neutral. + */ NEUTRAL("neutral"), - /** Enum value negative. */ + /** + * Enum value negative. + */ NEGATIVE("negative"); - /** The actual serialized value for a SentenceSentimentValue instance. */ + /** + * The actual serialized value for a SentenceSentimentValue instance. + */ private final String value; SentenceSentimentValue(String value) { @@ -24,7 +34,7 @@ public enum SentenceSentimentValue { /** * Parses a serialized value to a SentenceSentimentValue instance. - * + * * @param value the serialized value to parse. * @return the parsed SentenceSentimentValue object, or null if unable to parse. */ @@ -41,7 +51,9 @@ public static SentenceSentimentValue fromString(String value) { return null; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public String toString() { return this.value; diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentenceTarget.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentenceTarget.java index 3746a146da75..0a20f6432c55 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentenceTarget.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentenceTarget.java @@ -11,9 +11,10 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.util.List; -import java.util.Objects; -/** The SentenceTarget model. */ +/** + * The SentenceTarget model. + */ @Fluent public final class SentenceTarget implements JsonSerializable { /* @@ -46,12 +47,15 @@ public final class SentenceTarget implements JsonSerializable { */ private List relations; - /** Creates an instance of SentenceTarget class. */ - public SentenceTarget() {} + /** + * Creates an instance of SentenceTarget class. + */ + public SentenceTarget() { + } /** * Get the sentiment property: Targeted sentiment in the sentence. - * + * * @return the sentiment value. */ public TokenSentimentValue getSentiment() { @@ -60,7 +64,7 @@ public TokenSentimentValue getSentiment() { /** * Set the sentiment property: Targeted sentiment in the sentence. - * + * * @param sentiment the sentiment value to set. * @return the SentenceTarget object itself. */ @@ -71,7 +75,7 @@ public SentenceTarget setSentiment(TokenSentimentValue sentiment) { /** * Get the confidenceScores property: Target sentiment confidence scores for the target in the sentence. - * + * * @return the confidenceScores value. */ public TargetConfidenceScoreLabel getConfidenceScores() { @@ -80,7 +84,7 @@ public TargetConfidenceScoreLabel getConfidenceScores() { /** * Set the confidenceScores property: Target sentiment confidence scores for the target in the sentence. - * + * * @param confidenceScores the confidenceScores value to set. * @return the SentenceTarget object itself. */ @@ -91,7 +95,7 @@ public SentenceTarget setConfidenceScores(TargetConfidenceScoreLabel confidenceS /** * Get the offset property: The target offset from the start of the sentence. - * + * * @return the offset value. */ public int getOffset() { @@ -100,7 +104,7 @@ public int getOffset() { /** * Set the offset property: The target offset from the start of the sentence. - * + * * @param offset the offset value to set. * @return the SentenceTarget object itself. */ @@ -111,7 +115,7 @@ public SentenceTarget setOffset(int offset) { /** * Get the length property: The length of the target. - * + * * @return the length value. */ public int getLength() { @@ -120,7 +124,7 @@ public int getLength() { /** * Set the length property: The length of the target. - * + * * @param length the length value to set. * @return the SentenceTarget object itself. */ @@ -131,7 +135,7 @@ public SentenceTarget setLength(int length) { /** * Get the text property: The target text detected. - * + * * @return the text value. */ public String getText() { @@ -140,7 +144,7 @@ public String getText() { /** * Set the text property: The target text detected. - * + * * @param text the text value to set. * @return the SentenceTarget object itself. */ @@ -151,7 +155,7 @@ public SentenceTarget setText(String text) { /** * Get the relations property: The array of either assessment or target objects which is related to the target. - * + * * @return the relations value. */ public List getRelations() { @@ -160,7 +164,7 @@ public List getRelations() { /** * Set the relations property: The array of either assessment or target objects which is related to the target. - * + * * @param relations the relations value to set. * @return the SentenceTarget object itself. */ @@ -169,10 +173,13 @@ public SentenceTarget setRelations(List relations) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("sentiment", Objects.toString(this.sentiment, null)); + jsonWriter.writeStringField("sentiment", this.sentiment == null ? null : this.sentiment.toString()); jsonWriter.writeJsonField("confidenceScores", this.confidenceScores); jsonWriter.writeIntField("offset", this.offset); jsonWriter.writeIntField("length", this.length); @@ -183,41 +190,39 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of SentenceTarget from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of SentenceTarget if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 SentenceTarget. */ public static SentenceTarget fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - SentenceTarget deserializedSentenceTarget = new SentenceTarget(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("sentiment".equals(fieldName)) { - deserializedSentenceTarget.sentiment = TokenSentimentValue.fromString(reader.getString()); - } else if ("confidenceScores".equals(fieldName)) { - deserializedSentenceTarget.confidenceScores = TargetConfidenceScoreLabel.fromJson(reader); - } else if ("offset".equals(fieldName)) { - deserializedSentenceTarget.offset = reader.getInt(); - } else if ("length".equals(fieldName)) { - deserializedSentenceTarget.length = reader.getInt(); - } else if ("text".equals(fieldName)) { - deserializedSentenceTarget.text = reader.getString(); - } else if ("relations".equals(fieldName)) { - List relations = - reader.readArray(reader1 -> TargetRelation.fromJson(reader1)); - deserializedSentenceTarget.relations = relations; - } else { - reader.skipChildren(); - } - } - - return deserializedSentenceTarget; - }); + return jsonReader.readObject(reader -> { + SentenceTarget deserializedSentenceTarget = new SentenceTarget(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("sentiment".equals(fieldName)) { + deserializedSentenceTarget.sentiment = TokenSentimentValue.fromString(reader.getString()); + } else if ("confidenceScores".equals(fieldName)) { + deserializedSentenceTarget.confidenceScores = TargetConfidenceScoreLabel.fromJson(reader); + } else if ("offset".equals(fieldName)) { + deserializedSentenceTarget.offset = reader.getInt(); + } else if ("length".equals(fieldName)) { + deserializedSentenceTarget.length = reader.getInt(); + } else if ("text".equals(fieldName)) { + deserializedSentenceTarget.text = reader.getString(); + } else if ("relations".equals(fieldName)) { + List relations = reader.readArray(reader1 -> TargetRelation.fromJson(reader1)); + deserializedSentenceTarget.relations = relations; + } else { + reader.skipChildren(); + } + } + + return deserializedSentenceTarget; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentAnalysisLROTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentAnalysisLROTask.java index bd15bc26c522..b4df223d865f 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentAnalysisLROTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentAnalysisLROTask.java @@ -9,22 +9,41 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** An object representing the task definition for a Sentiment Analysis task. */ +/** + * An object representing the task definition for a Sentiment Analysis task. + */ @Fluent public final class SentimentAnalysisLROTask extends AnalyzeTextLROTask { + /* + * Enumeration of supported long-running Text Analysis tasks. + */ + private AnalyzeTextLROTaskKind kind = AnalyzeTextLROTaskKind.SENTIMENT_ANALYSIS; + /* * Supported parameters for a Sentiment Analysis task. */ private SentimentAnalysisTaskParameters parameters; - /** Creates an instance of SentimentAnalysisLROTask class. */ - public SentimentAnalysisLROTask() {} + /** + * Creates an instance of SentimentAnalysisLROTask class. + */ + public SentimentAnalysisLROTask() { + } + + /** + * Get the kind property: Enumeration of supported long-running Text Analysis tasks. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROTaskKind getKind() { + return this.kind; + } /** * Get the parameters property: Supported parameters for a Sentiment Analysis task. - * + * * @return the parameters value. */ public SentimentAnalysisTaskParameters getParameters() { @@ -33,7 +52,7 @@ public SentimentAnalysisTaskParameters getParameters() { /** * Set the parameters property: Supported parameters for a Sentiment Analysis task. - * + * * @param parameters the parameters value to set. * @return the SentimentAnalysisLROTask object itself. */ @@ -42,58 +61,54 @@ public SentimentAnalysisLROTask setParameters(SentimentAnalysisTaskParameters pa return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public SentimentAnalysisLROTask setTaskName(String taskName) { super.setTaskName(taskName); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("kind", Objects.toString(AnalyzeTextLROTaskKind.SENTIMENT_ANALYSIS, null)); jsonWriter.writeStringField("taskName", getTaskName()); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); jsonWriter.writeJsonField("parameters", this.parameters); return jsonWriter.writeEndObject(); } /** * Reads an instance of SentimentAnalysisLROTask from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of SentimentAnalysisLROTask 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 the polymorphic discriminator. + * it was pointing to JSON null. * @throws IOException If an error occurs while reading the SentimentAnalysisLROTask. */ public static SentimentAnalysisLROTask fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - SentimentAnalysisLROTask deserializedSentimentAnalysisLROTask = new SentimentAnalysisLROTask(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + SentimentAnalysisLROTask deserializedSentimentAnalysisLROTask = new SentimentAnalysisLROTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"SentimentAnalysis".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'SentimentAnalysis'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("taskName".equals(fieldName)) { - deserializedSentimentAnalysisLROTask.setTaskName(reader.getString()); - } else if ("parameters".equals(fieldName)) { - deserializedSentimentAnalysisLROTask.parameters = - SentimentAnalysisTaskParameters.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("taskName".equals(fieldName)) { + deserializedSentimentAnalysisLROTask.setTaskName(reader.getString()); + } else if ("kind".equals(fieldName)) { + deserializedSentimentAnalysisLROTask.kind = AnalyzeTextLROTaskKind.fromString(reader.getString()); + } else if ("parameters".equals(fieldName)) { + deserializedSentimentAnalysisLROTask.parameters = SentimentAnalysisTaskParameters.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedSentimentAnalysisLROTask; - }); + return deserializedSentimentAnalysisLROTask; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentAnalysisTask.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentAnalysisTask.java index a98bb2b64136..de83a41a92c2 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentAnalysisTask.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentAnalysisTask.java @@ -1,25 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 SentimentAnalysisTask model. */ @Fluent -public final class SentimentAnalysisTask { +public final class SentimentAnalysisTask implements JsonSerializable { /* * The parameters property. */ - @JsonProperty(value = "parameters") private SentimentAnalysisTaskParameters parameters; /* * The taskName property. */ - @JsonProperty(value = "taskName") private String taskName; /** @@ -61,4 +63,44 @@ public SentimentAnalysisTask setTaskName(String taskName) { this.taskName = taskName; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("parameters", parameters); + jsonWriter.writeStringField("taskName", this.taskName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SentimentAnalysisTask from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SentimentAnalysisTask 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 SentimentAnalysisTask. + */ + public static SentimentAnalysisTask fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SentimentAnalysisTask deserializedSentimentAnalysisTask = new SentimentAnalysisTask(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("parameters".equals(fieldName)) { + deserializedSentimentAnalysisTask.parameters = SentimentAnalysisTaskParameters.fromJson(reader); + } else if ("taskName".equals(fieldName)) { + deserializedSentimentAnalysisTask.taskName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedSentimentAnalysisTask; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentAnalysisTaskParameters.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentAnalysisTaskParameters.java index 940631f5415d..6a684c167644 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentAnalysisTaskParameters.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentAnalysisTaskParameters.java @@ -9,9 +9,10 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** Supported parameters for a Sentiment Analysis task. */ +/** + * Supported parameters for a Sentiment Analysis task. + */ @Fluent public final class SentimentAnalysisTaskParameters extends PreBuiltTaskParameters { /* @@ -20,17 +21,19 @@ public final class SentimentAnalysisTaskParameters extends PreBuiltTaskParameter private Boolean opinionMining; /* - * Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to - * Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. + * Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. */ private StringIndexType stringIndexType; - /** Creates an instance of SentimentAnalysisTaskParameters class. */ - public SentimentAnalysisTaskParameters() {} + /** + * Creates an instance of SentimentAnalysisTaskParameters class. + */ + public SentimentAnalysisTaskParameters() { + } /** * Get the opinionMining property: The opinionMining property. - * + * * @return the opinionMining value. */ public Boolean isOpinionMining() { @@ -39,7 +42,7 @@ public Boolean isOpinionMining() { /** * Set the opinionMining property: The opinionMining property. - * + * * @param opinionMining the opinionMining value to set. * @return the SentimentAnalysisTaskParameters object itself. */ @@ -52,7 +55,7 @@ public SentimentAnalysisTaskParameters setOpinionMining(Boolean opinionMining) { * Get the stringIndexType property: Specifies the method used to interpret string offsets. Defaults to Text * Elements (Graphemes) according to Unicode v8.0.0. For additional information see * https://aka.ms/text-analytics-offsets. - * + * * @return the stringIndexType value. */ public StringIndexType getStringIndexType() { @@ -63,7 +66,7 @@ public StringIndexType getStringIndexType() { * Set the stringIndexType property: Specifies the method used to interpret string offsets. Defaults to Text * Elements (Graphemes) according to Unicode v8.0.0. For additional information see * https://aka.ms/text-analytics-offsets. - * + * * @param stringIndexType the stringIndexType value to set. * @return the SentimentAnalysisTaskParameters object itself. */ @@ -72,64 +75,71 @@ public SentimentAnalysisTaskParameters setStringIndexType(StringIndexType string return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public SentimentAnalysisTaskParameters setModelVersion(String modelVersion) { super.setModelVersion(modelVersion); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public SentimentAnalysisTaskParameters setLoggingOptOut(Boolean loggingOptOut) { super.setLoggingOptOut(loggingOptOut); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); jsonWriter.writeBooleanField("loggingOptOut", isLoggingOptOut()); jsonWriter.writeStringField("modelVersion", getModelVersion()); jsonWriter.writeBooleanField("opinionMining", this.opinionMining); - jsonWriter.writeStringField("stringIndexType", Objects.toString(this.stringIndexType, null)); + jsonWriter.writeStringField("stringIndexType", + this.stringIndexType == null ? null : this.stringIndexType.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of SentimentAnalysisTaskParameters from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of SentimentAnalysisTaskParameters if the JsonReader was pointing to an instance of it, or - * null if it was pointing to JSON null. + * null if it was pointing to JSON null. * @throws IOException If an error occurs while reading the SentimentAnalysisTaskParameters. */ public static SentimentAnalysisTaskParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - SentimentAnalysisTaskParameters deserializedSentimentAnalysisTaskParameters = - new SentimentAnalysisTaskParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + SentimentAnalysisTaskParameters deserializedSentimentAnalysisTaskParameters + = new SentimentAnalysisTaskParameters(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("loggingOptOut".equals(fieldName)) { - deserializedSentimentAnalysisTaskParameters.setLoggingOptOut( - reader.getNullable(JsonReader::getBoolean)); - } else if ("modelVersion".equals(fieldName)) { - deserializedSentimentAnalysisTaskParameters.setModelVersion(reader.getString()); - } else if ("opinionMining".equals(fieldName)) { - deserializedSentimentAnalysisTaskParameters.opinionMining = - reader.getNullable(JsonReader::getBoolean); - } else if ("stringIndexType".equals(fieldName)) { - deserializedSentimentAnalysisTaskParameters.stringIndexType = - StringIndexType.fromString(reader.getString()); - } else { - reader.skipChildren(); - } - } + if ("loggingOptOut".equals(fieldName)) { + deserializedSentimentAnalysisTaskParameters + .setLoggingOptOut(reader.getNullable(JsonReader::getBoolean)); + } else if ("modelVersion".equals(fieldName)) { + deserializedSentimentAnalysisTaskParameters.setModelVersion(reader.getString()); + } else if ("opinionMining".equals(fieldName)) { + deserializedSentimentAnalysisTaskParameters.opinionMining + = reader.getNullable(JsonReader::getBoolean); + } else if ("stringIndexType".equals(fieldName)) { + deserializedSentimentAnalysisTaskParameters.stringIndexType + = StringIndexType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedSentimentAnalysisTaskParameters; - }); + return deserializedSentimentAnalysisTaskParameters; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentConfidenceScorePerLabel.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentConfidenceScorePerLabel.java index bbd467fd2625..91680a3d7b8b 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentConfidenceScorePerLabel.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentConfidenceScorePerLabel.java @@ -11,7 +11,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** Represents the confidence scores between 0 and 1 across all sentiment classes: positive, neutral, negative. */ +/** + * Represents the confidence scores between 0 and 1 across all sentiment classes: positive, neutral, negative. + */ @Fluent public final class SentimentConfidenceScorePerLabel implements JsonSerializable { /* @@ -29,12 +31,15 @@ public final class SentimentConfidenceScorePerLabel implements JsonSerializable< */ private double negative; - /** Creates an instance of SentimentConfidenceScorePerLabel class. */ - public SentimentConfidenceScorePerLabel() {} + /** + * Creates an instance of SentimentConfidenceScorePerLabel class. + */ + public SentimentConfidenceScorePerLabel() { + } /** * Get the positive property: Confidence score for positive sentiment. - * + * * @return the positive value. */ public double getPositive() { @@ -43,7 +48,7 @@ public double getPositive() { /** * Set the positive property: Confidence score for positive sentiment. - * + * * @param positive the positive value to set. * @return the SentimentConfidenceScorePerLabel object itself. */ @@ -54,7 +59,7 @@ public SentimentConfidenceScorePerLabel setPositive(double positive) { /** * Get the neutral property: Confidence score for neutral sentiment. - * + * * @return the neutral value. */ public double getNeutral() { @@ -63,7 +68,7 @@ public double getNeutral() { /** * Set the neutral property: Confidence score for neutral sentiment. - * + * * @param neutral the neutral value to set. * @return the SentimentConfidenceScorePerLabel object itself. */ @@ -74,7 +79,7 @@ public SentimentConfidenceScorePerLabel setNeutral(double neutral) { /** * Get the negative property: Confidence score for negative sentiment. - * + * * @return the negative value. */ public double getNegative() { @@ -83,7 +88,7 @@ public double getNegative() { /** * Set the negative property: Confidence score for negative sentiment. - * + * * @param negative the negative value to set. * @return the SentimentConfidenceScorePerLabel object itself. */ @@ -92,6 +97,9 @@ public SentimentConfidenceScorePerLabel setNegative(double negative) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -103,34 +111,33 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of SentimentConfidenceScorePerLabel from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of SentimentConfidenceScorePerLabel if the JsonReader was pointing to an instance of it, or - * null if it was pointing to JSON null. + * 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 SentimentConfidenceScorePerLabel. */ public static SentimentConfidenceScorePerLabel fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - SentimentConfidenceScorePerLabel deserializedSentimentConfidenceScorePerLabel = - new SentimentConfidenceScorePerLabel(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("positive".equals(fieldName)) { - deserializedSentimentConfidenceScorePerLabel.positive = reader.getDouble(); - } else if ("neutral".equals(fieldName)) { - deserializedSentimentConfidenceScorePerLabel.neutral = reader.getDouble(); - } else if ("negative".equals(fieldName)) { - deserializedSentimentConfidenceScorePerLabel.negative = reader.getDouble(); - } else { - reader.skipChildren(); - } - } - - return deserializedSentimentConfidenceScorePerLabel; - }); + return jsonReader.readObject(reader -> { + SentimentConfidenceScorePerLabel deserializedSentimentConfidenceScorePerLabel + = new SentimentConfidenceScorePerLabel(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("positive".equals(fieldName)) { + deserializedSentimentConfidenceScorePerLabel.positive = reader.getDouble(); + } else if ("neutral".equals(fieldName)) { + deserializedSentimentConfidenceScorePerLabel.neutral = reader.getDouble(); + } else if ("negative".equals(fieldName)) { + deserializedSentimentConfidenceScorePerLabel.negative = reader.getDouble(); + } else { + reader.skipChildren(); + } + } + + return deserializedSentimentConfidenceScorePerLabel; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentDocumentResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentDocumentResult.java index 93f86b2a6fcb..227c23dbeb19 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentDocumentResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentDocumentResult.java @@ -10,9 +10,10 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.util.List; -import java.util.Objects; -/** The SentimentDocumentResult model. */ +/** + * The SentimentDocumentResult model. + */ @Fluent public class SentimentDocumentResult extends DocumentResult { /* @@ -30,12 +31,15 @@ public class SentimentDocumentResult extends DocumentResult { */ private List sentences; - /** Creates an instance of SentimentDocumentResult class. */ - public SentimentDocumentResult() {} + /** + * Creates an instance of SentimentDocumentResult class. + */ + public SentimentDocumentResult() { + } /** * Get the sentiment property: Predicted sentiment for document (Negative, Neutral, Positive, or Mixed). - * + * * @return the sentiment value. */ public DocumentSentimentValue getSentiment() { @@ -44,7 +48,7 @@ public DocumentSentimentValue getSentiment() { /** * Set the sentiment property: Predicted sentiment for document (Negative, Neutral, Positive, or Mixed). - * + * * @param sentiment the sentiment value to set. * @return the SentimentDocumentResult object itself. */ @@ -56,7 +60,7 @@ public SentimentDocumentResult setSentiment(DocumentSentimentValue sentiment) { /** * Get the confidenceScores property: Document level sentiment confidence scores between 0 and 1 for each sentiment * class. - * + * * @return the confidenceScores value. */ public SentimentConfidenceScorePerLabel getConfidenceScores() { @@ -66,7 +70,7 @@ public SentimentConfidenceScorePerLabel getConfidenceScores() { /** * Set the confidenceScores property: Document level sentiment confidence scores between 0 and 1 for each sentiment * class. - * + * * @param confidenceScores the confidenceScores value to set. * @return the SentimentDocumentResult object itself. */ @@ -77,7 +81,7 @@ public SentimentDocumentResult setConfidenceScores(SentimentConfidenceScorePerLa /** * Get the sentences property: Sentence level sentiment analysis. - * + * * @return the sentences value. */ public List getSentences() { @@ -86,7 +90,7 @@ public List getSentences() { /** * Set the sentences property: Sentence level sentiment analysis. - * + * * @param sentences the sentences value to set. * @return the SentimentDocumentResult object itself. */ @@ -95,34 +99,43 @@ public SentimentDocumentResult setSentences(List sentences) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public SentimentDocumentResult setId(String id) { super.setId(id); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public SentimentDocumentResult setWarnings(List warnings) { super.setWarnings(warnings); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public SentimentDocumentResult setStatistics(DocumentStatistics statistics) { super.setStatistics(statistics); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); jsonWriter.writeStringField("id", getId()); jsonWriter.writeArrayField("warnings", getWarnings(), (writer, element) -> writer.writeJson(element)); jsonWriter.writeJsonField("statistics", getStatistics()); - jsonWriter.writeStringField("sentiment", Objects.toString(this.sentiment, null)); + jsonWriter.writeStringField("sentiment", this.sentiment == null ? null : this.sentiment.toString()); jsonWriter.writeJsonField("confidenceScores", this.confidenceScores); jsonWriter.writeArrayField("sentences", this.sentences, (writer, element) -> writer.writeJson(element)); return jsonWriter.writeEndObject(); @@ -130,45 +143,43 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of SentimentDocumentResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of SentimentDocumentResult if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. + * 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 SentimentDocumentResult. */ public static SentimentDocumentResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - SentimentDocumentResult deserializedSentimentDocumentResult = new SentimentDocumentResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - deserializedSentimentDocumentResult.setId(reader.getString()); - } else if ("warnings".equals(fieldName)) { - List warnings = - reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); - deserializedSentimentDocumentResult.setWarnings(warnings); - } else if ("statistics".equals(fieldName)) { - deserializedSentimentDocumentResult.setStatistics(DocumentStatistics.fromJson(reader)); - } else if ("sentiment".equals(fieldName)) { - deserializedSentimentDocumentResult.sentiment = - DocumentSentimentValue.fromString(reader.getString()); - } else if ("confidenceScores".equals(fieldName)) { - deserializedSentimentDocumentResult.confidenceScores = - SentimentConfidenceScorePerLabel.fromJson(reader); - } else if ("sentences".equals(fieldName)) { - List sentences = - reader.readArray(reader1 -> SentenceSentiment.fromJson(reader1)); - deserializedSentimentDocumentResult.sentences = sentences; - } else { - reader.skipChildren(); - } - } - - return deserializedSentimentDocumentResult; - }); + return jsonReader.readObject(reader -> { + SentimentDocumentResult deserializedSentimentDocumentResult = new SentimentDocumentResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedSentimentDocumentResult.setId(reader.getString()); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedSentimentDocumentResult.setWarnings(warnings); + } else if ("statistics".equals(fieldName)) { + deserializedSentimentDocumentResult.setStatistics(DocumentStatistics.fromJson(reader)); + } else if ("sentiment".equals(fieldName)) { + deserializedSentimentDocumentResult.sentiment + = DocumentSentimentValue.fromString(reader.getString()); + } else if ("confidenceScores".equals(fieldName)) { + deserializedSentimentDocumentResult.confidenceScores + = SentimentConfidenceScorePerLabel.fromJson(reader); + } else if ("sentences".equals(fieldName)) { + List sentences + = reader.readArray(reader1 -> SentenceSentiment.fromJson(reader1)); + deserializedSentimentDocumentResult.sentences = sentences; + } else { + reader.skipChildren(); + } + } + + return deserializedSentimentDocumentResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentLROResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentLROResult.java index 3a579ae33760..324b4f0724d1 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentLROResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentLROResult.java @@ -10,22 +10,42 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.time.OffsetDateTime; -import java.util.Objects; +import java.time.format.DateTimeFormatter; -/** The SentimentLROResult model. */ +/** + * The SentimentLROResult model. + */ @Fluent public final class SentimentLROResult extends AnalyzeTextLROResult { + /* + * Enumeration of supported Text Analysis long-running operation task results. + */ + private AnalyzeTextLROResultsKind kind = AnalyzeTextLROResultsKind.SENTIMENT_ANALYSIS_LRORESULTS; + /* * The results property. */ private SentimentResponse results; - /** Creates an instance of SentimentLROResult class. */ - public SentimentLROResult() {} + /** + * Creates an instance of SentimentLROResult class. + */ + public SentimentLROResult() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis long-running operation task results. + * + * @return the kind value. + */ + @Override + public AnalyzeTextLROResultsKind getKind() { + return this.kind; + } /** * Get the results property: The results property. - * + * * @return the results value. */ public SentimentResponse getResults() { @@ -34,7 +54,7 @@ public SentimentResponse getResults() { /** * Set the results property: The results property. - * + * * @param results the results value to set. * @return the SentimentLROResult object itself. */ @@ -43,81 +63,83 @@ public SentimentLROResult setResults(SentimentResponse results) { return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public SentimentLROResult setTaskName(String taskName) { super.setTaskName(taskName); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public SentimentLROResult setLastUpdateDateTime(OffsetDateTime lastUpdateDateTime) { super.setLastUpdateDateTime(lastUpdateDateTime); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public SentimentLROResult setStatus(State status) { super.setStatus(status); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField( - "kind", Objects.toString(AnalyzeTextLROResultsKind.SENTIMENT_ANALYSIS_LRORESULTS, null)); - jsonWriter.writeStringField("lastUpdateDateTime", Objects.toString(getLastUpdateDateTime(), null)); - jsonWriter.writeStringField("status", Objects.toString(getStatus(), null)); + jsonWriter.writeStringField("lastUpdateDateTime", + getLastUpdateDateTime() == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(getLastUpdateDateTime())); + jsonWriter.writeStringField("status", getStatus() == null ? null : getStatus().toString()); jsonWriter.writeStringField("taskName", getTaskName()); jsonWriter.writeJsonField("results", this.results); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of SentimentLROResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of SentimentLROResult 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 or the - * polymorphic discriminator. + * 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 SentimentLROResult. */ public static SentimentLROResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - SentimentLROResult deserializedSentimentLROResult = new SentimentLROResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + SentimentLROResult deserializedSentimentLROResult = new SentimentLROResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"SentimentAnalysisLROResults".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'SentimentAnalysisLROResults'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("lastUpdateDateTime".equals(fieldName)) { - deserializedSentimentLROResult.setLastUpdateDateTime( - reader.getNullable( - nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); - } else if ("status".equals(fieldName)) { - deserializedSentimentLROResult.setStatus(State.fromString(reader.getString())); - } else if ("taskName".equals(fieldName)) { - deserializedSentimentLROResult.setTaskName(reader.getString()); - } else if ("results".equals(fieldName)) { - deserializedSentimentLROResult.results = SentimentResponse.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("lastUpdateDateTime".equals(fieldName)) { + deserializedSentimentLROResult.setLastUpdateDateTime( + reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); + } else if ("status".equals(fieldName)) { + deserializedSentimentLROResult.setStatus(State.fromString(reader.getString())); + } else if ("taskName".equals(fieldName)) { + deserializedSentimentLROResult.setTaskName(reader.getString()); + } else if ("results".equals(fieldName)) { + deserializedSentimentLROResult.results = SentimentResponse.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedSentimentLROResult.kind = AnalyzeTextLROResultsKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedSentimentLROResult; - }); + return deserializedSentimentLROResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentResponse.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentResponse.java index 5c95fce9252e..6e147745cd51 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentResponse.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentResponse.java @@ -11,7 +11,9 @@ import java.io.IOException; import java.util.List; -/** The SentimentResponse model. */ +/** + * The SentimentResponse model. + */ @Fluent public final class SentimentResponse extends PreBuiltResult { /* @@ -19,12 +21,15 @@ public final class SentimentResponse extends PreBuiltResult { */ private List documents; - /** Creates an instance of SentimentResponse class. */ - public SentimentResponse() {} + /** + * Creates an instance of SentimentResponse class. + */ + public SentimentResponse() { + } /** * Get the documents property: Sentiment analysis per document. - * + * * @return the documents value. */ public List getDocuments() { @@ -33,7 +38,7 @@ public List getDocuments() { /** * Set the documents property: Sentiment analysis per document. - * + * * @param documents the documents value to set. * @return the SentimentResponse object itself. */ @@ -42,27 +47,36 @@ public SentimentResponse setDocuments(List docum return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public SentimentResponse setErrors(List errors) { super.setErrors(errors); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public SentimentResponse setStatistics(RequestStatistics statistics) { super.setStatistics(statistics); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public SentimentResponse setModelVersion(String modelVersion) { super.setModelVersion(modelVersion); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -75,38 +89,37 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of SentimentResponse from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of SentimentResponse if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 SentimentResponse. */ public static SentimentResponse fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - SentimentResponse deserializedSentimentResponse = new SentimentResponse(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + SentimentResponse deserializedSentimentResponse = new SentimentResponse(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("errors".equals(fieldName)) { - List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); - deserializedSentimentResponse.setErrors(errors); - } else if ("modelVersion".equals(fieldName)) { - deserializedSentimentResponse.setModelVersion(reader.getString()); - } else if ("statistics".equals(fieldName)) { - deserializedSentimentResponse.setStatistics(RequestStatistics.fromJson(reader)); - } else if ("documents".equals(fieldName)) { - List documents = - reader.readArray(reader1 -> SentimentResponseDocumentsItem.fromJson(reader1)); - deserializedSentimentResponse.documents = documents; - } else { - reader.skipChildren(); - } - } + if ("errors".equals(fieldName)) { + List errors = reader.readArray(reader1 -> DocumentError.fromJson(reader1)); + deserializedSentimentResponse.setErrors(errors); + } else if ("modelVersion".equals(fieldName)) { + deserializedSentimentResponse.setModelVersion(reader.getString()); + } else if ("statistics".equals(fieldName)) { + deserializedSentimentResponse.setStatistics(RequestStatistics.fromJson(reader)); + } else if ("documents".equals(fieldName)) { + List documents + = reader.readArray(reader1 -> SentimentResponseDocumentsItem.fromJson(reader1)); + deserializedSentimentResponse.documents = documents; + } else { + reader.skipChildren(); + } + } - return deserializedSentimentResponse; - }); + return deserializedSentimentResponse; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentResponseDocumentsItem.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentResponseDocumentsItem.java index 0a8762693abc..17fd0ec98a92 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentResponseDocumentsItem.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentResponseDocumentsItem.java @@ -10,62 +10,81 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.util.List; -import java.util.Objects; -/** The SentimentResponseDocumentsItem model. */ +/** + * The SentimentResponseDocumentsItem model. + */ @Fluent public final class SentimentResponseDocumentsItem extends SentimentDocumentResult { - /** Creates an instance of SentimentResponseDocumentsItem class. */ - public SentimentResponseDocumentsItem() {} + /** + * Creates an instance of SentimentResponseDocumentsItem class. + */ + public SentimentResponseDocumentsItem() { + } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public SentimentResponseDocumentsItem setSentiment(DocumentSentimentValue sentiment) { super.setSentiment(sentiment); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public SentimentResponseDocumentsItem setConfidenceScores(SentimentConfidenceScorePerLabel confidenceScores) { super.setConfidenceScores(confidenceScores); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public SentimentResponseDocumentsItem setSentences(List sentences) { super.setSentences(sentences); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public SentimentResponseDocumentsItem setId(String id) { super.setId(id); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public SentimentResponseDocumentsItem setWarnings(List warnings) { super.setWarnings(warnings); return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public SentimentResponseDocumentsItem setStatistics(DocumentStatistics statistics) { super.setStatistics(statistics); return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); jsonWriter.writeStringField("id", getId()); jsonWriter.writeArrayField("warnings", getWarnings(), (writer, element) -> writer.writeJson(element)); - jsonWriter.writeStringField("sentiment", Objects.toString(getSentiment(), null)); + jsonWriter.writeStringField("sentiment", getSentiment() == null ? null : getSentiment().toString()); jsonWriter.writeJsonField("confidenceScores", getConfidenceScores()); jsonWriter.writeArrayField("sentences", getSentences(), (writer, element) -> writer.writeJson(element)); jsonWriter.writeJsonField("statistics", getStatistics()); @@ -74,47 +93,44 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of SentimentResponseDocumentsItem from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of SentimentResponseDocumentsItem if the JsonReader was pointing to an instance of it, or - * null if it was pointing to JSON null. + * 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 SentimentResponseDocumentsItem. */ public static SentimentResponseDocumentsItem fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - SentimentResponseDocumentsItem deserializedSentimentResponseDocumentsItem = - new SentimentResponseDocumentsItem(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + SentimentResponseDocumentsItem deserializedSentimentResponseDocumentsItem + = new SentimentResponseDocumentsItem(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("id".equals(fieldName)) { - deserializedSentimentResponseDocumentsItem.setId(reader.getString()); - } else if ("warnings".equals(fieldName)) { - List warnings = - reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); - deserializedSentimentResponseDocumentsItem.setWarnings(warnings); - } else if ("sentiment".equals(fieldName)) { - deserializedSentimentResponseDocumentsItem.setSentiment( - DocumentSentimentValue.fromString(reader.getString())); - } else if ("confidenceScores".equals(fieldName)) { - deserializedSentimentResponseDocumentsItem.setConfidenceScores( - SentimentConfidenceScorePerLabel.fromJson(reader)); - } else if ("sentences".equals(fieldName)) { - List sentences = - reader.readArray(reader1 -> SentenceSentiment.fromJson(reader1)); - deserializedSentimentResponseDocumentsItem.setSentences(sentences); - } else if ("statistics".equals(fieldName)) { - deserializedSentimentResponseDocumentsItem.setStatistics( - DocumentStatistics.fromJson(reader)); - } else { - reader.skipChildren(); - } - } + if ("id".equals(fieldName)) { + deserializedSentimentResponseDocumentsItem.setId(reader.getString()); + } else if ("warnings".equals(fieldName)) { + List warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + deserializedSentimentResponseDocumentsItem.setWarnings(warnings); + } else if ("sentiment".equals(fieldName)) { + deserializedSentimentResponseDocumentsItem + .setSentiment(DocumentSentimentValue.fromString(reader.getString())); + } else if ("confidenceScores".equals(fieldName)) { + deserializedSentimentResponseDocumentsItem + .setConfidenceScores(SentimentConfidenceScorePerLabel.fromJson(reader)); + } else if ("sentences".equals(fieldName)) { + List sentences + = reader.readArray(reader1 -> SentenceSentiment.fromJson(reader1)); + deserializedSentimentResponseDocumentsItem.setSentences(sentences); + } else if ("statistics".equals(fieldName)) { + deserializedSentimentResponseDocumentsItem.setStatistics(DocumentStatistics.fromJson(reader)); + } else { + reader.skipChildren(); + } + } - return deserializedSentimentResponseDocumentsItem; - }); + return deserializedSentimentResponseDocumentsItem; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentTaskResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentTaskResult.java index 9ce34fda951b..12be9c1c6e0a 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentTaskResult.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SentimentTaskResult.java @@ -9,22 +9,41 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** The SentimentTaskResult model. */ +/** + * The SentimentTaskResult model. + */ @Fluent public final class SentimentTaskResult extends AnalyzeTextTaskResult { + /* + * Enumeration of supported Text Analysis task results. + */ + private AnalyzeTextTaskResultsKind kind = AnalyzeTextTaskResultsKind.SENTIMENT_ANALYSIS_RESULTS; + /* * The results property. */ private SentimentResponse results; - /** Creates an instance of SentimentTaskResult class. */ - public SentimentTaskResult() {} + /** + * Creates an instance of SentimentTaskResult class. + */ + public SentimentTaskResult() { + } + + /** + * Get the kind property: Enumeration of supported Text Analysis task results. + * + * @return the kind value. + */ + @Override + public AnalyzeTextTaskResultsKind getKind() { + return this.kind; + } /** * Get the results property: The results property. - * + * * @return the results value. */ public SentimentResponse getResults() { @@ -33,7 +52,7 @@ public SentimentResponse getResults() { /** * Set the results property: The results property. - * + * * @param results the results value to set. * @return the SentimentTaskResult object itself. */ @@ -42,49 +61,43 @@ public SentimentTaskResult setResults(SentimentResponse results) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField( - "kind", Objects.toString(AnalyzeTextTaskResultsKind.SENTIMENT_ANALYSIS_RESULTS, null)); jsonWriter.writeJsonField("results", this.results); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of SentimentTaskResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of SentimentTaskResult 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 or the - * polymorphic discriminator. + * 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 SentimentTaskResult. */ public static SentimentTaskResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - SentimentTaskResult deserializedSentimentTaskResult = new SentimentTaskResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + SentimentTaskResult deserializedSentimentTaskResult = new SentimentTaskResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("kind".equals(fieldName)) { - String kind = reader.getString(); - if (!"SentimentAnalysisResults".equals(kind)) { - throw new IllegalStateException( - "'kind' was expected to be non-null and equal to 'SentimentAnalysisResults'. The found 'kind' was '" - + kind - + "'."); - } - } else if ("results".equals(fieldName)) { - deserializedSentimentTaskResult.results = SentimentResponse.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("results".equals(fieldName)) { + deserializedSentimentTaskResult.results = SentimentResponse.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedSentimentTaskResult.kind = AnalyzeTextTaskResultsKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedSentimentTaskResult; - }); + return deserializedSentimentTaskResult; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SingleClassificationDocument.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SingleClassificationDocument.java index 5c0dfd85d87d..8079bf65919e 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SingleClassificationDocument.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SingleClassificationDocument.java @@ -1,39 +1,39 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 SingleClassificationDocument model. */ @Fluent -public final class SingleClassificationDocument { +public final class SingleClassificationDocument implements JsonSerializable { /* * Unique, non-empty document identifier. */ - @JsonProperty(value = "id", required = true) private String id; /* * The classification property. */ - @JsonProperty(value = "classification", required = true) private ClassificationResult classification; /* * Warnings encountered while processing document. */ - @JsonProperty(value = "warnings", required = true) private List warnings; /* * if showStats=true was specified in the request this field will contain * information about the document payload. */ - @JsonProperty(value = "statistics") private DocumentStatistics statistics; /** @@ -117,4 +117,49 @@ public SingleClassificationDocument setStatistics(DocumentStatistics statistics) this.statistics = statistics; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeJsonField("classification", this.classification); + jsonWriter.writeArrayField("warnings", this.warnings, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("statistics", this.statistics); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SingleClassificationDocument from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SingleClassificationDocument 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 SingleClassificationDocument. + */ + public static SingleClassificationDocument fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SingleClassificationDocument deserializedSingleClassificationDocument = new SingleClassificationDocument(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedSingleClassificationDocument.id = reader.getString(); + } else if ("classification".equals(fieldName)) { + deserializedSingleClassificationDocument.classification = ClassificationResult.fromJson(reader); + } else if ("warnings".equals(fieldName)) { + deserializedSingleClassificationDocument.warnings = reader.readArray(reader1 -> DocumentWarning.fromJson(reader1)); + } else if ("statistics".equals(fieldName)) { + deserializedSingleClassificationDocument.statistics = DocumentStatistics.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return deserializedSingleClassificationDocument; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SingleClassificationDocumentResult.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SingleClassificationDocumentResult.java deleted file mode 100644 index 0ea9abd7cf7a..000000000000 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SingleClassificationDocumentResult.java +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.ai.textanalytics.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -/** The SingleClassificationDocumentResult model. */ -@Fluent -public class SingleClassificationDocumentResult extends DocumentResult { - /* - * The class property. - */ - @JsonProperty(value = "class", required = true) - private ClassificationResult classProperty; - - /** - * Get the classProperty property: The class property. - * - * @return the classProperty value. - */ - public ClassificationResult getClassProperty() { - return this.classProperty; - } - - /** - * Set the classProperty property: The class property. - * - * @param classProperty the classProperty value to set. - * @return the SingleClassificationDocumentResult object itself. - */ - public SingleClassificationDocumentResult setClassProperty(ClassificationResult classProperty) { - this.classProperty = classProperty; - return this; - } - - /** {@inheritDoc} */ - @Override - public SingleClassificationDocumentResult setId(String id) { - super.setId(id); - return this; - } - - /** {@inheritDoc} */ - @Override - public SingleClassificationDocumentResult setWarnings(List warnings) { - super.setWarnings(warnings); - return this; - } - - /** {@inheritDoc} */ - @Override - public SingleClassificationDocumentResult setStatistics(DocumentStatistics statistics) { - super.setStatistics(statistics); - return this; - } -} diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/State.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/State.java index 051fd43128cf..371a9ae67a7f 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/State.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/State.java @@ -7,40 +7,57 @@ import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; -/** Defines values for State. */ +/** + * Defines values for State. + */ public final class State extends ExpandableStringEnum { - /** Static value notStarted for State. */ + /** + * Static value notStarted for State. + */ public static final State NOT_STARTED = fromString("notStarted"); - /** Static value running for State. */ + /** + * Static value running for State. + */ public static final State RUNNING = fromString("running"); - /** Static value succeeded for State. */ + /** + * Static value succeeded for State. + */ public static final State SUCCEEDED = fromString("succeeded"); - /** Static value failed for State. */ + /** + * Static value failed for State. + */ public static final State FAILED = fromString("failed"); - /** Static value cancelled for State. */ + /** + * Static value cancelled for State. + */ public static final State CANCELLED = fromString("cancelled"); - /** Static value cancelling for State. */ + /** + * Static value cancelling for State. + */ public static final State CANCELLING = fromString("cancelling"); - /** Static value partiallyCompleted for State. */ + /** + * Static value partiallyCompleted for State. + */ public static final State PARTIALLY_COMPLETED = fromString("partiallyCompleted"); /** * Creates a new instance of State value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated - public State() {} + public State() { + } /** * Creates or finds a State from its string representation. - * + * * @param name a name to look for. * @return the corresponding State. */ @@ -50,7 +67,7 @@ public static State fromString(String name) { /** * Gets known State values. - * + * * @return known State values. */ public static Collection values() { diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/StringIndexType.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/StringIndexType.java index e03b158af0e1..be6ea46a42e1 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/StringIndexType.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/StringIndexType.java @@ -33,15 +33,16 @@ public final class StringIndexType extends ExpandableStringEnum /** * Creates a new instance of StringIndexType value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated - public StringIndexType() {} + public StringIndexType() { + } /** * Creates or finds a StringIndexType from its string representation. - * + * * @param name a name to look for. * @return the corresponding StringIndexType. */ @@ -51,7 +52,7 @@ public static StringIndexType fromString(String name) { /** * Gets known StringIndexType values. - * + * * @return known StringIndexType values. */ public static Collection values() { diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/StringIndexTypeResponse.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/StringIndexTypeResponse.java deleted file mode 100644 index 331b3fc97951..000000000000 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/StringIndexTypeResponse.java +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.ai.textanalytics.implementation.models; - -import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; -import java.util.Collection; - -/** Defines values for StringIndexTypeResponse. */ -public final class StringIndexTypeResponse extends ExpandableStringEnum { - /** Static value TextElements_v8 for StringIndexTypeResponse. */ - public static final StringIndexTypeResponse TEXT_ELEMENTS_V8 = fromString("TextElements_v8"); - - /** Static value UnicodeCodePoint for StringIndexTypeResponse. */ - public static final StringIndexTypeResponse UNICODE_CODE_POINT = fromString("UnicodeCodePoint"); - - /** Static value Utf16CodeUnit for StringIndexTypeResponse. */ - public static final StringIndexTypeResponse UTF16CODE_UNIT = fromString("Utf16CodeUnit"); - - /** - * Creates or finds a StringIndexTypeResponse from its string representation. - * - * @param name a name to look for. - * @return the corresponding StringIndexTypeResponse. - */ - @JsonCreator - public static StringIndexTypeResponse fromString(String name) { - return fromString(name, StringIndexTypeResponse.class); - } - - /** @return known StringIndexTypeResponse values. */ - public static Collection values() { - return values(StringIndexTypeResponse.class); - } -} diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SummaryContext.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SummaryContext.java index a563a5991285..1375927702d3 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SummaryContext.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/SummaryContext.java @@ -11,7 +11,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** The context of the summary. */ +/** + * The context of the summary. + */ @Fluent public final class SummaryContext implements JsonSerializable { /* @@ -24,13 +26,16 @@ public final class SummaryContext implements JsonSerializable { */ private int length; - /** Creates an instance of SummaryContext class. */ - public SummaryContext() {} + /** + * Creates an instance of SummaryContext class. + */ + public SummaryContext() { + } /** * Get the offset property: Start position for the context. Use of different 'stringIndexType' values can affect the * offset returned. - * + * * @return the offset value. */ public int getOffset() { @@ -40,7 +45,7 @@ public int getOffset() { /** * Set the offset property: Start position for the context. Use of different 'stringIndexType' values can affect the * offset returned. - * + * * @param offset the offset value to set. * @return the SummaryContext object itself. */ @@ -52,7 +57,7 @@ public SummaryContext setOffset(int offset) { /** * Get the length property: The length of the context. Use of different 'stringIndexType' values can affect the * length returned. - * + * * @return the length value. */ public int getLength() { @@ -62,7 +67,7 @@ public int getLength() { /** * Set the length property: The length of the context. Use of different 'stringIndexType' values can affect the * length returned. - * + * * @param length the length value to set. * @return the SummaryContext object itself. */ @@ -71,6 +76,9 @@ public SummaryContext setLength(int length) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -81,31 +89,30 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of SummaryContext from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of SummaryContext if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 SummaryContext. */ public static SummaryContext fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - SummaryContext deserializedSummaryContext = new SummaryContext(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + SummaryContext deserializedSummaryContext = new SummaryContext(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("offset".equals(fieldName)) { - deserializedSummaryContext.offset = reader.getInt(); - } else if ("length".equals(fieldName)) { - deserializedSummaryContext.length = reader.getInt(); - } else { - reader.skipChildren(); - } - } + if ("offset".equals(fieldName)) { + deserializedSummaryContext.offset = reader.getInt(); + } else if ("length".equals(fieldName)) { + deserializedSummaryContext.length = reader.getInt(); + } else { + reader.skipChildren(); + } + } - return deserializedSummaryContext; - }); + return deserializedSummaryContext; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TargetConfidenceScoreLabel.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TargetConfidenceScoreLabel.java index 46a40d4ae0ad..6d3330d075a6 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TargetConfidenceScoreLabel.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TargetConfidenceScoreLabel.java @@ -11,7 +11,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** Represents the confidence scores across all sentiment classes: positive and negative. */ +/** + * Represents the confidence scores across all sentiment classes: positive and negative. + */ @Fluent public final class TargetConfidenceScoreLabel implements JsonSerializable { /* @@ -24,12 +26,15 @@ public final class TargetConfidenceScoreLabel implements JsonSerializable { - TargetConfidenceScoreLabel deserializedTargetConfidenceScoreLabel = - new TargetConfidenceScoreLabel(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + TargetConfidenceScoreLabel deserializedTargetConfidenceScoreLabel = new TargetConfidenceScoreLabel(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("positive".equals(fieldName)) { - deserializedTargetConfidenceScoreLabel.positive = reader.getDouble(); - } else if ("negative".equals(fieldName)) { - deserializedTargetConfidenceScoreLabel.negative = reader.getDouble(); - } else { - reader.skipChildren(); - } - } + if ("positive".equals(fieldName)) { + deserializedTargetConfidenceScoreLabel.positive = reader.getDouble(); + } else if ("negative".equals(fieldName)) { + deserializedTargetConfidenceScoreLabel.negative = reader.getDouble(); + } else { + reader.skipChildren(); + } + } - return deserializedTargetConfidenceScoreLabel; - }); + return deserializedTargetConfidenceScoreLabel; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TargetRelation.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TargetRelation.java index 3de5eb8be749..be24263ce6b3 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TargetRelation.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TargetRelation.java @@ -10,9 +10,10 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; -import java.util.Objects; -/** The TargetRelation model. */ +/** + * The TargetRelation model. + */ @Fluent public final class TargetRelation implements JsonSerializable { /* @@ -25,12 +26,15 @@ public final class TargetRelation implements JsonSerializable { */ private String ref; - /** Creates an instance of TargetRelation class. */ - public TargetRelation() {} + /** + * Creates an instance of TargetRelation class. + */ + public TargetRelation() { + } /** * Get the relationType property: The type related to the target. - * + * * @return the relationType value. */ public TargetRelationType getRelationType() { @@ -39,7 +43,7 @@ public TargetRelationType getRelationType() { /** * Set the relationType property: The type related to the target. - * + * * @param relationType the relationType value to set. * @return the TargetRelation object itself. */ @@ -50,7 +54,7 @@ public TargetRelation setRelationType(TargetRelationType relationType) { /** * Get the ref property: The JSON pointer indicating the linked object. - * + * * @return the ref value. */ public String getRef() { @@ -59,7 +63,7 @@ public String getRef() { /** * Set the ref property: The JSON pointer indicating the linked object. - * + * * @param ref the ref value to set. * @return the TargetRelation object itself. */ @@ -68,41 +72,43 @@ public TargetRelation setRef(String ref) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("relationType", Objects.toString(this.relationType, null)); + jsonWriter.writeStringField("relationType", this.relationType == null ? null : this.relationType.toString()); jsonWriter.writeStringField("ref", this.ref); return jsonWriter.writeEndObject(); } /** * Reads an instance of TargetRelation from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of TargetRelation if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 TargetRelation. */ public static TargetRelation fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - TargetRelation deserializedTargetRelation = new TargetRelation(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + TargetRelation deserializedTargetRelation = new TargetRelation(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("relationType".equals(fieldName)) { - deserializedTargetRelation.relationType = TargetRelationType.fromString(reader.getString()); - } else if ("ref".equals(fieldName)) { - deserializedTargetRelation.ref = reader.getString(); - } else { - reader.skipChildren(); - } - } + if ("relationType".equals(fieldName)) { + deserializedTargetRelation.relationType = TargetRelationType.fromString(reader.getString()); + } else if ("ref".equals(fieldName)) { + deserializedTargetRelation.ref = reader.getString(); + } else { + reader.skipChildren(); + } + } - return deserializedTargetRelation; - }); + return deserializedTargetRelation; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TargetRelationType.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TargetRelationType.java index f5c919e10615..deb2aa3fc1a1 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TargetRelationType.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TargetRelationType.java @@ -4,15 +4,23 @@ package com.azure.ai.textanalytics.implementation.models; -/** The type related to the target. */ +/** + * The type related to the target. + */ public enum TargetRelationType { - /** Enum value assessment. */ + /** + * Enum value assessment. + */ ASSESSMENT("assessment"), - /** Enum value target. */ + /** + * Enum value target. + */ TARGET("target"); - /** The actual serialized value for a TargetRelationType instance. */ + /** + * The actual serialized value for a TargetRelationType instance. + */ private final String value; TargetRelationType(String value) { @@ -21,7 +29,7 @@ public enum TargetRelationType { /** * Parses a serialized value to a TargetRelationType instance. - * + * * @param value the serialized value to parse. * @return the parsed TargetRelationType object, or null if unable to parse. */ @@ -38,7 +46,9 @@ public static TargetRelationType fromString(String value) { return null; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public String toString() { return this.value; diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TaskIdentifier.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TaskIdentifier.java index 76adf7e67212..e602bd2fd024 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TaskIdentifier.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TaskIdentifier.java @@ -11,7 +11,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** Base task object. */ +/** + * Base task object. + */ @Fluent public class TaskIdentifier implements JsonSerializable { /* @@ -19,12 +21,15 @@ public class TaskIdentifier implements JsonSerializable { */ private String taskName; - /** Creates an instance of TaskIdentifier class. */ - public TaskIdentifier() {} + /** + * Creates an instance of TaskIdentifier class. + */ + public TaskIdentifier() { + } /** * Get the taskName property: The taskName property. - * + * * @return the taskName value. */ public String getTaskName() { @@ -33,7 +38,7 @@ public String getTaskName() { /** * Set the taskName property: The taskName property. - * + * * @param taskName the taskName value to set. * @return the TaskIdentifier object itself. */ @@ -42,6 +47,9 @@ public TaskIdentifier setTaskName(String taskName) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -51,28 +59,27 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of TaskIdentifier from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of TaskIdentifier if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * pointing to JSON null. * @throws IOException If an error occurs while reading the TaskIdentifier. */ public static TaskIdentifier fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - TaskIdentifier deserializedTaskIdentifier = new TaskIdentifier(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + TaskIdentifier deserializedTaskIdentifier = new TaskIdentifier(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("taskName".equals(fieldName)) { - deserializedTaskIdentifier.taskName = reader.getString(); - } else { - reader.skipChildren(); - } - } + if ("taskName".equals(fieldName)) { + deserializedTaskIdentifier.taskName = reader.getString(); + } else { + reader.skipChildren(); + } + } - return deserializedTaskIdentifier; - }); + return deserializedTaskIdentifier; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TaskParameters.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TaskParameters.java index ec246f48bfb0..56674d58c1b4 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TaskParameters.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TaskParameters.java @@ -11,7 +11,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** Base parameters object for a text analysis task. */ +/** + * Base parameters object for a text analysis task. + */ @Fluent public class TaskParameters implements JsonSerializable { /* @@ -19,12 +21,15 @@ public class TaskParameters implements JsonSerializable { */ private Boolean loggingOptOut; - /** Creates an instance of TaskParameters class. */ - public TaskParameters() {} + /** + * Creates an instance of TaskParameters class. + */ + public TaskParameters() { + } /** * Get the loggingOptOut property: The loggingOptOut property. - * + * * @return the loggingOptOut value. */ public Boolean isLoggingOptOut() { @@ -33,7 +38,7 @@ public Boolean isLoggingOptOut() { /** * Set the loggingOptOut property: The loggingOptOut property. - * + * * @param loggingOptOut the loggingOptOut value to set. * @return the TaskParameters object itself. */ @@ -42,6 +47,9 @@ public TaskParameters setLoggingOptOut(Boolean loggingOptOut) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -51,28 +59,27 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of TaskParameters from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of TaskParameters if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * pointing to JSON null. * @throws IOException If an error occurs while reading the TaskParameters. */ public static TaskParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - TaskParameters deserializedTaskParameters = new TaskParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + TaskParameters deserializedTaskParameters = new TaskParameters(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("loggingOptOut".equals(fieldName)) { - deserializedTaskParameters.loggingOptOut = reader.getNullable(JsonReader::getBoolean); - } else { - reader.skipChildren(); - } - } + if ("loggingOptOut".equals(fieldName)) { + deserializedTaskParameters.loggingOptOut = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } - return deserializedTaskParameters; - }); + return deserializedTaskParameters; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TaskState.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TaskState.java index 08bf78d04c0f..d98f7d973557 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TaskState.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TaskState.java @@ -11,9 +11,11 @@ import com.azure.json.JsonWriter; import java.io.IOException; import java.time.OffsetDateTime; -import java.util.Objects; +import java.time.format.DateTimeFormatter; -/** The TaskState model. */ +/** + * The TaskState model. + */ @Fluent public class TaskState implements JsonSerializable { /* @@ -26,12 +28,15 @@ public class TaskState implements JsonSerializable { */ private State status; - /** Creates an instance of TaskState class. */ - public TaskState() {} + /** + * Creates an instance of TaskState class. + */ + public TaskState() { + } /** * Get the lastUpdateDateTime property: The lastUpdateDateTime property. - * + * * @return the lastUpdateDateTime value. */ public OffsetDateTime getLastUpdateDateTime() { @@ -40,7 +45,7 @@ public OffsetDateTime getLastUpdateDateTime() { /** * Set the lastUpdateDateTime property: The lastUpdateDateTime property. - * + * * @param lastUpdateDateTime the lastUpdateDateTime value to set. * @return the TaskState object itself. */ @@ -51,7 +56,7 @@ public TaskState setLastUpdateDateTime(OffsetDateTime lastUpdateDateTime) { /** * Get the status property: The status property. - * + * * @return the status value. */ public State getStatus() { @@ -60,7 +65,7 @@ public State getStatus() { /** * Set the status property: The status property. - * + * * @param status the status value to set. * @return the TaskState object itself. */ @@ -69,43 +74,47 @@ public TaskState setStatus(State status) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("lastUpdateDateTime", Objects.toString(this.lastUpdateDateTime, null)); - jsonWriter.writeStringField("status", Objects.toString(this.status, null)); + jsonWriter.writeStringField("lastUpdateDateTime", + this.lastUpdateDateTime == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.lastUpdateDateTime)); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); return jsonWriter.writeEndObject(); } /** * Reads an instance of TaskState from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of TaskState if the JsonReader was pointing to an instance of it, or null if it was pointing - * to JSON null. + * to JSON null. * @throws IllegalStateException If the deserialized JSON object was missing any required properties. * @throws IOException If an error occurs while reading the TaskState. */ public static TaskState fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - TaskState deserializedTaskState = new TaskState(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + TaskState deserializedTaskState = new TaskState(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("lastUpdateDateTime".equals(fieldName)) { - deserializedTaskState.lastUpdateDateTime = - reader.getNullable( - nonNullReader -> OffsetDateTime.parse(nonNullReader.getString())); - } else if ("status".equals(fieldName)) { - deserializedTaskState.status = State.fromString(reader.getString()); - } else { - reader.skipChildren(); - } - } + if ("lastUpdateDateTime".equals(fieldName)) { + deserializedTaskState.lastUpdateDateTime + = reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString())); + } else if ("status".equals(fieldName)) { + deserializedTaskState.status = State.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } - return deserializedTaskState; - }); + return deserializedTaskState; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksState.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksState.java index c41889b1ab47..74db7e1c6fbd 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksState.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksState.java @@ -11,7 +11,9 @@ import com.azure.json.JsonWriter; import java.io.IOException; -/** The TasksState model. */ +/** + * The TasksState model. + */ @Fluent public class TasksState implements JsonSerializable { /* @@ -19,12 +21,15 @@ public class TasksState implements JsonSerializable { */ private TasksStateTasks tasks; - /** Creates an instance of TasksState class. */ - public TasksState() {} + /** + * Creates an instance of TasksState class. + */ + public TasksState() { + } /** * Get the tasks property: The tasks property. - * + * * @return the tasks value. */ public TasksStateTasks getTasks() { @@ -33,7 +38,7 @@ public TasksStateTasks getTasks() { /** * Set the tasks property: The tasks property. - * + * * @param tasks the tasks value to set. * @return the TasksState object itself. */ @@ -42,6 +47,9 @@ public TasksState setTasks(TasksStateTasks tasks) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -51,29 +59,28 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of TasksState from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of TasksState if the JsonReader was pointing to an instance of it, or null if it was pointing - * to JSON null. + * to JSON null. * @throws IllegalStateException If the deserialized JSON object was missing any required properties. * @throws IOException If an error occurs while reading the TasksState. */ public static TasksState fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - TasksState deserializedTasksState = new TasksState(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); + return jsonReader.readObject(reader -> { + TasksState deserializedTasksState = new TasksState(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("tasks".equals(fieldName)) { - deserializedTasksState.tasks = TasksStateTasks.fromJson(reader); - } else { - reader.skipChildren(); - } - } + if ("tasks".equals(fieldName)) { + deserializedTasksState.tasks = TasksStateTasks.fromJson(reader); + } else { + reader.skipChildren(); + } + } - return deserializedTasksState; - }); + return deserializedTasksState; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasks.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasks.java index aecdafaee7f4..93f1fab89033 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasks.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasks.java @@ -12,7 +12,9 @@ import java.io.IOException; import java.util.List; -/** The TasksStateTasks model. */ +/** + * The TasksStateTasks model. + */ @Fluent public final class TasksStateTasks implements JsonSerializable { /* @@ -40,12 +42,15 @@ public final class TasksStateTasks implements JsonSerializable */ private List items; - /** Creates an instance of TasksStateTasks class. */ - public TasksStateTasks() {} + /** + * Creates an instance of TasksStateTasks class. + */ + public TasksStateTasks() { + } /** * Get the completed property: The completed property. - * + * * @return the completed value. */ public int getCompleted() { @@ -54,7 +59,7 @@ public int getCompleted() { /** * Set the completed property: The completed property. - * + * * @param completed the completed value to set. * @return the TasksStateTasks object itself. */ @@ -65,7 +70,7 @@ public TasksStateTasks setCompleted(int completed) { /** * Get the failed property: The failed property. - * + * * @return the failed value. */ public int getFailed() { @@ -74,7 +79,7 @@ public int getFailed() { /** * Set the failed property: The failed property. - * + * * @param failed the failed value to set. * @return the TasksStateTasks object itself. */ @@ -85,7 +90,7 @@ public TasksStateTasks setFailed(int failed) { /** * Get the inProgress property: The inProgress property. - * + * * @return the inProgress value. */ public int getInProgress() { @@ -94,7 +99,7 @@ public int getInProgress() { /** * Set the inProgress property: The inProgress property. - * + * * @param inProgress the inProgress value to set. * @return the TasksStateTasks object itself. */ @@ -105,7 +110,7 @@ public TasksStateTasks setInProgress(int inProgress) { /** * Get the total property: The total property. - * + * * @return the total value. */ public int getTotal() { @@ -114,7 +119,7 @@ public int getTotal() { /** * Set the total property: The total property. - * + * * @param total the total value to set. * @return the TasksStateTasks object itself. */ @@ -125,7 +130,7 @@ public TasksStateTasks setTotal(int total) { /** * Get the items property: The items property. - * + * * @return the items value. */ public List getItems() { @@ -134,7 +139,7 @@ public List getItems() { /** * Set the items property: The items property. - * + * * @param items the items value to set. * @return the TasksStateTasks object itself. */ @@ -143,6 +148,9 @@ public TasksStateTasks setItems(List items) { return this; } + /** + * {@inheritDoc} + */ @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -156,39 +164,38 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of TasksStateTasks from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of TasksStateTasks if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. + * 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 TasksStateTasks. */ public static TasksStateTasks fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject( - reader -> { - TasksStateTasks deserializedTasksStateTasks = new TasksStateTasks(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("completed".equals(fieldName)) { - deserializedTasksStateTasks.completed = reader.getInt(); - } else if ("failed".equals(fieldName)) { - deserializedTasksStateTasks.failed = reader.getInt(); - } else if ("inProgress".equals(fieldName)) { - deserializedTasksStateTasks.inProgress = reader.getInt(); - } else if ("total".equals(fieldName)) { - deserializedTasksStateTasks.total = reader.getInt(); - } else if ("items".equals(fieldName)) { - List items = - reader.readArray(reader1 -> AnalyzeTextLROResult.fromJson(reader1)); - deserializedTasksStateTasks.items = items; - } else { - reader.skipChildren(); - } - } - - return deserializedTasksStateTasks; - }); + return jsonReader.readObject(reader -> { + TasksStateTasks deserializedTasksStateTasks = new TasksStateTasks(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("completed".equals(fieldName)) { + deserializedTasksStateTasks.completed = reader.getInt(); + } else if ("failed".equals(fieldName)) { + deserializedTasksStateTasks.failed = reader.getInt(); + } else if ("inProgress".equals(fieldName)) { + deserializedTasksStateTasks.inProgress = reader.getInt(); + } else if ("total".equals(fieldName)) { + deserializedTasksStateTasks.total = reader.getInt(); + } else if ("items".equals(fieldName)) { + List items + = reader.readArray(reader1 -> AnalyzeTextLROResult.fromJson(reader1)); + deserializedTasksStateTasks.items = items; + } else { + reader.skipChildren(); + } + } + + return deserializedTasksStateTasks; + }); } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksCustomEntityRecognitionTasksItem.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksCustomEntityRecognitionTasksItem.java index 7ecf3615d53c..54b4dc1dde3e 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksCustomEntityRecognitionTasksItem.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksCustomEntityRecognitionTasksItem.java @@ -1,11 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; + +import java.io.IOException; /** The TasksStateTasksCustomEntityRecognitionTasksItem model. */ @Fluent @@ -13,7 +16,6 @@ public final class TasksStateTasksCustomEntityRecognitionTasksItem extends TaskS /* * The results property. */ - @JsonProperty(value = "results") private CustomEntitiesResult results; /** @@ -35,4 +37,41 @@ public TasksStateTasksCustomEntityRecognitionTasksItem setResults(CustomEntities this.results = results; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("results", results); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TasksStateTasksCustomEntityRecognitionTasksItem from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TasksStateTasksCustomEntityRecognitionTasksItem 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 TasksStateTasksCustomEntityRecognitionTasksItem. + */ + public static TasksStateTasksCustomEntityRecognitionTasksItem fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TasksStateTasksCustomEntityRecognitionTasksItem deserializedTasksStateTasksCustomEntityRecognitionTasksItem = + new TasksStateTasksCustomEntityRecognitionTasksItem(); + + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("results".equals(fieldName)) { + deserializedTasksStateTasksCustomEntityRecognitionTasksItem.results = CustomEntitiesResult.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return deserializedTasksStateTasksCustomEntityRecognitionTasksItem; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksCustomMultiClassificationTasksItem.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksCustomMultiClassificationTasksItem.java index 2114e3867ac7..5e0fa43bfd45 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksCustomMultiClassificationTasksItem.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksCustomMultiClassificationTasksItem.java @@ -1,11 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; + +import java.io.IOException; /** The TasksStateTasksCustomMultiClassificationTasksItem model. */ @Fluent @@ -13,7 +16,6 @@ public final class TasksStateTasksCustomMultiClassificationTasksItem extends Tas /* * The results property. */ - @JsonProperty(value = "results") private CustomMultiClassificationResult results; /** @@ -35,4 +37,41 @@ public TasksStateTasksCustomMultiClassificationTasksItem setResults(CustomMultiC this.results = results; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("results", results); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TasksStateTasksCustomMultiClassificationTasksItem from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TasksStateTasksCustomMultiClassificationTasksItem 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 TasksStateTasksCustomMultiClassificationTasksItem. + */ + public static TasksStateTasksCustomMultiClassificationTasksItem fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TasksStateTasksCustomMultiClassificationTasksItem deserializedTasksStateTasksCustomMultiClassificationTasksItem = + new TasksStateTasksCustomMultiClassificationTasksItem(); + + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("results".equals(fieldName)) { + deserializedTasksStateTasksCustomMultiClassificationTasksItem.results = CustomMultiClassificationResult.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return deserializedTasksStateTasksCustomMultiClassificationTasksItem; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksCustomSingleClassificationTasksItem.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksCustomSingleClassificationTasksItem.java index 3857a3316376..64e462fe89e6 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksCustomSingleClassificationTasksItem.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksCustomSingleClassificationTasksItem.java @@ -1,11 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; + +import java.io.IOException; /** The TasksStateTasksCustomSingleClassificationTasksItem model. */ @Fluent @@ -13,7 +16,6 @@ public final class TasksStateTasksCustomSingleClassificationTasksItem extends Ta /* * The results property. */ - @JsonProperty(value = "results") private CustomSingleClassificationResult results; /** @@ -35,4 +37,41 @@ public TasksStateTasksCustomSingleClassificationTasksItem setResults(CustomSingl this.results = results; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("results", results); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TasksStateTasksCustomSingleClassificationTasksItem from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TasksStateTasksCustomSingleClassificationTasksItem 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 TasksStateTasksCustomSingleClassificationTasksItem. + */ + public static TasksStateTasksCustomSingleClassificationTasksItem fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TasksStateTasksCustomSingleClassificationTasksItem deserializedTasksStateTasksCustomSingleClassificationTasksItem = + new TasksStateTasksCustomSingleClassificationTasksItem(); + + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("results".equals(fieldName)) { + deserializedTasksStateTasksCustomSingleClassificationTasksItem.results = CustomSingleClassificationResult.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return deserializedTasksStateTasksCustomSingleClassificationTasksItem; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksDetails.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksDetails.java deleted file mode 100644 index 39869037787d..000000000000 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksDetails.java +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.ai.textanalytics.implementation.models; - -import com.azure.core.annotation.Immutable; - -/** The TasksStateTasksDetails model. */ -@Immutable -public final class TasksStateTasksDetails extends TaskState { - -} diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksEntityLinkingTasksItem.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksEntityLinkingTasksItem.java index b5ef1b6a69d0..f572faa00a92 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksEntityLinkingTasksItem.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksEntityLinkingTasksItem.java @@ -1,11 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; + +import java.io.IOException; /** The TasksStateTasksEntityLinkingTasksItem model. */ @Fluent @@ -13,7 +16,6 @@ public final class TasksStateTasksEntityLinkingTasksItem extends TaskState { /* * The results property. */ - @JsonProperty(value = "results") private EntityLinkingResult results; /** @@ -35,4 +37,41 @@ public TasksStateTasksEntityLinkingTasksItem setResults(EntityLinkingResult resu this.results = results; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("results", results); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TasksStateTasksEntityLinkingTasksItem from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TasksStateTasksEntityLinkingTasksItem 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 TasksStateTasksEntityLinkingTasksItem. + */ + public static TasksStateTasksEntityLinkingTasksItem fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TasksStateTasksEntityLinkingTasksItem deserializedTasksStateTasksEntityLinkingTasksItem = + new TasksStateTasksEntityLinkingTasksItem(); + + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("results".equals(fieldName)) { + deserializedTasksStateTasksEntityLinkingTasksItem.results = EntityLinkingResult.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return deserializedTasksStateTasksEntityLinkingTasksItem; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksEntityRecognitionPiiTasksItem.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksEntityRecognitionPiiTasksItem.java index 481123422993..744f5de4fe8c 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksEntityRecognitionPiiTasksItem.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksEntityRecognitionPiiTasksItem.java @@ -1,11 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; + +import java.io.IOException; /** The TasksStateTasksEntityRecognitionPiiTasksItem model. */ @Fluent @@ -13,7 +16,6 @@ public final class TasksStateTasksEntityRecognitionPiiTasksItem extends TaskStat /* * The results property. */ - @JsonProperty(value = "results") private PiiResult results; /** @@ -35,4 +37,41 @@ public TasksStateTasksEntityRecognitionPiiTasksItem setResults(PiiResult results this.results = results; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("results", results); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TasksStateTasksEntityRecognitionPiiTasksItem from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TasksStateTasksEntityRecognitionPiiTasksItem 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 TasksStateTasksEntityRecognitionPiiTasksItem. + */ + public static TasksStateTasksEntityRecognitionPiiTasksItem fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TasksStateTasksEntityRecognitionPiiTasksItem deserializedTasksStateTasksEntityRecognitionPiiTasksItem = + new TasksStateTasksEntityRecognitionPiiTasksItem(); + + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("results".equals(fieldName)) { + deserializedTasksStateTasksEntityRecognitionPiiTasksItem.results = PiiResult.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return deserializedTasksStateTasksEntityRecognitionPiiTasksItem; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksEntityRecognitionTasksItem.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksEntityRecognitionTasksItem.java index ab7d2bd3dd7b..8aa71cc1ccaf 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksEntityRecognitionTasksItem.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksEntityRecognitionTasksItem.java @@ -1,19 +1,21 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; + +import java.io.IOException; /** The TasksStateTasksEntityRecognitionTasksItem model. */ @Fluent -public final class TasksStateTasksEntityRecognitionTasksItem extends TaskState { +public class TasksStateTasksEntityRecognitionTasksItem extends TaskState { /* * The results property. */ - @JsonProperty(value = "results") private EntitiesResult results; /** @@ -35,4 +37,41 @@ public TasksStateTasksEntityRecognitionTasksItem setResults(EntitiesResult resul this.results = results; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("results", results); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TasksStateTasksEntityRecognitionTasksItem from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TasksStateTasksEntityRecognitionTasksItem 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 TasksStateTasksEntityRecognitionTasksItem. + */ + public static TasksStateTasksEntityRecognitionTasksItem fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TasksStateTasksEntityRecognitionTasksItem deserializedTasksStateTasksEntityRecognitionTasksItem = + new TasksStateTasksEntityRecognitionTasksItem(); + + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("results".equals(fieldName)) { + deserializedTasksStateTasksEntityRecognitionTasksItem.results = EntitiesResult.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return deserializedTasksStateTasksEntityRecognitionTasksItem; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksKeyPhraseExtractionTasksItem.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksKeyPhraseExtractionTasksItem.java index 00aee7824c5e..f80aeea94aed 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksKeyPhraseExtractionTasksItem.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksKeyPhraseExtractionTasksItem.java @@ -1,11 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; + +import java.io.IOException; /** The TasksStateTasksKeyPhraseExtractionTasksItem model. */ @Fluent @@ -13,7 +16,6 @@ public final class TasksStateTasksKeyPhraseExtractionTasksItem extends TaskState /* * The results property. */ - @JsonProperty(value = "results") private KeyPhraseResult results; /** @@ -35,4 +37,41 @@ public TasksStateTasksKeyPhraseExtractionTasksItem setResults(KeyPhraseResult re this.results = results; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("results", results); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TasksStateTasksKeyPhraseExtractionTasksItem from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TasksStateTasksKeyPhraseExtractionTasksItem 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 TasksStateTasksKeyPhraseExtractionTasksItem. + */ + public static TasksStateTasksKeyPhraseExtractionTasksItem fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TasksStateTasksKeyPhraseExtractionTasksItem deserializedTasksStateTasksKeyPhraseExtractionTasksItem = + new TasksStateTasksKeyPhraseExtractionTasksItem(); + + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("results".equals(fieldName)) { + deserializedTasksStateTasksKeyPhraseExtractionTasksItem.results = KeyPhraseResult.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return deserializedTasksStateTasksKeyPhraseExtractionTasksItem; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksOld.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksOld.java index 197af3deffae..39d2abbeb9a1 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksOld.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksOld.java @@ -1,86 +1,78 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -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 TasksStateTasksOld model. */ @Fluent -public final class TasksStateTasksOld { +public final class TasksStateTasksOld implements JsonSerializable { /* * The completed property. */ - @JsonProperty(value = "completed", required = true) private int completed; /* * The failed property. */ - @JsonProperty(value = "failed", required = true) private int failed; /* * The inProgress property. */ - @JsonProperty(value = "inProgress", required = true) private int inProgress; /* * The total property. */ - @JsonProperty(value = "total", required = true) private int total; /* * The entityRecognitionTasks property. */ - @JsonProperty(value = "entityRecognitionTasks") private List entityRecognitionTasks; /* * The entityRecognitionPiiTasks property. */ - @JsonProperty(value = "entityRecognitionPiiTasks") private List entityRecognitionPiiTasks; /* * The keyPhraseExtractionTasks property. */ - @JsonProperty(value = "keyPhraseExtractionTasks") private List keyPhraseExtractionTasks; /* * The entityLinkingTasks property. */ - @JsonProperty(value = "entityLinkingTasks") private List entityLinkingTasks; /* * The sentimentAnalysisTasks property. */ - @JsonProperty(value = "sentimentAnalysisTasks") private List sentimentAnalysisTasks; /* * The customEntityRecognitionTasks property. */ - @JsonProperty(value = "customEntityRecognitionTasks") private List customEntityRecognitionTasks; /* * The customSingleClassificationTasks property. */ - @JsonProperty(value = "customSingleClassificationTasks") private List customSingleClassificationTasks; /* * The customMultiClassificationTasks property. */ - @JsonProperty(value = "customMultiClassificationTasks") private List customMultiClassificationTasks; /** @@ -329,4 +321,90 @@ public TasksStateTasksOld setCustomMultiClassificationTasks( this.customMultiClassificationTasks = customMultiClassificationTasks; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("completed", this.completed); + jsonWriter.writeIntField("failed", this.failed); + jsonWriter.writeIntField("inProgress", this.inProgress); + jsonWriter.writeIntField("total", this.total); + jsonWriter.writeArrayField("entityRecognitionTasks", this.entityRecognitionTasks, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("entityRecognitionPiiTasks", this.entityRecognitionTasks, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("keyPhraseExtractionTasks", this.entityRecognitionTasks, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("entityLinkingTasks", this.entityRecognitionTasks, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("sentimentAnalysisTasks", this.entityRecognitionTasks, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("customEntityRecognitionTasks", this.entityRecognitionTasks, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("customSingleClassificationTasks", this.entityRecognitionTasks, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("customMultiClassificationTasks", this.entityRecognitionTasks, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TasksStateTasksOld from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TasksStateTasksOld 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 TasksStateTasksOld. + */ + public static TasksStateTasksOld fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TasksStateTasksOld deserializedTasksStateTasksOld = new TasksStateTasksOld(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("completed".equals(fieldName)) { + deserializedTasksStateTasksOld.completed = reader.getInt(); + } else if ("failed".equals(fieldName)) { + deserializedTasksStateTasksOld.failed = reader.getInt(); + } else if ("inProgress".equals(fieldName)) { + deserializedTasksStateTasksOld.inProgress = reader.getInt(); + } else if ("total".equals(fieldName)) { + deserializedTasksStateTasksOld.total = reader.getInt(); + } else if ("entityRecognitionTasks".equals(fieldName)) { + deserializedTasksStateTasksOld.entityRecognitionTasks = reader.readArray( + reader1 -> TasksStateTasksEntityRecognitionTasksItem.fromJson(reader1)); + } else if ("entityRecognitionPiiTasks".equals(fieldName)) { + deserializedTasksStateTasksOld.entityRecognitionPiiTasks = reader.readArray( + reader1 -> TasksStateTasksEntityRecognitionPiiTasksItem.fromJson(reader1)); + } else if ("keyPhraseExtractionTasks".equals(fieldName)) { + deserializedTasksStateTasksOld.keyPhraseExtractionTasks = reader.readArray( + reader1 -> TasksStateTasksKeyPhraseExtractionTasksItem.fromJson(reader1)); + } else if ("entityLinkingTasks".equals(fieldName)) { + deserializedTasksStateTasksOld.entityLinkingTasks = reader.readArray( + reader1 -> TasksStateTasksEntityLinkingTasksItem.fromJson(reader1)); + } else if ("sentimentAnalysisTasks".equals(fieldName)) { + deserializedTasksStateTasksOld.sentimentAnalysisTasks = reader.readArray( + reader1 -> TasksStateTasksSentimentAnalysisTasksItem.fromJson(reader1)); + } else if ("customEntityRecognitionTasks".equals(fieldName)) { + deserializedTasksStateTasksOld.customEntityRecognitionTasks = reader.readArray( + reader1 -> TasksStateTasksCustomEntityRecognitionTasksItem.fromJson(reader1)); + } else if ("customSingleClassificationTasks".equals(fieldName)) { + deserializedTasksStateTasksOld.customSingleClassificationTasks = reader.readArray( + reader1 -> TasksStateTasksCustomSingleClassificationTasksItem.fromJson(reader1)); + } else if ("customMultiClassificationTasks".equals(fieldName)) { + deserializedTasksStateTasksOld.customMultiClassificationTasks = reader.readArray( + reader1 -> TasksStateTasksCustomMultiClassificationTasksItem.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + + return deserializedTasksStateTasksOld; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksSentimentAnalysisTasksItem.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksSentimentAnalysisTasksItem.java index e9506eab61d8..af4e35b8c956 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksSentimentAnalysisTasksItem.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TasksStateTasksSentimentAnalysisTasksItem.java @@ -1,11 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.implementation.models; import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; + +import java.io.IOException; /** The TasksStateTasksSentimentAnalysisTasksItem model. */ @Fluent @@ -13,7 +16,6 @@ public final class TasksStateTasksSentimentAnalysisTasksItem extends TaskState { /* * The results property. */ - @JsonProperty(value = "results") private SentimentResponse results; /** @@ -35,4 +37,41 @@ public TasksStateTasksSentimentAnalysisTasksItem setResults(SentimentResponse re this.results = results; return this; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("results", results); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TasksStateTasksSentimentAnalysisTasksItem from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TasksStateTasksSentimentAnalysisTasksItem 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 TasksStateTasksSentimentAnalysisTasksItem. + */ + public static TasksStateTasksSentimentAnalysisTasksItem fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TasksStateTasksSentimentAnalysisTasksItem deserializedTasksStateTasksSentimentAnalysisTasksItem = + new TasksStateTasksSentimentAnalysisTasksItem(); + + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("results".equals(fieldName)) { + deserializedTasksStateTasksSentimentAnalysisTasksItem.results = SentimentResponse.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return deserializedTasksStateTasksSentimentAnalysisTasksItem; + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TokenSentimentValue.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TokenSentimentValue.java index 1e741e9cd707..2e7d5e8567bd 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TokenSentimentValue.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/TokenSentimentValue.java @@ -4,18 +4,28 @@ package com.azure.ai.textanalytics.implementation.models; -/** Targeted sentiment in the sentence. */ +/** + * Targeted sentiment in the sentence. + */ public enum TokenSentimentValue { - /** Enum value positive. */ + /** + * Enum value positive. + */ POSITIVE("positive"), - /** Enum value mixed. */ + /** + * Enum value mixed. + */ MIXED("mixed"), - /** Enum value negative. */ + /** + * Enum value negative. + */ NEGATIVE("negative"); - /** The actual serialized value for a TokenSentimentValue instance. */ + /** + * The actual serialized value for a TokenSentimentValue instance. + */ private final String value; TokenSentimentValue(String value) { @@ -24,7 +34,7 @@ public enum TokenSentimentValue { /** * Parses a serialized value to a TokenSentimentValue instance. - * + * * @param value the serialized value to parse. * @return the parsed TokenSentimentValue object, or null if unable to parse. */ @@ -41,7 +51,9 @@ public static TokenSentimentValue fromString(String value) { return null; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public String toString() { return this.value; diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/WarningCodeValue.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/WarningCodeValue.java index cad61e069dee..deec82f8b81b 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/WarningCodeValue.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/WarningCodeValue.java @@ -7,25 +7,32 @@ import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; -/** Error code. */ +/** + * Error code. + */ public final class WarningCodeValue extends ExpandableStringEnum { - /** Static value LongWordsInDocument for WarningCodeValue. */ + /** + * Static value LongWordsInDocument for WarningCodeValue. + */ public static final WarningCodeValue LONG_WORDS_IN_DOCUMENT = fromString("LongWordsInDocument"); - /** Static value DocumentTruncated for WarningCodeValue. */ + /** + * Static value DocumentTruncated for WarningCodeValue. + */ public static final WarningCodeValue DOCUMENT_TRUNCATED = fromString("DocumentTruncated"); /** * Creates a new instance of WarningCodeValue value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated - public WarningCodeValue() {} + public WarningCodeValue() { + } /** * Creates or finds a WarningCodeValue from its string representation. - * + * * @param name a name to look for. * @return the corresponding WarningCodeValue. */ @@ -35,7 +42,7 @@ public static WarningCodeValue fromString(String name) { /** * Gets known WarningCodeValue values. - * + * * @return known WarningCodeValue values. */ public static Collection values() { diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/package-info.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/package-info.java index 0fe69a11c3cb..3dfbbdf707d4 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/package-info.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/models/package-info.java @@ -3,10 +3,10 @@ // Code generated by Microsoft (R) AutoRest Code Generator. /** - * Package containing the data models for MicrosoftCognitiveLanguageServiceTextAnalysis. The language service API is a - * suite of natural language processing (NLP) skills built with best-in-class Microsoft machine learning algorithms. The - * API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase extraction, language - * detection and question answering. Further documentation can be found in <a + * Package containing the data models for MicrosoftCognitiveLanguageServiceTextAnalysis. + * The language service API is a suite of natural language processing (NLP) skills built with best-in-class Microsoft + * machine learning algorithms. The API can be used to analyze unstructured text for tasks such as sentiment analysis, + * key phrase extraction, language detection and question answering. Further documentation can be found in <a * href="https://docs.microsoft.com/azure/cognitive-services/language-service/overview">https://docs.microsoft.com/azure/cognitive-services/language-service/overview</a>. */ package com.azure.ai.textanalytics.implementation.models; diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/package-info.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/package-info.java index 5220231597eb..acc658d9a17a 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/package-info.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/package-info.java @@ -3,10 +3,10 @@ // Code generated by Microsoft (R) AutoRest Code Generator. /** - * Package containing the implementations for MicrosoftCognitiveLanguageServiceTextAnalysis. The language service API is - * a suite of natural language processing (NLP) skills built with best-in-class Microsoft machine learning algorithms. - * The API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase extraction, - * language detection and question answering. Further documentation can be found in <a + * Package containing the implementations for MicrosoftCognitiveLanguageServiceTextAnalysis. + * The language service API is a suite of natural language processing (NLP) skills built with best-in-class Microsoft + * machine learning algorithms. The API can be used to analyze unstructured text for tasks such as sentiment analysis, + * key phrase extraction, language detection and question answering. Further documentation can be found in <a * href="https://docs.microsoft.com/azure/cognitive-services/language-service/overview">https://docs.microsoft.com/azure/cognitive-services/language-service/overview</a>. */ package com.azure.ai.textanalytics.implementation; diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/EntityCategory.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/EntityCategory.java index 75d4500ef05d..59230f5c1d23 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/EntityCategory.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/EntityCategory.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Immutable; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; @@ -101,7 +100,6 @@ public EntityCategory() { * @param name The string name to look for. * @return The corresponding {@code EntityCategory}. */ - @JsonCreator public static EntityCategory fromString(String name) { return fromString(name, EntityCategory.class); } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/EntityCertainty.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/EntityCertainty.java index f9d5904154d7..8049c43261d2 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/EntityCertainty.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/EntityCertainty.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Immutable; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; @@ -44,7 +43,6 @@ public EntityCertainty() { * @param name The string name to look for. * @return The corresponding {@code EntityCertainty}. */ - @JsonCreator public static EntityCertainty fromString(String name) { return fromString(name, EntityCertainty.class); } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/EntityConditionality.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/EntityConditionality.java index d23e1038c7c9..c02e83ece7da 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/EntityConditionality.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/EntityConditionality.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Immutable; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; @@ -35,7 +34,6 @@ public EntityConditionality() { * @param name The string name to look for. * @return The corresponding {@code EntityConditionality}. */ - @JsonCreator public static EntityConditionality fromString(String name) { return fromString(name, EntityConditionality.class); } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/ExtractiveSummarySentencesOrder.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/ExtractiveSummarySentencesOrder.java index 1bc5af9bd462..1e76481f107d 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/ExtractiveSummarySentencesOrder.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/ExtractiveSummarySentencesOrder.java @@ -7,25 +7,32 @@ import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; -/** The sorting criteria to use for the results of Extractive Summarization. */ +/** + * The sorting criteria to use for the results of Extractive Summarization. + */ public final class ExtractiveSummarySentencesOrder extends ExpandableStringEnum { - /** Indicates that results should be sorted in order of appearance in the text. */ + /** + * Indicates that results should be sorted in order of appearance in the text. + */ public static final ExtractiveSummarySentencesOrder OFFSET = fromString("Offset"); - /** Indicates that results should be sorted in order of importance (i.e. rank score) according to the model. */ + /** + * Indicates that results should be sorted in order of importance (i.e. rank score) according to the model. + */ public static final ExtractiveSummarySentencesOrder RANK = fromString("Rank"); /** * Creates a new instance of ExtractiveSummarySentencesOrder value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated - public ExtractiveSummarySentencesOrder() {} + public ExtractiveSummarySentencesOrder() { + } /** * Creates or finds a ExtractiveSummarySentencesOrder from its string representation. - * + * * @param name a name to look for. * @return the corresponding ExtractiveSummarySentencesOrder. */ @@ -35,7 +42,7 @@ public static ExtractiveSummarySentencesOrder fromString(String name) { /** * Gets known ExtractiveSummarySentencesOrder values. - * + * * @return known ExtractiveSummarySentencesOrder values. */ public static Collection values() { diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/HealthcareEntityCategory.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/HealthcareEntityCategory.java index bc6962bca0a1..90e85dcae4d9 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/HealthcareEntityCategory.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/HealthcareEntityCategory.java @@ -7,127 +7,202 @@ import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; -/** Healthcare Entity Category. */ +/** + * Healthcare Entity Category. + */ public final class HealthcareEntityCategory extends ExpandableStringEnum { - /** Static value BodyStructure for HealthcareEntityCategory. */ + /** + * Static value BodyStructure for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory BODY_STRUCTURE = fromString("BodyStructure"); - /** Static value Age for HealthcareEntityCategory. */ + /** + * Static value Age for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory AGE = fromString("Age"); - /** Static value Gender for HealthcareEntityCategory. */ + /** + * Static value Gender for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory GENDER = fromString("Gender"); - /** Static value Ethnicity for HealthcareEntityCategory. */ + /** + * Static value Ethnicity for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory ETHNICITY = fromString("Ethnicity"); - /** Static value ExaminationName for HealthcareEntityCategory. */ + /** + * Static value ExaminationName for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory EXAMINATION_NAME = fromString("ExaminationName"); - /** Static value Date for HealthcareEntityCategory. */ + /** + * Static value Date for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory DATE = fromString("Date"); - /** Static value Direction for HealthcareEntityCategory. */ + /** + * Static value Direction for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory DIRECTION = fromString("Direction"); - /** Static value Frequency for HealthcareEntityCategory. */ + /** + * Static value Frequency for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory FREQUENCY = fromString("Frequency"); - /** Static value MeasurementValue for HealthcareEntityCategory. */ + /** + * Static value MeasurementValue for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory MEASUREMENT_VALUE = fromString("MeasurementValue"); - /** Static value MeasurementUnit for HealthcareEntityCategory. */ + /** + * Static value MeasurementUnit for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory MEASUREMENT_UNIT = fromString("MeasurementUnit"); - /** Static value RelationalOperator for HealthcareEntityCategory. */ + /** + * Static value RelationalOperator for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory RELATIONAL_OPERATOR = fromString("RelationalOperator"); - /** Static value Time for HealthcareEntityCategory. */ + /** + * Static value Time for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory TIME = fromString("Time"); - /** Static value Course for HealthcareEntityCategory. */ + /** + * Static value Course for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory COURSE = fromString("Course"); - /** Static value GeneOrProtein for HealthcareEntityCategory. */ + /** + * Static value GeneOrProtein for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory GENE_OR_PROTEIN = fromString("GeneOrProtein"); - /** Static value Variant for HealthcareEntityCategory. */ + /** + * Static value Variant for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory VARIANT = fromString("Variant"); - /** Static value Expression for HealthcareEntityCategory. */ + /** + * Static value Expression for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory EXPRESSION = fromString("Expression"); - /** Static value MutationType for HealthcareEntityCategory. */ + /** + * Static value MutationType for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory MUTATION_TYPE = fromString("MutationType"); - /** Static value AdministrativeEvent for HealthcareEntityCategory. */ + /** + * Static value AdministrativeEvent for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory ADMINISTRATIVE_EVENT = fromString("AdministrativeEvent"); - /** Static value CareEnvironment for HealthcareEntityCategory. */ + /** + * Static value CareEnvironment for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory CARE_ENVIRONMENT = fromString("CareEnvironment"); - /** Static value HealthcareProfession for HealthcareEntityCategory. */ + /** + * Static value HealthcareProfession for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory HEALTHCARE_PROFESSION = fromString("HealthcareProfession"); - /** Static value Diagnosis for HealthcareEntityCategory. */ + /** + * Static value Diagnosis for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory DIAGNOSIS = fromString("Diagnosis"); - /** Static value SymptomOrSign for HealthcareEntityCategory. */ + /** + * Static value SymptomOrSign for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory SYMPTOM_OR_SIGN = fromString("SymptomOrSign"); - /** Static value ConditionQualifier for HealthcareEntityCategory. */ + /** + * Static value ConditionQualifier for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory CONDITION_QUALIFIER = fromString("ConditionQualifier"); - /** Static value ConditionScale for HealthcareEntityCategory. */ + /** + * Static value ConditionScale for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory CONDITION_SCALE = fromString("ConditionScale"); - /** Static value MedicationClass for HealthcareEntityCategory. */ + /** + * Static value MedicationClass for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory MEDICATION_CLASS = fromString("MedicationClass"); - /** Static value MedicationName for HealthcareEntityCategory. */ + /** + * Static value MedicationName for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory MEDICATION_NAME = fromString("MedicationName"); - /** Static value Dosage for HealthcareEntityCategory. */ + /** + * Static value Dosage for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory DOSAGE = fromString("Dosage"); - /** Static value MedicationForm for HealthcareEntityCategory. */ + /** + * Static value MedicationForm for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory MEDICATION_FORM = fromString("MedicationForm"); - /** Static value MedicationRoute for HealthcareEntityCategory. */ + /** + * Static value MedicationRoute for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory MEDICATION_ROUTE = fromString("MedicationRoute"); - /** Static value FamilyRelation for HealthcareEntityCategory. */ + /** + * Static value FamilyRelation for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory FAMILY_RELATION = fromString("FamilyRelation"); - /** Static value TreatmentName for HealthcareEntityCategory. */ + /** + * Static value TreatmentName for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory TREATMENT_NAME = fromString("TreatmentName"); - /** Static value Allergen for HealthcareEntityCategory. */ + /** + * Static value Allergen for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory ALLERGEN = fromString("Allergen"); - /** Static value Employment for HealthcareEntityCategory. */ + /** + * Static value Employment for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory EMPLOYMENT = fromString("Employment"); - /** Static value LivingStatus for HealthcareEntityCategory. */ + /** + * Static value LivingStatus for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory LIVING_STATUS = fromString("LivingStatus"); - /** Static value SubstanceUse for HealthcareEntityCategory. */ + /** + * Static value SubstanceUse for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory SUBSTANCE_USE = fromString("SubstanceUse"); - /** Static value SubstanceUseAmount for HealthcareEntityCategory. */ + /** + * Static value SubstanceUseAmount for HealthcareEntityCategory. + */ public static final HealthcareEntityCategory SUBSTANCE_USE_AMOUNT = fromString("SubstanceUseAmount"); /** * Creates a new instance of HealthcareEntityCategory value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated - public HealthcareEntityCategory() {} + public HealthcareEntityCategory() { + } /** * Creates or finds a HealthcareEntityCategory from its string representation. - * + * * @param name a name to look for. * @return the corresponding HealthcareEntityCategory. */ @@ -137,7 +212,7 @@ public static HealthcareEntityCategory fromString(String name) { /** * Gets known HealthcareEntityCategory values. - * + * * @return known HealthcareEntityCategory values. */ public static Collection values() { diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/HealthcareEntityRelationType.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/HealthcareEntityRelationType.java index 83ae3b85b8c2..9d5ba2491f9f 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/HealthcareEntityRelationType.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/HealthcareEntityRelationType.java @@ -7,126 +7,199 @@ import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; -/** Type of relation. Examples include: `DosageOfMedication` or 'FrequencyOfMedication', etc. */ +/** + * Type of relation. Examples include: `DosageOfMedication` or 'FrequencyOfMedication', etc. + */ public final class HealthcareEntityRelationType extends ExpandableStringEnum { - /** Static value Abbreviation for HealthcareEntityRelationType. */ + /** + * Static value Abbreviation for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType ABBREVIATION = fromString("Abbreviation"); - /** Static value BodySiteOfCondition for HealthcareEntityRelationType. */ + /** + * Static value BodySiteOfCondition for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType BODY_SITE_OF_CONDITION = fromString("BodySiteOfCondition"); - /** Static value BodySiteOfTreatment for HealthcareEntityRelationType. */ + /** + * Static value BodySiteOfTreatment for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType BODY_SITE_OF_TREATMENT = fromString("BodySiteOfTreatment"); - /** Static value CourseOfCondition for HealthcareEntityRelationType. */ + /** + * Static value CourseOfCondition for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType COURSE_OF_CONDITION = fromString("CourseOfCondition"); - /** Static value CourseOfExamination for HealthcareEntityRelationType. */ + /** + * Static value CourseOfExamination for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType COURSE_OF_EXAMINATION = fromString("CourseOfExamination"); - /** Static value CourseOfMedication for HealthcareEntityRelationType. */ + /** + * Static value CourseOfMedication for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType COURSE_OF_MEDICATION = fromString("CourseOfMedication"); - /** Static value CourseOfTreatment for HealthcareEntityRelationType. */ + /** + * Static value CourseOfTreatment for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType COURSE_OF_TREATMENT = fromString("CourseOfTreatment"); - /** Static value DirectionOfBodyStructure for HealthcareEntityRelationType. */ - public static final HealthcareEntityRelationType DIRECTION_OF_BODY_STRUCTURE = - fromString("DirectionOfBodyStructure"); + /** + * Static value DirectionOfBodyStructure for HealthcareEntityRelationType. + */ + public static final HealthcareEntityRelationType DIRECTION_OF_BODY_STRUCTURE + = fromString("DirectionOfBodyStructure"); - /** Static value DirectionOfCondition for HealthcareEntityRelationType. */ + /** + * Static value DirectionOfCondition for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType DIRECTION_OF_CONDITION = fromString("DirectionOfCondition"); - /** Static value DirectionOfExamination for HealthcareEntityRelationType. */ + /** + * Static value DirectionOfExamination for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType DIRECTION_OF_EXAMINATION = fromString("DirectionOfExamination"); - /** Static value DirectionOfTreatment for HealthcareEntityRelationType. */ + /** + * Static value DirectionOfTreatment for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType DIRECTION_OF_TREATMENT = fromString("DirectionOfTreatment"); - /** Static value DosageOfMedication for HealthcareEntityRelationType. */ + /** + * Static value DosageOfMedication for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType DOSAGE_OF_MEDICATION = fromString("DosageOfMedication"); - /** Static value ExaminationFindsCondition for HealthcareEntityRelationType. */ - public static final HealthcareEntityRelationType EXAMINATION_FINDS_CONDITION = - fromString("ExaminationFindsCondition"); + /** + * Static value ExaminationFindsCondition for HealthcareEntityRelationType. + */ + public static final HealthcareEntityRelationType EXAMINATION_FINDS_CONDITION + = fromString("ExaminationFindsCondition"); - /** Static value ExpressionOfGene for HealthcareEntityRelationType. */ + /** + * Static value ExpressionOfGene for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType EXPRESSION_OF_GENE = fromString("ExpressionOfGene"); - /** Static value ExpressionOfVariant for HealthcareEntityRelationType. */ + /** + * Static value ExpressionOfVariant for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType EXPRESSION_OF_VARIANT = fromString("ExpressionOfVariant"); - /** Static value FormOfMedication for HealthcareEntityRelationType. */ + /** + * Static value FormOfMedication for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType FORM_OF_MEDICATION = fromString("FormOfMedication"); - /** Static value FrequencyOfCondition for HealthcareEntityRelationType. */ + /** + * Static value FrequencyOfCondition for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType FREQUENCY_OF_CONDITION = fromString("FrequencyOfCondition"); - /** Static value FrequencyOfMedication for HealthcareEntityRelationType. */ + /** + * Static value FrequencyOfMedication for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType FREQUENCY_OF_MEDICATION = fromString("FrequencyOfMedication"); - /** Static value FrequencyOfTreatment for HealthcareEntityRelationType. */ + /** + * Static value FrequencyOfTreatment for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType FREQUENCY_OF_TREATMENT = fromString("FrequencyOfTreatment"); - /** Static value MutationTypeOfGene for HealthcareEntityRelationType. */ + /** + * Static value MutationTypeOfGene for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType MUTATION_TYPE_OF_GENE = fromString("MutationTypeOfGene"); - /** Static value MutationTypeOfVariant for HealthcareEntityRelationType. */ + /** + * Static value MutationTypeOfVariant for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType MUTATION_TYPE_OF_VARIANT = fromString("MutationTypeOfVariant"); - /** Static value QualifierOfCondition for HealthcareEntityRelationType. */ + /** + * Static value QualifierOfCondition for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType QUALIFIER_OF_CONDITION = fromString("QualifierOfCondition"); - /** Static value RelationOfExamination for HealthcareEntityRelationType. */ + /** + * Static value RelationOfExamination for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType RELATION_OF_EXAMINATION = fromString("RelationOfExamination"); - /** Static value RouteOfMedication for HealthcareEntityRelationType. */ + /** + * Static value RouteOfMedication for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType ROUTE_OF_MEDICATION = fromString("RouteOfMedication"); - /** Static value ScaleOfCondition for HealthcareEntityRelationType. */ + /** + * Static value ScaleOfCondition for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType SCALE_OF_CONDITION = fromString("ScaleOfCondition"); - /** Static value TimeOfCondition for HealthcareEntityRelationType. */ + /** + * Static value TimeOfCondition for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType TIME_OF_CONDITION = fromString("TimeOfCondition"); - /** Static value TimeOfEvent for HealthcareEntityRelationType. */ + /** + * Static value TimeOfEvent for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType TIME_OF_EVENT = fromString("TimeOfEvent"); - /** Static value TimeOfExamination for HealthcareEntityRelationType. */ + /** + * Static value TimeOfExamination for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType TIME_OF_EXAMINATION = fromString("TimeOfExamination"); - /** Static value TimeOfMedication for HealthcareEntityRelationType. */ + /** + * Static value TimeOfMedication for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType TIME_OF_MEDICATION = fromString("TimeOfMedication"); - /** Static value TimeOfTreatment for HealthcareEntityRelationType. */ + /** + * Static value TimeOfTreatment for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType TIME_OF_TREATMENT = fromString("TimeOfTreatment"); - /** Static value UnitOfCondition for HealthcareEntityRelationType. */ + /** + * Static value UnitOfCondition for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType UNIT_OF_CONDITION = fromString("UnitOfCondition"); - /** Static value UnitOfExamination for HealthcareEntityRelationType. */ + /** + * Static value UnitOfExamination for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType UNIT_OF_EXAMINATION = fromString("UnitOfExamination"); - /** Static value ValueOfCondition for HealthcareEntityRelationType. */ + /** + * Static value ValueOfCondition for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType VALUE_OF_CONDITION = fromString("ValueOfCondition"); - /** Static value ValueOfExamination for HealthcareEntityRelationType. */ + /** + * Static value ValueOfExamination for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType VALUE_OF_EXAMINATION = fromString("ValueOfExamination"); - /** Static value VariantOfGene for HealthcareEntityRelationType. */ + /** + * Static value VariantOfGene for HealthcareEntityRelationType. + */ public static final HealthcareEntityRelationType VARIANT_OF_GENE = fromString("VariantOfGene"); /** * Creates a new instance of HealthcareEntityRelationType value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated - public HealthcareEntityRelationType() {} + public HealthcareEntityRelationType() { + } /** * Creates or finds a HealthcareEntityRelationType from its string representation. - * + * * @param name a name to look for. * @return the corresponding HealthcareEntityRelationType. */ @@ -136,7 +209,7 @@ public static HealthcareEntityRelationType fromString(String name) { /** * Gets known HealthcareEntityRelationType values. - * + * * @return known HealthcareEntityRelationType values. */ public static Collection values() { diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/PiiEntityCategory.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/PiiEntityCategory.java index f088290e4d33..4ba52af3486d 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/PiiEntityCategory.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/PiiEntityCategory.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Immutable; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; @@ -567,7 +566,6 @@ public PiiEntityCategory() { * @param name a name to look for. * @return the corresponding PiiEntityCategory. */ - @JsonCreator public static PiiEntityCategory fromString(String name) { return fromString(name, PiiEntityCategory.class); } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/TextAnalyticsError.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/TextAnalyticsError.java index e825fc894a92..1af429ac9756 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/TextAnalyticsError.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/TextAnalyticsError.java @@ -1,16 +1,21 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.ai.textanalytics.models; import com.azure.core.annotation.Immutable; +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 {@code TextAnalyticsError} model. */ @Immutable -public final class TextAnalyticsError { +public final class TextAnalyticsError implements JsonSerializable { /* * Error code. Possible values include: 'invalidRequest', * 'invalidArgument', 'internalServerError', 'serviceUnavailable' @@ -67,4 +72,49 @@ public String getMessage() { public String getTarget() { return this.target; } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("errorCode", this.errorCode == null ? null : this.errorCode.toString()); + jsonWriter.writeStringField("message", this.message); + jsonWriter.writeStringField("target", this.target); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TextAnalyticsError from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TextAnalyticsError 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 TextAnalyticsError. + */ + public static TextAnalyticsError fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TextAnalyticsErrorCode errorCode = null; + String message = null; + String target = null; + + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("errorCode".equals(fieldName)) { + errorCode = TextAnalyticsErrorCode.fromString(reader.getString()); + } else if ("message".equals(fieldName)) { + message = reader.getString(); + } else if ("target".equals(fieldName)) { + target = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new TextAnalyticsError(errorCode, message, target); + }); + } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/TextAnalyticsErrorCode.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/TextAnalyticsErrorCode.java index c0d40ee3a0a9..9e9dc85087a2 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/TextAnalyticsErrorCode.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/TextAnalyticsErrorCode.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Immutable; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.io.Serializable; import java.util.Collection; @@ -16,7 +15,6 @@ @Immutable public final class TextAnalyticsErrorCode extends ExpandableStringEnum implements Serializable { private static final long serialVersionUID = 21436310107606058L; - /** * Enum value InvalidRequest. */ @@ -97,7 +95,6 @@ public TextAnalyticsErrorCode() { * @param name The string name to look for. * @return The corresponding TextAnalyticsErrorCode. */ - @JsonCreator public static TextAnalyticsErrorCode fromString(String name) { return fromString(name, TextAnalyticsErrorCode.class); } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/TextSentiment.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/TextSentiment.java index 6b5355cf969d..832e3484899f 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/TextSentiment.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/TextSentiment.java @@ -5,7 +5,6 @@ import com.azure.core.annotation.Immutable; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; @@ -49,7 +48,6 @@ public TextSentiment() { * @param name A name to look for. * @return The corresponding {@code TextSentiment}. */ - @JsonCreator public static TextSentiment fromString(String name) { return fromString(name, TextSentiment.class); } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/WarningCode.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/WarningCode.java index e694f0d26a79..d7f6d0367704 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/WarningCode.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/WarningCode.java @@ -6,7 +6,6 @@ import com.azure.core.annotation.Immutable; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; @@ -40,7 +39,6 @@ public WarningCode() { * @param name A name to look for. * @return The corresponding {@code WarningCode}. */ - @JsonCreator public static WarningCode fromString(String name) { return fromString(name, WarningCode.class); } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/package-info.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/package-info.java index e1d8752eeca5..268ddab7abc6 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/package-info.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/package-info.java @@ -3,10 +3,10 @@ // Code generated by Microsoft (R) AutoRest Code Generator. /** - * Package containing the data models for MicrosoftCognitiveLanguageServiceTextAnalysis. The language service API is a - * suite of natural language processing (NLP) skills built with best-in-class Microsoft machine learning algorithms. The - * API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase extraction, language - * detection and question answering. Further documentation can be found in <a + * Package containing the data models for MicrosoftCognitiveLanguageServiceTextAnalysis. + * The language service API is a suite of natural language processing (NLP) skills built with best-in-class Microsoft + * machine learning algorithms. The API can be used to analyze unstructured text for tasks such as sentiment analysis, + * key phrase extraction, language detection and question answering. Further documentation can be found in <a * href="https://docs.microsoft.com/azure/cognitive-services/language-service/overview">https://docs.microsoft.com/azure/cognitive-services/language-service/overview</a>. */ package com.azure.ai.textanalytics.models; diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TextAnalyticsClientBuilderTest.java b/sdk/textanalytics/azure-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TextAnalyticsClientBuilderTest.java index efcbc5a9ecd3..f3dff672e295 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TextAnalyticsClientBuilderTest.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TextAnalyticsClientBuilderTest.java @@ -238,13 +238,6 @@ public void clientBuilderWithNewLanguageForBatchOperation(HttpClient httpClient, }); } - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("com.azure.ai.textanalytics.TestUtils#getTestParameters") - public void clientBuilderWithAAD(HttpClient httpClient, TextAnalyticsServiceVersion serviceVersion) { - clientBuilderWithAadRunner(httpClient, serviceVersion, clientBuilder -> (input) -> - validatePrimaryLanguage(clientBuilder.buildClient().detectLanguage(input))); - } - @Test @DoNotRecord public void applicationIdFallsBackToLogOptions() { diff --git a/sdk/textanalytics/azure-ai-textanalytics/swagger/README.md b/sdk/textanalytics/azure-ai-textanalytics/swagger/README.md index 3e572dae3426..f0347c72afb8 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/swagger/README.md +++ b/sdk/textanalytics/azure-ai-textanalytics/swagger/README.md @@ -29,7 +29,7 @@ autorest ### Code Generation ```yaml -use: '@autorest/java@4.1.22' +use: '@autorest/java@4.1.29' input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/53240ebc58b3c4e99de723194032064db1d97e63/specification/cognitiveservices/data-plane/Language/stable/2023-04-01/analyzetext.json java: true output-folder: ../