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

software.amazon.awssdk.enhanced.dynamodb.model.Page 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.enhanced.dynamodb.model;

import java.util.List;
import java.util.Map;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.annotations.ThreadSafe;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
import software.amazon.awssdk.utils.ToString;

/**
 * An immutable object that holds a page of queried or scanned results from DynamoDb.
 * 

* Contains a reference to the last evaluated key for the current page; see {@link #lastEvaluatedKey()} for more information. * @param The modelled type of the object that has been read. */ @SdkPublicApi @ThreadSafe public final class Page { private final List items; private final Map lastEvaluatedKey; private Page(List items, Map lastEvaluatedKey) { this.items = items; this.lastEvaluatedKey = lastEvaluatedKey; } /** * Static constructor for this object. * @param items A list of items to store for the page. * @param lastEvaluatedKey A 'lastEvaluatedKey' to store for the page. * @param The modelled type of the object that has been read. * @return A newly constructed {@link Page} object. */ public static Page create(List items, Map lastEvaluatedKey) { return new Page<>(items, lastEvaluatedKey); } /** * Static constructor for this object that sets a null 'lastEvaluatedKey' which indicates this is the final page * of results. * @param items A list of items to store for the page. * @param The modelled type of the object that has been read. * @return A newly constructed {@link Page} object. */ public static Page create(List items) { return new Page<>(items, null); } /** * Returns a page of mapped objects that represent records from a database query or scan. * @return A list of mapped objects. */ public List items() { return items; } /** * Returns the 'lastEvaluatedKey' that DynamoDb returned from the last page query or scan. This key can be used * to continue the query or scan if passed into a request. * @return The 'lastEvaluatedKey' from the last query or scan operation or null if the no more pages are available. */ public Map lastEvaluatedKey() { return lastEvaluatedKey; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Page page = (Page) o; if (items != null ? ! items.equals(page.items) : page.items != null) { return false; } return lastEvaluatedKey != null ? lastEvaluatedKey.equals(page.lastEvaluatedKey) : page.lastEvaluatedKey == null; } @Override public int hashCode() { int result = items != null ? items.hashCode() : 0; result = 31 * result + (lastEvaluatedKey != null ? lastEvaluatedKey.hashCode() : 0); return result; } @Override public String toString() { return ToString.builder("Page") .add("lastEvaluatedKey", lastEvaluatedKey) .add("items", items) .build(); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy