software.amazon.awssdk.services.textract.model.GetLendingAnalysisResponse Maven / Gradle / Ivy
Show all versions of textract Show documentation
/*
* 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 extends Builder> 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