
software.amazon.awssdk.services.dynamodb.model.ItemCollectionMetrics Maven / Gradle / Ivy
/*
* 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 software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.protocol.ProtocolMarshaller;
import software.amazon.awssdk.core.protocol.StructuredPojo;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.services.dynamodb.transform.ItemCollectionMetricsMarshaller;
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;
/**
*
* Information about item collections, if any, that were affected by the operation. ItemCollectionMetrics
* is only returned if the request asked for it. If the table does not have any local secondary indexes, this
* information is not returned in the response.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ItemCollectionMetrics implements StructuredPojo,
ToCopyableBuilder {
private final Map itemCollectionKey;
private final List sizeEstimateRangeGB;
private ItemCollectionMetrics(BuilderImpl builder) {
this.itemCollectionKey = builder.itemCollectionKey;
this.sizeEstimateRangeGB = builder.sizeEstimateRangeGB;
}
/**
*
* The partition key value of the item collection. This value is the same as the partition key value of the item.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return The partition key value of the item collection. This value is the same as the partition key value of the
* item.
*/
public Map itemCollectionKey() {
return itemCollectionKey;
}
/**
*
* An estimate of item collection size, in gigabytes. This value is a two-element array containing a lower bound and
* an upper bound for the estimate. The estimate includes the size of all the items in the table, plus the size of
* all attributes projected into all of the local secondary indexes on that table. Use this estimate to measure
* whether a local secondary index is approaching its size limit.
*
*
* The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of the estimate.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return An estimate of item collection size, in gigabytes. This value is a two-element array containing a lower
* bound and an upper bound for the estimate. The estimate includes the size of all the items in the table,
* plus the size of all attributes projected into all of the local secondary indexes on that table. Use this
* estimate to measure whether a local secondary index is approaching its size limit.
*
* The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of the
* estimate.
*/
public List sizeEstimateRangeGB() {
return sizeEstimateRangeGB;
}
@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 int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(itemCollectionKey());
hashCode = 31 * hashCode + Objects.hashCode(sizeEstimateRangeGB());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ItemCollectionMetrics)) {
return false;
}
ItemCollectionMetrics other = (ItemCollectionMetrics) obj;
return Objects.equals(itemCollectionKey(), other.itemCollectionKey())
&& Objects.equals(sizeEstimateRangeGB(), other.sizeEstimateRangeGB());
}
@Override
public String toString() {
return ToString.builder("ItemCollectionMetrics").add("ItemCollectionKey", itemCollectionKey())
.add("SizeEstimateRangeGB", sizeEstimateRangeGB()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ItemCollectionKey":
return Optional.ofNullable(clazz.cast(itemCollectionKey()));
case "SizeEstimateRangeGB":
return Optional.ofNullable(clazz.cast(sizeEstimateRangeGB()));
default:
return Optional.empty();
}
}
@SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
ItemCollectionMetricsMarshaller.getInstance().marshall(this, protocolMarshaller);
}
public interface Builder extends CopyableBuilder {
/**
*
* The partition key value of the item collection. This value is the same as the partition key value of the
* item.
*
*
* @param itemCollectionKey
* The partition key value of the item collection. This value is the same as the partition key value of
* the item.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder itemCollectionKey(Map itemCollectionKey);
/**
*
* An estimate of item collection size, in gigabytes. This value is a two-element array containing a lower bound
* and an upper bound for the estimate. The estimate includes the size of all the items in the table, plus the
* size of all attributes projected into all of the local secondary indexes on that table. Use this estimate to
* measure whether a local secondary index is approaching its size limit.
*
*
* The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of the
* estimate.
*
*
* @param sizeEstimateRangeGB
* An estimate of item collection size, in gigabytes. This value is a two-element array containing a
* lower bound and an upper bound for the estimate. The estimate includes the size of all the items in
* the table, plus the size of all attributes projected into all of the local secondary indexes on that
* table. Use this estimate to measure whether a local secondary index is approaching its size limit.
*
* The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of
* the estimate.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder sizeEstimateRangeGB(Collection sizeEstimateRangeGB);
/**
*
* An estimate of item collection size, in gigabytes. This value is a two-element array containing a lower bound
* and an upper bound for the estimate. The estimate includes the size of all the items in the table, plus the
* size of all attributes projected into all of the local secondary indexes on that table. Use this estimate to
* measure whether a local secondary index is approaching its size limit.
*
*
* The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of the
* estimate.
*
*
* @param sizeEstimateRangeGB
* An estimate of item collection size, in gigabytes. This value is a two-element array containing a
* lower bound and an upper bound for the estimate. The estimate includes the size of all the items in
* the table, plus the size of all attributes projected into all of the local secondary indexes on that
* table. Use this estimate to measure whether a local secondary index is approaching its size limit.
*
* The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of
* the estimate.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder sizeEstimateRangeGB(Double... sizeEstimateRangeGB);
}
static final class BuilderImpl implements Builder {
private Map itemCollectionKey = DefaultSdkAutoConstructMap.getInstance();
private List sizeEstimateRangeGB = DefaultSdkAutoConstructList.getInstance();
private BuilderImpl() {
}
private BuilderImpl(ItemCollectionMetrics model) {
itemCollectionKey(model.itemCollectionKey);
sizeEstimateRangeGB(model.sizeEstimateRangeGB);
}
public final Map getItemCollectionKey() {
return itemCollectionKey != null ? CollectionUtils.mapValues(itemCollectionKey, AttributeValue::toBuilder) : null;
}
@Override
public final Builder itemCollectionKey(Map itemCollectionKey) {
this.itemCollectionKey = ItemCollectionKeyAttributeMapCopier.copy(itemCollectionKey);
return this;
}
public final void setItemCollectionKey(Map itemCollectionKey) {
this.itemCollectionKey = ItemCollectionKeyAttributeMapCopier.copyFromBuilder(itemCollectionKey);
}
public final Collection getSizeEstimateRangeGB() {
return sizeEstimateRangeGB;
}
@Override
public final Builder sizeEstimateRangeGB(Collection sizeEstimateRangeGB) {
this.sizeEstimateRangeGB = ItemCollectionSizeEstimateRangeCopier.copy(sizeEstimateRangeGB);
return this;
}
@Override
@SafeVarargs
public final Builder sizeEstimateRangeGB(Double... sizeEstimateRangeGB) {
sizeEstimateRangeGB(Arrays.asList(sizeEstimateRangeGB));
return this;
}
public final void setSizeEstimateRangeGB(Collection sizeEstimateRangeGB) {
this.sizeEstimateRangeGB = ItemCollectionSizeEstimateRangeCopier.copy(sizeEstimateRangeGB);
}
@Override
public ItemCollectionMetrics build() {
return new ItemCollectionMetrics(this);
}
}
}