com.amazonaws.services.dynamodbv2.model.StreamRecord Maven / Gradle / Ivy
/*
* Copyright 2016-2021 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 com.amazonaws.services.dynamodbv2.model;
import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.protocol.StructuredPojo;
import com.amazonaws.protocol.ProtocolMarshaller;
/**
*
* A description of a single data modification that was performed on an item in a DynamoDB table.
*
*
* @see AWS API
* Documentation
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class StreamRecord implements Serializable, Cloneable, StructuredPojo {
/**
*
* The approximate date and time when the stream record was created, in UNIX epoch time format.
*
*/
private java.util.Date approximateCreationDateTime;
/**
*
* The primary key attribute(s) for the DynamoDB item that was modified.
*
*/
private java.util.Map keys;
/**
*
* The item in the DynamoDB table as it appeared after it was modified.
*
*/
private java.util.Map newImage;
/**
*
* The item in the DynamoDB table as it appeared before it was modified.
*
*/
private java.util.Map oldImage;
/**
*
* The sequence number of the stream record.
*
*/
private String sequenceNumber;
/**
*
* The size of the stream record, in bytes.
*
*/
private Long sizeBytes;
/**
*
* The type of data from the modified DynamoDB item that was captured in this stream record:
*
*
* -
*
* KEYS_ONLY
- only the key attributes of the modified item.
*
*
* -
*
* NEW_IMAGE
- the entire item, as it appeared after it was modified.
*
*
* -
*
* OLD_IMAGE
- the entire item, as it appeared before it was modified.
*
*
* -
*
* NEW_AND_OLD_IMAGES
- both the new and the old item images of the item.
*
*
*
*/
private String streamViewType;
/**
*
* The approximate date and time when the stream record was created, in UNIX epoch time format.
*
*
* @param approximateCreationDateTime
* The approximate date and time when the stream record was created, in UNIX epoch time format.
*/
public void setApproximateCreationDateTime(java.util.Date approximateCreationDateTime) {
this.approximateCreationDateTime = approximateCreationDateTime;
}
/**
*
* The approximate date and time when the stream record was created, in UNIX epoch time format.
*
*
* @return The approximate date and time when the stream record was created, in UNIX epoch time format.
*/
public java.util.Date getApproximateCreationDateTime() {
return this.approximateCreationDateTime;
}
/**
*
* The approximate date and time when the stream record was created, in UNIX epoch time format.
*
*
* @param approximateCreationDateTime
* The approximate date and time when the stream record was created, in UNIX epoch time format.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public StreamRecord withApproximateCreationDateTime(java.util.Date approximateCreationDateTime) {
setApproximateCreationDateTime(approximateCreationDateTime);
return this;
}
/**
*
* The primary key attribute(s) for the DynamoDB item that was modified.
*
*
* @return The primary key attribute(s) for the DynamoDB item that was modified.
*/
public java.util.Map getKeys() {
return keys;
}
/**
*
* The primary key attribute(s) for the DynamoDB item that was modified.
*
*
* @param keys
* The primary key attribute(s) for the DynamoDB item that was modified.
*/
public void setKeys(java.util.Map keys) {
this.keys = keys;
}
/**
*
* The primary key attribute(s) for the DynamoDB item that was modified.
*
*
* @param keys
* The primary key attribute(s) for the DynamoDB item that was modified.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public StreamRecord withKeys(java.util.Map keys) {
setKeys(keys);
return this;
}
/**
* Add a single Keys entry
*
* @see StreamRecord#withKeys
* @returns a reference to this object so that method calls can be chained together.
*/
public StreamRecord addKeysEntry(String key, AttributeValue value) {
if (null == this.keys) {
this.keys = new java.util.HashMap();
}
if (this.keys.containsKey(key))
throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided.");
this.keys.put(key, value);
return this;
}
/**
* Removes all the entries added into Keys.
*
* @return Returns a reference to this object so that method calls can be chained together.
*/
public StreamRecord clearKeysEntries() {
this.keys = null;
return this;
}
/**
*
* The item in the DynamoDB table as it appeared after it was modified.
*
*
* @return The item in the DynamoDB table as it appeared after it was modified.
*/
public java.util.Map getNewImage() {
return newImage;
}
/**
*
* The item in the DynamoDB table as it appeared after it was modified.
*
*
* @param newImage
* The item in the DynamoDB table as it appeared after it was modified.
*/
public void setNewImage(java.util.Map newImage) {
this.newImage = newImage;
}
/**
*
* The item in the DynamoDB table as it appeared after it was modified.
*
*
* @param newImage
* The item in the DynamoDB table as it appeared after it was modified.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public StreamRecord withNewImage(java.util.Map newImage) {
setNewImage(newImage);
return this;
}
/**
* Add a single NewImage entry
*
* @see StreamRecord#withNewImage
* @returns a reference to this object so that method calls can be chained together.
*/
public StreamRecord addNewImageEntry(String key, AttributeValue value) {
if (null == this.newImage) {
this.newImage = new java.util.HashMap();
}
if (this.newImage.containsKey(key))
throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided.");
this.newImage.put(key, value);
return this;
}
/**
* Removes all the entries added into NewImage.
*
* @return Returns a reference to this object so that method calls can be chained together.
*/
public StreamRecord clearNewImageEntries() {
this.newImage = null;
return this;
}
/**
*
* The item in the DynamoDB table as it appeared before it was modified.
*
*
* @return The item in the DynamoDB table as it appeared before it was modified.
*/
public java.util.Map getOldImage() {
return oldImage;
}
/**
*
* The item in the DynamoDB table as it appeared before it was modified.
*
*
* @param oldImage
* The item in the DynamoDB table as it appeared before it was modified.
*/
public void setOldImage(java.util.Map oldImage) {
this.oldImage = oldImage;
}
/**
*
* The item in the DynamoDB table as it appeared before it was modified.
*
*
* @param oldImage
* The item in the DynamoDB table as it appeared before it was modified.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public StreamRecord withOldImage(java.util.Map oldImage) {
setOldImage(oldImage);
return this;
}
/**
* Add a single OldImage entry
*
* @see StreamRecord#withOldImage
* @returns a reference to this object so that method calls can be chained together.
*/
public StreamRecord addOldImageEntry(String key, AttributeValue value) {
if (null == this.oldImage) {
this.oldImage = new java.util.HashMap();
}
if (this.oldImage.containsKey(key))
throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided.");
this.oldImage.put(key, value);
return this;
}
/**
* Removes all the entries added into OldImage.
*
* @return Returns a reference to this object so that method calls can be chained together.
*/
public StreamRecord clearOldImageEntries() {
this.oldImage = null;
return this;
}
/**
*
* The sequence number of the stream record.
*
*
* @param sequenceNumber
* The sequence number of the stream record.
*/
public void setSequenceNumber(String sequenceNumber) {
this.sequenceNumber = sequenceNumber;
}
/**
*
* The sequence number of the stream record.
*
*
* @return The sequence number of the stream record.
*/
public String getSequenceNumber() {
return this.sequenceNumber;
}
/**
*
* The sequence number of the stream record.
*
*
* @param sequenceNumber
* The sequence number of the stream record.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public StreamRecord withSequenceNumber(String sequenceNumber) {
setSequenceNumber(sequenceNumber);
return this;
}
/**
*
* The size of the stream record, in bytes.
*
*
* @param sizeBytes
* The size of the stream record, in bytes.
*/
public void setSizeBytes(Long sizeBytes) {
this.sizeBytes = sizeBytes;
}
/**
*
* The size of the stream record, in bytes.
*
*
* @return The size of the stream record, in bytes.
*/
public Long getSizeBytes() {
return this.sizeBytes;
}
/**
*
* The size of the stream record, in bytes.
*
*
* @param sizeBytes
* The size of the stream record, in bytes.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public StreamRecord withSizeBytes(Long sizeBytes) {
setSizeBytes(sizeBytes);
return this;
}
/**
*
* The type of data from the modified DynamoDB item that was captured in this stream record:
*
*
* -
*
* KEYS_ONLY
- only the key attributes of the modified item.
*
*
* -
*
* NEW_IMAGE
- the entire item, as it appeared after it was modified.
*
*
* -
*
* OLD_IMAGE
- the entire item, as it appeared before it was modified.
*
*
* -
*
* NEW_AND_OLD_IMAGES
- both the new and the old item images of the item.
*
*
*
*
* @param streamViewType
* The type of data from the modified DynamoDB item that was captured in this stream record:
*
* -
*
* KEYS_ONLY
- only the key attributes of the modified item.
*
*
* -
*
* NEW_IMAGE
- the entire item, as it appeared after it was modified.
*
*
* -
*
* OLD_IMAGE
- the entire item, as it appeared before it was modified.
*
*
* -
*
* NEW_AND_OLD_IMAGES
- both the new and the old item images of the item.
*
*
* @see StreamViewType
*/
public void setStreamViewType(String streamViewType) {
this.streamViewType = streamViewType;
}
/**
*
* The type of data from the modified DynamoDB item that was captured in this stream record:
*
*
* -
*
* KEYS_ONLY
- only the key attributes of the modified item.
*
*
* -
*
* NEW_IMAGE
- the entire item, as it appeared after it was modified.
*
*
* -
*
* OLD_IMAGE
- the entire item, as it appeared before it was modified.
*
*
* -
*
* NEW_AND_OLD_IMAGES
- both the new and the old item images of the item.
*
*
*
*
* @return The type of data from the modified DynamoDB item that was captured in this stream record:
*
* -
*
* KEYS_ONLY
- only the key attributes of the modified item.
*
*
* -
*
* NEW_IMAGE
- the entire item, as it appeared after it was modified.
*
*
* -
*
* OLD_IMAGE
- the entire item, as it appeared before it was modified.
*
*
* -
*
* NEW_AND_OLD_IMAGES
- both the new and the old item images of the item.
*
*
* @see StreamViewType
*/
public String getStreamViewType() {
return this.streamViewType;
}
/**
*
* The type of data from the modified DynamoDB item that was captured in this stream record:
*
*
* -
*
* KEYS_ONLY
- only the key attributes of the modified item.
*
*
* -
*
* NEW_IMAGE
- the entire item, as it appeared after it was modified.
*
*
* -
*
* OLD_IMAGE
- the entire item, as it appeared before it was modified.
*
*
* -
*
* NEW_AND_OLD_IMAGES
- both the new and the old item images of the item.
*
*
*
*
* @param streamViewType
* The type of data from the modified DynamoDB item that was captured in this stream record:
*
* -
*
* KEYS_ONLY
- only the key attributes of the modified item.
*
*
* -
*
* NEW_IMAGE
- the entire item, as it appeared after it was modified.
*
*
* -
*
* OLD_IMAGE
- the entire item, as it appeared before it was modified.
*
*
* -
*
* NEW_AND_OLD_IMAGES
- both the new and the old item images of the item.
*
*
* @return Returns a reference to this object so that method calls can be chained together.
* @see StreamViewType
*/
public StreamRecord withStreamViewType(String streamViewType) {
setStreamViewType(streamViewType);
return this;
}
/**
*
* The type of data from the modified DynamoDB item that was captured in this stream record:
*
*
* -
*
* KEYS_ONLY
- only the key attributes of the modified item.
*
*
* -
*
* NEW_IMAGE
- the entire item, as it appeared after it was modified.
*
*
* -
*
* OLD_IMAGE
- the entire item, as it appeared before it was modified.
*
*
* -
*
* NEW_AND_OLD_IMAGES
- both the new and the old item images of the item.
*
*
*
*
* @param streamViewType
* The type of data from the modified DynamoDB item that was captured in this stream record:
*
* -
*
* KEYS_ONLY
- only the key attributes of the modified item.
*
*
* -
*
* NEW_IMAGE
- the entire item, as it appeared after it was modified.
*
*
* -
*
* OLD_IMAGE
- the entire item, as it appeared before it was modified.
*
*
* -
*
* NEW_AND_OLD_IMAGES
- both the new and the old item images of the item.
*
*
* @see StreamViewType
*/
public void setStreamViewType(StreamViewType streamViewType) {
withStreamViewType(streamViewType);
}
/**
*
* The type of data from the modified DynamoDB item that was captured in this stream record:
*
*
* -
*
* KEYS_ONLY
- only the key attributes of the modified item.
*
*
* -
*
* NEW_IMAGE
- the entire item, as it appeared after it was modified.
*
*
* -
*
* OLD_IMAGE
- the entire item, as it appeared before it was modified.
*
*
* -
*
* NEW_AND_OLD_IMAGES
- both the new and the old item images of the item.
*
*
*
*
* @param streamViewType
* The type of data from the modified DynamoDB item that was captured in this stream record:
*
* -
*
* KEYS_ONLY
- only the key attributes of the modified item.
*
*
* -
*
* NEW_IMAGE
- the entire item, as it appeared after it was modified.
*
*
* -
*
* OLD_IMAGE
- the entire item, as it appeared before it was modified.
*
*
* -
*
* NEW_AND_OLD_IMAGES
- both the new and the old item images of the item.
*
*
* @return Returns a reference to this object so that method calls can be chained together.
* @see StreamViewType
*/
public StreamRecord withStreamViewType(StreamViewType streamViewType) {
this.streamViewType = streamViewType.toString();
return this;
}
/**
* 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.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getApproximateCreationDateTime() != null)
sb.append("ApproximateCreationDateTime: ").append(getApproximateCreationDateTime()).append(",");
if (getKeys() != null)
sb.append("Keys: ").append(getKeys()).append(",");
if (getNewImage() != null)
sb.append("NewImage: ").append(getNewImage()).append(",");
if (getOldImage() != null)
sb.append("OldImage: ").append(getOldImage()).append(",");
if (getSequenceNumber() != null)
sb.append("SequenceNumber: ").append(getSequenceNumber()).append(",");
if (getSizeBytes() != null)
sb.append("SizeBytes: ").append(getSizeBytes()).append(",");
if (getStreamViewType() != null)
sb.append("StreamViewType: ").append(getStreamViewType());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof StreamRecord == false)
return false;
StreamRecord other = (StreamRecord) obj;
if (other.getApproximateCreationDateTime() == null ^ this.getApproximateCreationDateTime() == null)
return false;
if (other.getApproximateCreationDateTime() != null && other.getApproximateCreationDateTime().equals(this.getApproximateCreationDateTime()) == false)
return false;
if (other.getKeys() == null ^ this.getKeys() == null)
return false;
if (other.getKeys() != null && other.getKeys().equals(this.getKeys()) == false)
return false;
if (other.getNewImage() == null ^ this.getNewImage() == null)
return false;
if (other.getNewImage() != null && other.getNewImage().equals(this.getNewImage()) == false)
return false;
if (other.getOldImage() == null ^ this.getOldImage() == null)
return false;
if (other.getOldImage() != null && other.getOldImage().equals(this.getOldImage()) == false)
return false;
if (other.getSequenceNumber() == null ^ this.getSequenceNumber() == null)
return false;
if (other.getSequenceNumber() != null && other.getSequenceNumber().equals(this.getSequenceNumber()) == false)
return false;
if (other.getSizeBytes() == null ^ this.getSizeBytes() == null)
return false;
if (other.getSizeBytes() != null && other.getSizeBytes().equals(this.getSizeBytes()) == false)
return false;
if (other.getStreamViewType() == null ^ this.getStreamViewType() == null)
return false;
if (other.getStreamViewType() != null && other.getStreamViewType().equals(this.getStreamViewType()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getApproximateCreationDateTime() == null) ? 0 : getApproximateCreationDateTime().hashCode());
hashCode = prime * hashCode + ((getKeys() == null) ? 0 : getKeys().hashCode());
hashCode = prime * hashCode + ((getNewImage() == null) ? 0 : getNewImage().hashCode());
hashCode = prime * hashCode + ((getOldImage() == null) ? 0 : getOldImage().hashCode());
hashCode = prime * hashCode + ((getSequenceNumber() == null) ? 0 : getSequenceNumber().hashCode());
hashCode = prime * hashCode + ((getSizeBytes() == null) ? 0 : getSizeBytes().hashCode());
hashCode = prime * hashCode + ((getStreamViewType() == null) ? 0 : getStreamViewType().hashCode());
return hashCode;
}
@Override
public StreamRecord clone() {
try {
return (StreamRecord) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
}
}
@com.amazonaws.annotation.SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
com.amazonaws.services.dynamodbv2.model.transform.StreamRecordMarshaller.getInstance().marshall(this, protocolMarshaller);
}
}