All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.textract.model.GetLendingAnalysisResponse Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Textract module holds the client classes that are used for communicating with Textract.

There is a newer version: 2.29.15
Show newest version
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
 * the License. A copy of the License is located at
 * 
 * http://aws.amazon.com/apache2.0
 * 
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 */

package software.amazon.awssdk.services.textract.model;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 */
@Generated("software.amazon.awssdk:codegen")
public final class GetLendingAnalysisResponse extends TextractResponse implements
        ToCopyableBuilder {
    private static final SdkField DOCUMENT_METADATA_FIELD = SdkField
            . builder(MarshallingType.SDK_POJO).memberName("DocumentMetadata")
            .getter(getter(GetLendingAnalysisResponse::documentMetadata)).setter(setter(Builder::documentMetadata))
            .constructor(DocumentMetadata::builder)
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DocumentMetadata").build()).build();

    private static final SdkField JOB_STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("JobStatus").getter(getter(GetLendingAnalysisResponse::jobStatusAsString))
            .setter(setter(Builder::jobStatus))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("JobStatus").build()).build();

    private static final SdkField NEXT_TOKEN_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("NextToken").getter(getter(GetLendingAnalysisResponse::nextToken)).setter(setter(Builder::nextToken))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NextToken").build()).build();

    private static final SdkField> RESULTS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("Results")
            .getter(getter(GetLendingAnalysisResponse::results))
            .setter(setter(Builder::results))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Results").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(LendingResult::builder)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build()).build()).build()).build();

    private static final SdkField> WARNINGS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("Warnings")
            .getter(getter(GetLendingAnalysisResponse::warnings))
            .setter(setter(Builder::warnings))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Warnings").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(Warning::builder)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build()).build()).build()).build();

    private static final SdkField STATUS_MESSAGE_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("StatusMessage").getter(getter(GetLendingAnalysisResponse::statusMessage))
            .setter(setter(Builder::statusMessage))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StatusMessage").build()).build();

    private static final SdkField ANALYZE_LENDING_MODEL_VERSION_FIELD = SdkField
            . builder(MarshallingType.STRING)
            .memberName("AnalyzeLendingModelVersion")
            .getter(getter(GetLendingAnalysisResponse::analyzeLendingModelVersion))
            .setter(setter(Builder::analyzeLendingModelVersion))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AnalyzeLendingModelVersion").build())
            .build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(DOCUMENT_METADATA_FIELD,
            JOB_STATUS_FIELD, NEXT_TOKEN_FIELD, RESULTS_FIELD, WARNINGS_FIELD, STATUS_MESSAGE_FIELD,
            ANALYZE_LENDING_MODEL_VERSION_FIELD));

    private final DocumentMetadata documentMetadata;

    private final String jobStatus;

    private final String nextToken;

    private final List results;

    private final List warnings;

    private final String statusMessage;

    private final String analyzeLendingModelVersion;

    private GetLendingAnalysisResponse(BuilderImpl builder) {
        super(builder);
        this.documentMetadata = builder.documentMetadata;
        this.jobStatus = builder.jobStatus;
        this.nextToken = builder.nextToken;
        this.results = builder.results;
        this.warnings = builder.warnings;
        this.statusMessage = builder.statusMessage;
        this.analyzeLendingModelVersion = builder.analyzeLendingModelVersion;
    }

    /**
     * Returns the value of the DocumentMetadata property for this object.
     * 
     * @return The value of the DocumentMetadata property for this object.
     */
    public final DocumentMetadata documentMetadata() {
        return documentMetadata;
    }

    /**
     * 

* The current status of the lending analysis job. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #jobStatus} will * return {@link JobStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #jobStatusAsString}. *

* * @return The current status of the lending analysis job. * @see JobStatus */ public final JobStatus jobStatus() { return JobStatus.fromValue(jobStatus); } /** *

* The current status of the lending analysis job. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #jobStatus} will * return {@link JobStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #jobStatusAsString}. *

* * @return The current status of the lending analysis job. * @see JobStatus */ public final String jobStatusAsString() { return jobStatus; } /** *

* If the response is truncated, Amazon Textract returns this token. You can use this token in the subsequent * request to retrieve the next set of lending results. *

* * @return If the response is truncated, Amazon Textract returns this token. You can use this token in the * subsequent request to retrieve the next set of lending results. */ public final String nextToken() { return nextToken; } /** * For responses, this returns true if the service returned a value for the Results property. This DOES NOT check * that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). This is * useful because the SDK will never return a null collection or map, but you may need to differentiate between the * service returning nothing (or null) and the service returning an empty collection or map. For requests, this * returns true if a value for the property was specified in the request builder, and false if a value was not * specified. */ public final boolean hasResults() { return results != null && !(results instanceof SdkAutoConstructList); } /** *

* Holds the information returned by one of AmazonTextract's document analysis operations for the pinstripe. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasResults} method. *

* * @return Holds the information returned by one of AmazonTextract's document analysis operations for the pinstripe. */ public final List results() { return results; } /** * For responses, this returns true if the service returned a value for the Warnings property. This DOES NOT check * that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). This is * useful because the SDK will never return a null collection or map, but you may need to differentiate between the * service returning nothing (or null) and the service returning an empty collection or map. For requests, this * returns true if a value for the property was specified in the request builder, and false if a value was not * specified. */ public final boolean hasWarnings() { return warnings != null && !(warnings instanceof SdkAutoConstructList); } /** *

* A list of warnings that occurred during the lending analysis operation. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasWarnings} method. *

* * @return A list of warnings that occurred during the lending analysis operation. */ public final List warnings() { return warnings; } /** *

* Returns if the lending analysis job could not be completed. Contains explanation for what error occurred. *

* * @return Returns if the lending analysis job could not be completed. Contains explanation for what error occurred. */ public final String statusMessage() { return statusMessage; } /** *

* The current model version of the Analyze Lending API. *

* * @return The current model version of the Analyze Lending API. */ public final String analyzeLendingModelVersion() { return analyzeLendingModelVersion; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(documentMetadata()); hashCode = 31 * hashCode + Objects.hashCode(jobStatusAsString()); hashCode = 31 * hashCode + Objects.hashCode(nextToken()); hashCode = 31 * hashCode + Objects.hashCode(hasResults() ? results() : null); hashCode = 31 * hashCode + Objects.hashCode(hasWarnings() ? warnings() : null); hashCode = 31 * hashCode + Objects.hashCode(statusMessage()); hashCode = 31 * hashCode + Objects.hashCode(analyzeLendingModelVersion()); return hashCode; } @Override public final boolean equals(Object obj) { return super.equals(obj) && equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof GetLendingAnalysisResponse)) { return false; } GetLendingAnalysisResponse other = (GetLendingAnalysisResponse) obj; return Objects.equals(documentMetadata(), other.documentMetadata()) && Objects.equals(jobStatusAsString(), other.jobStatusAsString()) && Objects.equals(nextToken(), other.nextToken()) && hasResults() == other.hasResults() && Objects.equals(results(), other.results()) && hasWarnings() == other.hasWarnings() && Objects.equals(warnings(), other.warnings()) && Objects.equals(statusMessage(), other.statusMessage()) && Objects.equals(analyzeLendingModelVersion(), other.analyzeLendingModelVersion()); } /** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. */ @Override public final String toString() { return ToString.builder("GetLendingAnalysisResponse").add("DocumentMetadata", documentMetadata()) .add("JobStatus", jobStatusAsString()).add("NextToken", nextToken()) .add("Results", hasResults() ? results() : null).add("Warnings", hasWarnings() ? warnings() : null) .add("StatusMessage", statusMessage()).add("AnalyzeLendingModelVersion", analyzeLendingModelVersion()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "DocumentMetadata": return Optional.ofNullable(clazz.cast(documentMetadata())); case "JobStatus": return Optional.ofNullable(clazz.cast(jobStatusAsString())); case "NextToken": return Optional.ofNullable(clazz.cast(nextToken())); case "Results": return Optional.ofNullable(clazz.cast(results())); case "Warnings": return Optional.ofNullable(clazz.cast(warnings())); case "StatusMessage": return Optional.ofNullable(clazz.cast(statusMessage())); case "AnalyzeLendingModelVersion": return Optional.ofNullable(clazz.cast(analyzeLendingModelVersion())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((GetLendingAnalysisResponse) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends TextractResponse.Builder, SdkPojo, CopyableBuilder { /** * Sets the value of the DocumentMetadata property for this object. * * @param documentMetadata * The new value for the DocumentMetadata property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder documentMetadata(DocumentMetadata documentMetadata); /** * Sets the value of the DocumentMetadata property for this object. * * This is a convenience method that creates an instance of the {@link DocumentMetadata.Builder} avoiding the * need to create one manually via {@link DocumentMetadata#builder()}. * *

* When the {@link Consumer} completes, {@link DocumentMetadata.Builder#build()} is called immediately and its * result is passed to {@link #documentMetadata(DocumentMetadata)}. * * @param documentMetadata * a consumer that will call methods on {@link DocumentMetadata.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #documentMetadata(DocumentMetadata) */ default Builder documentMetadata(Consumer documentMetadata) { return documentMetadata(DocumentMetadata.builder().applyMutation(documentMetadata).build()); } /** *

* The current status of the lending analysis job. *

* * @param jobStatus * The current status of the lending analysis job. * @see JobStatus * @return Returns a reference to this object so that method calls can be chained together. * @see JobStatus */ Builder jobStatus(String jobStatus); /** *

* The current status of the lending analysis job. *

* * @param jobStatus * The current status of the lending analysis job. * @see JobStatus * @return Returns a reference to this object so that method calls can be chained together. * @see JobStatus */ Builder jobStatus(JobStatus jobStatus); /** *

* If the response is truncated, Amazon Textract returns this token. You can use this token in the subsequent * request to retrieve the next set of lending results. *

* * @param nextToken * If the response is truncated, Amazon Textract returns this token. You can use this token in the * subsequent request to retrieve the next set of lending results. * @return Returns a reference to this object so that method calls can be chained together. */ Builder nextToken(String nextToken); /** *

* Holds the information returned by one of AmazonTextract's document analysis operations for the pinstripe. *

* * @param results * Holds the information returned by one of AmazonTextract's document analysis operations for the * pinstripe. * @return Returns a reference to this object so that method calls can be chained together. */ Builder results(Collection results); /** *

* Holds the information returned by one of AmazonTextract's document analysis operations for the pinstripe. *

* * @param results * Holds the information returned by one of AmazonTextract's document analysis operations for the * pinstripe. * @return Returns a reference to this object so that method calls can be chained together. */ Builder results(LendingResult... results); /** *

* Holds the information returned by one of AmazonTextract's document analysis operations for the pinstripe. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.textract.model.LendingResult.Builder} avoiding the need to create one * manually via {@link software.amazon.awssdk.services.textract.model.LendingResult#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.textract.model.LendingResult.Builder#build()} is called immediately * and its result is passed to {@link #results(List)}. * * @param results * a consumer that will call methods on * {@link software.amazon.awssdk.services.textract.model.LendingResult.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #results(java.util.Collection) */ Builder results(Consumer... results); /** *

* A list of warnings that occurred during the lending analysis operation. *

* * @param warnings * A list of warnings that occurred during the lending analysis operation. * @return Returns a reference to this object so that method calls can be chained together. */ Builder warnings(Collection warnings); /** *

* A list of warnings that occurred during the lending analysis operation. *

* * @param warnings * A list of warnings that occurred during the lending analysis operation. * @return Returns a reference to this object so that method calls can be chained together. */ Builder warnings(Warning... warnings); /** *

* A list of warnings that occurred during the lending analysis operation. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.textract.model.Warning.Builder} avoiding the need to create one * manually via {@link software.amazon.awssdk.services.textract.model.Warning#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.textract.model.Warning.Builder#build()} is called immediately and its * result is passed to {@link #warnings(List)}. * * @param warnings * a consumer that will call methods on * {@link software.amazon.awssdk.services.textract.model.Warning.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #warnings(java.util.Collection) */ Builder warnings(Consumer... warnings); /** *

* Returns if the lending analysis job could not be completed. Contains explanation for what error occurred. *

* * @param statusMessage * Returns if the lending analysis job could not be completed. Contains explanation for what error * occurred. * @return Returns a reference to this object so that method calls can be chained together. */ Builder statusMessage(String statusMessage); /** *

* The current model version of the Analyze Lending API. *

* * @param analyzeLendingModelVersion * The current model version of the Analyze Lending API. * @return Returns a reference to this object so that method calls can be chained together. */ Builder analyzeLendingModelVersion(String analyzeLendingModelVersion); } static final class BuilderImpl extends TextractResponse.BuilderImpl implements Builder { private DocumentMetadata documentMetadata; private String jobStatus; private String nextToken; private List results = DefaultSdkAutoConstructList.getInstance(); private List warnings = DefaultSdkAutoConstructList.getInstance(); private String statusMessage; private String analyzeLendingModelVersion; private BuilderImpl() { } private BuilderImpl(GetLendingAnalysisResponse model) { super(model); documentMetadata(model.documentMetadata); jobStatus(model.jobStatus); nextToken(model.nextToken); results(model.results); warnings(model.warnings); statusMessage(model.statusMessage); analyzeLendingModelVersion(model.analyzeLendingModelVersion); } public final DocumentMetadata.Builder getDocumentMetadata() { return documentMetadata != null ? documentMetadata.toBuilder() : null; } public final void setDocumentMetadata(DocumentMetadata.BuilderImpl documentMetadata) { this.documentMetadata = documentMetadata != null ? documentMetadata.build() : null; } @Override public final Builder documentMetadata(DocumentMetadata documentMetadata) { this.documentMetadata = documentMetadata; return this; } public final String getJobStatus() { return jobStatus; } public final void setJobStatus(String jobStatus) { this.jobStatus = jobStatus; } @Override public final Builder jobStatus(String jobStatus) { this.jobStatus = jobStatus; return this; } @Override public final Builder jobStatus(JobStatus jobStatus) { this.jobStatus(jobStatus == null ? null : jobStatus.toString()); return this; } public final String getNextToken() { return nextToken; } public final void setNextToken(String nextToken) { this.nextToken = nextToken; } @Override public final Builder nextToken(String nextToken) { this.nextToken = nextToken; return this; } public final List getResults() { List result = LendingResultListCopier.copyToBuilder(this.results); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setResults(Collection results) { this.results = LendingResultListCopier.copyFromBuilder(results); } @Override public final Builder results(Collection results) { this.results = LendingResultListCopier.copy(results); return this; } @Override @SafeVarargs public final Builder results(LendingResult... results) { results(Arrays.asList(results)); return this; } @Override @SafeVarargs public final Builder results(Consumer... results) { results(Stream.of(results).map(c -> LendingResult.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final List getWarnings() { List result = WarningsCopier.copyToBuilder(this.warnings); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setWarnings(Collection warnings) { this.warnings = WarningsCopier.copyFromBuilder(warnings); } @Override public final Builder warnings(Collection warnings) { this.warnings = WarningsCopier.copy(warnings); return this; } @Override @SafeVarargs public final Builder warnings(Warning... warnings) { warnings(Arrays.asList(warnings)); return this; } @Override @SafeVarargs public final Builder warnings(Consumer... warnings) { warnings(Stream.of(warnings).map(c -> Warning.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final String getStatusMessage() { return statusMessage; } public final void setStatusMessage(String statusMessage) { this.statusMessage = statusMessage; } @Override public final Builder statusMessage(String statusMessage) { this.statusMessage = statusMessage; return this; } public final String getAnalyzeLendingModelVersion() { return analyzeLendingModelVersion; } public final void setAnalyzeLendingModelVersion(String analyzeLendingModelVersion) { this.analyzeLendingModelVersion = analyzeLendingModelVersion; } @Override public final Builder analyzeLendingModelVersion(String analyzeLendingModelVersion) { this.analyzeLendingModelVersion = analyzeLendingModelVersion; return this; } @Override public GetLendingAnalysisResponse build() { return new GetLendingAnalysisResponse(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy