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

software.amazon.awssdk.services.dynamodb.model.BatchGetItemResponse Maven / Gradle / Ivy

Go to download

A single bundled dependency that includes all service and dependent JARs with third-party libraries relocated to different namespaces.

There is a newer version: 2.5.20
Show newest version
/*
 * Copyright 2013-2018 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.dynamodb.model;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.utils.CollectionUtils;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* Represents the output of a BatchGetItem operation. *

*/ @Generated("software.amazon.awssdk:codegen") public final class BatchGetItemResponse extends DynamoDbResponse implements ToCopyableBuilder { private final Map>> responses; private final Map unprocessedKeys; private final List consumedCapacity; private BatchGetItemResponse(BuilderImpl builder) { super(builder); this.responses = builder.responses; this.unprocessedKeys = builder.unprocessedKeys; this.consumedCapacity = builder.consumedCapacity; } /** *

* A map of table name to a list of items. Each object in Responses consists of a table name, along * with a map of attribute data consisting of the data type and attribute value. *

*

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

* * @return A map of table name to a list of items. Each object in Responses consists of a table name, * along with a map of attribute data consisting of the data type and attribute value. */ public Map>> responses() { return responses; } /** *

* A map of tables and their respective keys that were not processed with the current response. The * UnprocessedKeys value is in the same form as RequestItems, so the value can be provided * directly to a subsequent BatchGetItem operation. For more information, see RequestItems * in the Request Parameters section. *

*

* Each element consists of: *

*
    *
  • *

    * Keys - An array of primary key attribute values that define specific items in the table. *

    *
  • *
  • *

    * ProjectionExpression - One or more attributes to be retrieved from the table or index. By default, * all attributes are returned. If a requested attribute is not found, it does not appear in the result. *

    *
  • *
  • *

    * ConsistentRead - The consistency of a read operation. If set to true, then a strongly * consistent read is used; otherwise, an eventually consistent read is used. *

    *
  • *
*

* If there are no unprocessed keys remaining, the response contains an empty UnprocessedKeys map. *

*

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

* * @return A map of tables and their respective keys that were not processed with the current response. The * UnprocessedKeys value is in the same form as RequestItems, so the value can be * provided directly to a subsequent BatchGetItem operation. For more information, see * RequestItems in the Request Parameters section.

*

* Each element consists of: *

*
    *
  • *

    * Keys - An array of primary key attribute values that define specific items in the table. *

    *
  • *
  • *

    * ProjectionExpression - One or more attributes to be retrieved from the table or index. By * default, all attributes are returned. If a requested attribute is not found, it does not appear in the * result. *

    *
  • *
  • *

    * ConsistentRead - The consistency of a read operation. If set to true, then a * strongly consistent read is used; otherwise, an eventually consistent read is used. *

    *
  • *
*

* If there are no unprocessed keys remaining, the response contains an empty UnprocessedKeys * map. */ public Map unprocessedKeys() { return unprocessedKeys; } /** *

* The read capacity units consumed by the entire BatchGetItem operation. *

*

* Each element consists of: *

*
    *
  • *

    * TableName - The table that consumed the provisioned throughput. *

    *
  • *
  • *

    * CapacityUnits - The total number of capacity units consumed. *

    *
  • *
*

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

* * @return The read capacity units consumed by the entire BatchGetItem operation.

*

* Each element consists of: *

*
    *
  • *

    * TableName - The table that consumed the provisioned throughput. *

    *
  • *
  • *

    * CapacityUnits - The total number of capacity units consumed. *

    *
  • */ public List consumedCapacity() { return consumedCapacity; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(responses()); hashCode = 31 * hashCode + Objects.hashCode(unprocessedKeys()); hashCode = 31 * hashCode + Objects.hashCode(consumedCapacity()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof BatchGetItemResponse)) { return false; } BatchGetItemResponse other = (BatchGetItemResponse) obj; return Objects.equals(responses(), other.responses()) && Objects.equals(unprocessedKeys(), other.unprocessedKeys()) && Objects.equals(consumedCapacity(), other.consumedCapacity()); } @Override public String toString() { return ToString.builder("BatchGetItemResponse").add("Responses", responses()).add("UnprocessedKeys", unprocessedKeys()) .add("ConsumedCapacity", consumedCapacity()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "Responses": return Optional.ofNullable(clazz.cast(responses())); case "UnprocessedKeys": return Optional.ofNullable(clazz.cast(unprocessedKeys())); case "ConsumedCapacity": return Optional.ofNullable(clazz.cast(consumedCapacity())); default: return Optional.empty(); } } public interface Builder extends DynamoDbResponse.Builder, CopyableBuilder { /** *

    * A map of table name to a list of items. Each object in Responses consists of a table name, along * with a map of attribute data consisting of the data type and attribute value. *

    * * @param responses * A map of table name to a list of items. Each object in Responses consists of a table * name, along with a map of attribute data consisting of the data type and attribute value. * @return Returns a reference to this object so that method calls can be chained together. */ Builder responses(Map>> responses); /** *

    * A map of tables and their respective keys that were not processed with the current response. The * UnprocessedKeys value is in the same form as RequestItems, so the value can be * provided directly to a subsequent BatchGetItem operation. For more information, see * RequestItems in the Request Parameters section. *

    *

    * Each element consists of: *

    *
      *
    • *

      * Keys - An array of primary key attribute values that define specific items in the table. *

      *
    • *
    • *

      * ProjectionExpression - One or more attributes to be retrieved from the table or index. By * default, all attributes are returned. If a requested attribute is not found, it does not appear in the * result. *

      *
    • *
    • *

      * ConsistentRead - The consistency of a read operation. If set to true, then a * strongly consistent read is used; otherwise, an eventually consistent read is used. *

      *
    • *
    *

    * If there are no unprocessed keys remaining, the response contains an empty UnprocessedKeys map. *

    * * @param unprocessedKeys * A map of tables and their respective keys that were not processed with the current response. The * UnprocessedKeys value is in the same form as RequestItems, so the value can * be provided directly to a subsequent BatchGetItem operation. For more information, see * RequestItems in the Request Parameters section.

    *

    * Each element consists of: *

    *
      *
    • *

      * Keys - An array of primary key attribute values that define specific items in the table. *

      *
    • *
    • *

      * ProjectionExpression - One or more attributes to be retrieved from the table or index. By * default, all attributes are returned. If a requested attribute is not found, it does not appear in the * result. *

      *
    • *
    • *

      * ConsistentRead - The consistency of a read operation. If set to true, then a * strongly consistent read is used; otherwise, an eventually consistent read is used. *

      *
    • *
    *

    * If there are no unprocessed keys remaining, the response contains an empty * UnprocessedKeys map. * @return Returns a reference to this object so that method calls can be chained together. */ Builder unprocessedKeys(Map unprocessedKeys); /** *

    * The read capacity units consumed by the entire BatchGetItem operation. *

    *

    * Each element consists of: *

    *
      *
    • *

      * TableName - The table that consumed the provisioned throughput. *

      *
    • *
    • *

      * CapacityUnits - The total number of capacity units consumed. *

      *
    • *
    * * @param consumedCapacity * The read capacity units consumed by the entire BatchGetItem operation.

    *

    * Each element consists of: *

    *
      *
    • *

      * TableName - The table that consumed the provisioned throughput. *

      *
    • *
    • *

      * CapacityUnits - The total number of capacity units consumed. *

      *
    • * @return Returns a reference to this object so that method calls can be chained together. */ Builder consumedCapacity(Collection consumedCapacity); /** *

      * The read capacity units consumed by the entire BatchGetItem operation. *

      *

      * Each element consists of: *

      *
        *
      • *

        * TableName - The table that consumed the provisioned throughput. *

        *
      • *
      • *

        * CapacityUnits - The total number of capacity units consumed. *

        *
      • *
      * * @param consumedCapacity * The read capacity units consumed by the entire BatchGetItem operation.

      *

      * Each element consists of: *

      *
        *
      • *

        * TableName - The table that consumed the provisioned throughput. *

        *
      • *
      • *

        * CapacityUnits - The total number of capacity units consumed. *

        *
      • * @return Returns a reference to this object so that method calls can be chained together. */ Builder consumedCapacity(ConsumedCapacity... consumedCapacity); /** *

        * The read capacity units consumed by the entire BatchGetItem operation. *

        *

        * Each element consists of: *

        *
          *
        • *

          * TableName - The table that consumed the provisioned throughput. *

          *
        • *
        • *

          * CapacityUnits - The total number of capacity units consumed. *

          *
        • *
        * This is a convenience that creates an instance of the {@link List.Builder} avoiding the * need to create one manually via {@link List#builder()}. * * When the {@link Consumer} completes, {@link List.Builder#build()} is called immediately and * its result is passed to {@link #consumedCapacity(List)}. * * @param consumedCapacity * a consumer that will call methods on {@link List.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #consumedCapacity(List) */ Builder consumedCapacity(Consumer... consumedCapacity); } static final class BuilderImpl extends DynamoDbResponse.BuilderImpl implements Builder { private Map>> responses = DefaultSdkAutoConstructMap.getInstance(); private Map unprocessedKeys = DefaultSdkAutoConstructMap.getInstance(); private List consumedCapacity = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(BatchGetItemResponse model) { super(model); responses(model.responses); unprocessedKeys(model.unprocessedKeys); consumedCapacity(model.consumedCapacity); } public final Map>> getResponses() { return responses; } @Override public final Builder responses(Map>> responses) { this.responses = BatchGetResponseMapCopier.copy(responses); return this; } public final void setResponses(Map>> responses) { this.responses = BatchGetResponseMapCopier.copy(responses); } public final Map getUnprocessedKeys() { return unprocessedKeys != null ? CollectionUtils.mapValues(unprocessedKeys, KeysAndAttributes::toBuilder) : null; } @Override public final Builder unprocessedKeys(Map unprocessedKeys) { this.unprocessedKeys = BatchGetRequestMapCopier.copy(unprocessedKeys); return this; } public final void setUnprocessedKeys(Map unprocessedKeys) { this.unprocessedKeys = BatchGetRequestMapCopier.copyFromBuilder(unprocessedKeys); } public final Collection getConsumedCapacity() { return consumedCapacity != null ? consumedCapacity.stream().map(ConsumedCapacity::toBuilder) .collect(Collectors.toList()) : null; } @Override public final Builder consumedCapacity(Collection consumedCapacity) { this.consumedCapacity = ConsumedCapacityMultipleCopier.copy(consumedCapacity); return this; } @Override @SafeVarargs public final Builder consumedCapacity(ConsumedCapacity... consumedCapacity) { consumedCapacity(Arrays.asList(consumedCapacity)); return this; } @Override @SafeVarargs public final Builder consumedCapacity(Consumer... consumedCapacity) { consumedCapacity(Stream.of(consumedCapacity).map(c -> ConsumedCapacity.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setConsumedCapacity(Collection consumedCapacity) { this.consumedCapacity = ConsumedCapacityMultipleCopier.copyFromBuilder(consumedCapacity); } @Override public BatchGetItemResponse build() { return new BatchGetItemResponse(this); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy