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

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

/*
 * 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.io.Serializable;
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;

/**
 * 

* The structure holding all the information returned by AnalyzeExpense *

*/ @Generated("software.amazon.awssdk:codegen") public final class ExpenseDocument implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField EXPENSE_INDEX_FIELD = SdkField. builder(MarshallingType.INTEGER) .memberName("ExpenseIndex").getter(getter(ExpenseDocument::expenseIndex)).setter(setter(Builder::expenseIndex)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExpenseIndex").build()).build(); private static final SdkField> SUMMARY_FIELDS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("SummaryFields") .getter(getter(ExpenseDocument::summaryFields)) .setter(setter(Builder::summaryFields)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SummaryFields").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(ExpenseField::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField> LINE_ITEM_GROUPS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("LineItemGroups") .getter(getter(ExpenseDocument::lineItemGroups)) .setter(setter(Builder::lineItemGroups)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LineItemGroups").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(LineItemGroup::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField> BLOCKS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("Blocks") .getter(getter(ExpenseDocument::blocks)) .setter(setter(Builder::blocks)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Blocks").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(Block::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(EXPENSE_INDEX_FIELD, SUMMARY_FIELDS_FIELD, LINE_ITEM_GROUPS_FIELD, BLOCKS_FIELD)); private static final long serialVersionUID = 1L; private final Integer expenseIndex; private final List summaryFields; private final List lineItemGroups; private final List blocks; private ExpenseDocument(BuilderImpl builder) { this.expenseIndex = builder.expenseIndex; this.summaryFields = builder.summaryFields; this.lineItemGroups = builder.lineItemGroups; this.blocks = builder.blocks; } /** *

* Denotes which invoice or receipt in the document the information is coming from. First document will be 1, the * second 2, and so on. *

* * @return Denotes which invoice or receipt in the document the information is coming from. First document will be * 1, the second 2, and so on. */ public final Integer expenseIndex() { return expenseIndex; } /** * For responses, this returns true if the service returned a value for the SummaryFields 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 hasSummaryFields() { return summaryFields != null && !(summaryFields instanceof SdkAutoConstructList); } /** *

* Any information found outside of a table by Amazon Textract. *

*

* 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 #hasSummaryFields} method. *

* * @return Any information found outside of a table by Amazon Textract. */ public final List summaryFields() { return summaryFields; } /** * For responses, this returns true if the service returned a value for the LineItemGroups 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 hasLineItemGroups() { return lineItemGroups != null && !(lineItemGroups instanceof SdkAutoConstructList); } /** *

* Information detected on each table of a document, seperated into LineItems. *

*

* 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 #hasLineItemGroups} method. *

* * @return Information detected on each table of a document, seperated into LineItems. */ public final List lineItemGroups() { return lineItemGroups; } /** * For responses, this returns true if the service returned a value for the Blocks 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 hasBlocks() { return blocks != null && !(blocks instanceof SdkAutoConstructList); } /** *

* This is a block object, the same as reported when DetectDocumentText is run on a document. It provides word level * recognition of text. *

*

* 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 #hasBlocks} method. *

* * @return This is a block object, the same as reported when DetectDocumentText is run on a document. It provides * word level recognition of text. */ public final List blocks() { return blocks; } @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 + Objects.hashCode(expenseIndex()); hashCode = 31 * hashCode + Objects.hashCode(hasSummaryFields() ? summaryFields() : null); hashCode = 31 * hashCode + Objects.hashCode(hasLineItemGroups() ? lineItemGroups() : null); hashCode = 31 * hashCode + Objects.hashCode(hasBlocks() ? blocks() : null); return hashCode; } @Override public final boolean equals(Object obj) { return equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof ExpenseDocument)) { return false; } ExpenseDocument other = (ExpenseDocument) obj; return Objects.equals(expenseIndex(), other.expenseIndex()) && hasSummaryFields() == other.hasSummaryFields() && Objects.equals(summaryFields(), other.summaryFields()) && hasLineItemGroups() == other.hasLineItemGroups() && Objects.equals(lineItemGroups(), other.lineItemGroups()) && hasBlocks() == other.hasBlocks() && Objects.equals(blocks(), other.blocks()); } /** * 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("ExpenseDocument").add("ExpenseIndex", expenseIndex()) .add("SummaryFields", hasSummaryFields() ? summaryFields() : null) .add("LineItemGroups", hasLineItemGroups() ? lineItemGroups() : null) .add("Blocks", hasBlocks() ? blocks() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "ExpenseIndex": return Optional.ofNullable(clazz.cast(expenseIndex())); case "SummaryFields": return Optional.ofNullable(clazz.cast(summaryFields())); case "LineItemGroups": return Optional.ofNullable(clazz.cast(lineItemGroups())); case "Blocks": return Optional.ofNullable(clazz.cast(blocks())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((ExpenseDocument) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* Denotes which invoice or receipt in the document the information is coming from. First document will be 1, * the second 2, and so on. *

* * @param expenseIndex * Denotes which invoice or receipt in the document the information is coming from. First document will * be 1, the second 2, and so on. * @return Returns a reference to this object so that method calls can be chained together. */ Builder expenseIndex(Integer expenseIndex); /** *

* Any information found outside of a table by Amazon Textract. *

* * @param summaryFields * Any information found outside of a table by Amazon Textract. * @return Returns a reference to this object so that method calls can be chained together. */ Builder summaryFields(Collection summaryFields); /** *

* Any information found outside of a table by Amazon Textract. *

* * @param summaryFields * Any information found outside of a table by Amazon Textract. * @return Returns a reference to this object so that method calls can be chained together. */ Builder summaryFields(ExpenseField... summaryFields); /** *

* Any information found outside of a table by Amazon Textract. *

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

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

* Information detected on each table of a document, seperated into LineItems. *

* * @param lineItemGroups * Information detected on each table of a document, seperated into LineItems. * @return Returns a reference to this object so that method calls can be chained together. */ Builder lineItemGroups(Collection lineItemGroups); /** *

* Information detected on each table of a document, seperated into LineItems. *

* * @param lineItemGroups * Information detected on each table of a document, seperated into LineItems. * @return Returns a reference to this object so that method calls can be chained together. */ Builder lineItemGroups(LineItemGroup... lineItemGroups); /** *

* Information detected on each table of a document, seperated into LineItems. *

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

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

* This is a block object, the same as reported when DetectDocumentText is run on a document. It provides word * level recognition of text. *

* * @param blocks * This is a block object, the same as reported when DetectDocumentText is run on a document. It provides * word level recognition of text. * @return Returns a reference to this object so that method calls can be chained together. */ Builder blocks(Collection blocks); /** *

* This is a block object, the same as reported when DetectDocumentText is run on a document. It provides word * level recognition of text. *

* * @param blocks * This is a block object, the same as reported when DetectDocumentText is run on a document. It provides * word level recognition of text. * @return Returns a reference to this object so that method calls can be chained together. */ Builder blocks(Block... blocks); /** *

* This is a block object, the same as reported when DetectDocumentText is run on a document. It provides word * level recognition of text. *

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

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.textract.model.Block.Builder#build()} is called immediately and its * result is passed to {@link #blocks(List)}. * * @param blocks * a consumer that will call methods on * {@link software.amazon.awssdk.services.textract.model.Block.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #blocks(java.util.Collection) */ Builder blocks(Consumer... blocks); } static final class BuilderImpl implements Builder { private Integer expenseIndex; private List summaryFields = DefaultSdkAutoConstructList.getInstance(); private List lineItemGroups = DefaultSdkAutoConstructList.getInstance(); private List blocks = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(ExpenseDocument model) { expenseIndex(model.expenseIndex); summaryFields(model.summaryFields); lineItemGroups(model.lineItemGroups); blocks(model.blocks); } public final Integer getExpenseIndex() { return expenseIndex; } public final void setExpenseIndex(Integer expenseIndex) { this.expenseIndex = expenseIndex; } @Override public final Builder expenseIndex(Integer expenseIndex) { this.expenseIndex = expenseIndex; return this; } public final List getSummaryFields() { List result = ExpenseFieldListCopier.copyToBuilder(this.summaryFields); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setSummaryFields(Collection summaryFields) { this.summaryFields = ExpenseFieldListCopier.copyFromBuilder(summaryFields); } @Override public final Builder summaryFields(Collection summaryFields) { this.summaryFields = ExpenseFieldListCopier.copy(summaryFields); return this; } @Override @SafeVarargs public final Builder summaryFields(ExpenseField... summaryFields) { summaryFields(Arrays.asList(summaryFields)); return this; } @Override @SafeVarargs public final Builder summaryFields(Consumer... summaryFields) { summaryFields(Stream.of(summaryFields).map(c -> ExpenseField.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final List getLineItemGroups() { List result = LineItemGroupListCopier.copyToBuilder(this.lineItemGroups); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setLineItemGroups(Collection lineItemGroups) { this.lineItemGroups = LineItemGroupListCopier.copyFromBuilder(lineItemGroups); } @Override public final Builder lineItemGroups(Collection lineItemGroups) { this.lineItemGroups = LineItemGroupListCopier.copy(lineItemGroups); return this; } @Override @SafeVarargs public final Builder lineItemGroups(LineItemGroup... lineItemGroups) { lineItemGroups(Arrays.asList(lineItemGroups)); return this; } @Override @SafeVarargs public final Builder lineItemGroups(Consumer... lineItemGroups) { lineItemGroups(Stream.of(lineItemGroups).map(c -> LineItemGroup.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final List getBlocks() { List result = BlockListCopier.copyToBuilder(this.blocks); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setBlocks(Collection blocks) { this.blocks = BlockListCopier.copyFromBuilder(blocks); } @Override public final Builder blocks(Collection blocks) { this.blocks = BlockListCopier.copy(blocks); return this; } @Override @SafeVarargs public final Builder blocks(Block... blocks) { blocks(Arrays.asList(blocks)); return this; } @Override @SafeVarargs public final Builder blocks(Consumer... blocks) { blocks(Stream.of(blocks).map(c -> Block.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } @Override public ExpenseDocument build() { return new ExpenseDocument(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy