
software.amazon.awssdk.services.dynamodb.model.StreamSpecification 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.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.services.dynamodb.transform.StreamSpecificationMarshaller;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Represents the DynamoDB Streams configuration for a table in DynamoDB.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class StreamSpecification implements StructuredPojo,
ToCopyableBuilder {
private final Boolean streamEnabled;
private final String streamViewType;
private StreamSpecification(BuilderImpl builder) {
this.streamEnabled = builder.streamEnabled;
this.streamViewType = builder.streamViewType;
}
/**
*
* Indicates whether DynamoDB Streams is enabled (true) or disabled (false) on the table.
*
*
* @return Indicates whether DynamoDB Streams is enabled (true) or disabled (false) on the table.
*/
public Boolean streamEnabled() {
return streamEnabled;
}
/**
*
* When an item in the table is modified, StreamViewType
determines what information is written to the
* stream for this table. Valid values for StreamViewType
are:
*
*
* -
*
* KEYS_ONLY
- Only the key attributes of the modified item are written to the stream.
*
*
* -
*
* NEW_IMAGE
- The entire item, as it appears after it was modified, is written to the stream.
*
*
* -
*
* OLD_IMAGE
- The entire item, as it appeared before it was modified, is written to the stream.
*
*
* -
*
* NEW_AND_OLD_IMAGES
- Both the new and the old item images of the item are written to the stream.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #streamViewType}
* will return {@link StreamViewType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #streamViewTypeAsString}.
*
*
* @return When an item in the table is modified, StreamViewType
determines what information is written
* to the stream for this table. Valid values for StreamViewType
are:
*
* -
*
* KEYS_ONLY
- Only the key attributes of the modified item are written to the stream.
*
*
* -
*
* NEW_IMAGE
- The entire item, as it appears after it was modified, is written to the stream.
*
*
* -
*
* OLD_IMAGE
- The entire item, as it appeared before it was modified, is written to the
* stream.
*
*
* -
*
* NEW_AND_OLD_IMAGES
- Both the new and the old item images of the item are written to the
* stream.
*
*
* @see StreamViewType
*/
public StreamViewType streamViewType() {
return StreamViewType.fromValue(streamViewType);
}
/**
*
* When an item in the table is modified, StreamViewType
determines what information is written to the
* stream for this table. Valid values for StreamViewType
are:
*
*
* -
*
* KEYS_ONLY
- Only the key attributes of the modified item are written to the stream.
*
*
* -
*
* NEW_IMAGE
- The entire item, as it appears after it was modified, is written to the stream.
*
*
* -
*
* OLD_IMAGE
- The entire item, as it appeared before it was modified, is written to the stream.
*
*
* -
*
* NEW_AND_OLD_IMAGES
- Both the new and the old item images of the item are written to the stream.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #streamViewType}
* will return {@link StreamViewType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #streamViewTypeAsString}.
*
*
* @return When an item in the table is modified, StreamViewType
determines what information is written
* to the stream for this table. Valid values for StreamViewType
are:
*
* -
*
* KEYS_ONLY
- Only the key attributes of the modified item are written to the stream.
*
*
* -
*
* NEW_IMAGE
- The entire item, as it appears after it was modified, is written to the stream.
*
*
* -
*
* OLD_IMAGE
- The entire item, as it appeared before it was modified, is written to the
* stream.
*
*
* -
*
* NEW_AND_OLD_IMAGES
- Both the new and the old item images of the item are written to the
* stream.
*
*
* @see StreamViewType
*/
public String streamViewTypeAsString() {
return streamViewType;
}
@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(streamEnabled());
hashCode = 31 * hashCode + Objects.hashCode(streamViewTypeAsString());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof StreamSpecification)) {
return false;
}
StreamSpecification other = (StreamSpecification) obj;
return Objects.equals(streamEnabled(), other.streamEnabled())
&& Objects.equals(streamViewTypeAsString(), other.streamViewTypeAsString());
}
@Override
public String toString() {
return ToString.builder("StreamSpecification").add("StreamEnabled", streamEnabled())
.add("StreamViewType", streamViewTypeAsString()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "StreamEnabled":
return Optional.ofNullable(clazz.cast(streamEnabled()));
case "StreamViewType":
return Optional.ofNullable(clazz.cast(streamViewTypeAsString()));
default:
return Optional.empty();
}
}
@SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
StreamSpecificationMarshaller.getInstance().marshall(this, protocolMarshaller);
}
public interface Builder extends CopyableBuilder {
/**
*
* Indicates whether DynamoDB Streams is enabled (true) or disabled (false) on the table.
*
*
* @param streamEnabled
* Indicates whether DynamoDB Streams is enabled (true) or disabled (false) on the table.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder streamEnabled(Boolean streamEnabled);
/**
*
* When an item in the table is modified, StreamViewType
determines what information is written to
* the stream for this table. Valid values for StreamViewType
are:
*
*
* -
*
* KEYS_ONLY
- Only the key attributes of the modified item are written to the stream.
*
*
* -
*
* NEW_IMAGE
- The entire item, as it appears after it was modified, is written to the stream.
*
*
* -
*
* OLD_IMAGE
- The entire item, as it appeared before it was modified, is written to the stream.
*
*
* -
*
* NEW_AND_OLD_IMAGES
- Both the new and the old item images of the item are written to the stream.
*
*
*
*
* @param streamViewType
* When an item in the table is modified, StreamViewType
determines what information is
* written to the stream for this table. Valid values for StreamViewType
are:
*
* -
*
* KEYS_ONLY
- Only the key attributes of the modified item are written to the stream.
*
*
* -
*
* NEW_IMAGE
- The entire item, as it appears after it was modified, is written to the
* stream.
*
*
* -
*
* OLD_IMAGE
- The entire item, as it appeared before it was modified, is written to the
* stream.
*
*
* -
*
* NEW_AND_OLD_IMAGES
- Both the new and the old item images of the item are written to the
* stream.
*
*
* @see StreamViewType
* @return Returns a reference to this object so that method calls can be chained together.
* @see StreamViewType
*/
Builder streamViewType(String streamViewType);
/**
*
* When an item in the table is modified, StreamViewType
determines what information is written to
* the stream for this table. Valid values for StreamViewType
are:
*
*
* -
*
* KEYS_ONLY
- Only the key attributes of the modified item are written to the stream.
*
*
* -
*
* NEW_IMAGE
- The entire item, as it appears after it was modified, is written to the stream.
*
*
* -
*
* OLD_IMAGE
- The entire item, as it appeared before it was modified, is written to the stream.
*
*
* -
*
* NEW_AND_OLD_IMAGES
- Both the new and the old item images of the item are written to the stream.
*
*
*
*
* @param streamViewType
* When an item in the table is modified, StreamViewType
determines what information is
* written to the stream for this table. Valid values for StreamViewType
are:
*
* -
*
* KEYS_ONLY
- Only the key attributes of the modified item are written to the stream.
*
*
* -
*
* NEW_IMAGE
- The entire item, as it appears after it was modified, is written to the
* stream.
*
*
* -
*
* OLD_IMAGE
- The entire item, as it appeared before it was modified, is written to the
* stream.
*
*
* -
*
* NEW_AND_OLD_IMAGES
- Both the new and the old item images of the item are written to the
* stream.
*
*
* @see StreamViewType
* @return Returns a reference to this object so that method calls can be chained together.
* @see StreamViewType
*/
Builder streamViewType(StreamViewType streamViewType);
}
static final class BuilderImpl implements Builder {
private Boolean streamEnabled;
private String streamViewType;
private BuilderImpl() {
}
private BuilderImpl(StreamSpecification model) {
streamEnabled(model.streamEnabled);
streamViewType(model.streamViewType);
}
public final Boolean getStreamEnabled() {
return streamEnabled;
}
@Override
public final Builder streamEnabled(Boolean streamEnabled) {
this.streamEnabled = streamEnabled;
return this;
}
public final void setStreamEnabled(Boolean streamEnabled) {
this.streamEnabled = streamEnabled;
}
public final String getStreamViewType() {
return streamViewType;
}
@Override
public final Builder streamViewType(String streamViewType) {
this.streamViewType = streamViewType;
return this;
}
@Override
public final Builder streamViewType(StreamViewType streamViewType) {
this.streamViewType(streamViewType.toString());
return this;
}
public final void setStreamViewType(String streamViewType) {
this.streamViewType = streamViewType;
}
@Override
public StreamSpecification build() {
return new StreamSpecification(this);
}
}
}