com.amazonaws.services.dynamodbv2.model.StreamRecord Maven / Gradle / Ivy
Show all versions of aws-java-sdk-dynamodb Show documentation
/*
* Copyright 2010-2016 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;
/**
*
* A description of a single data modification that was performed on an item in
* a DynamoDB table.
*
*/
public class StreamRecord implements Serializable, Cloneable {
/**
*
* 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 appears 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 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;
}
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. <p> 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;
}
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. <p> 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;
}
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. <p> 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 appears 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 appears 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 appears 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 appears 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 appears 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 appears 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 appears 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 appears 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) {
this.streamViewType = streamViewType.toString();
}
/**
*
* 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 appears 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 appears 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) {
setStreamViewType(streamViewType);
return this;
}
/**
* Returns a string representation of this object; useful for testing and
* debugging.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getKeys() != null)
sb.append("Keys: " + getKeys() + ",");
if (getNewImage() != null)
sb.append("NewImage: " + getNewImage() + ",");
if (getOldImage() != null)
sb.append("OldImage: " + getOldImage() + ",");
if (getSequenceNumber() != null)
sb.append("SequenceNumber: " + getSequenceNumber() + ",");
if (getSizeBytes() != null)
sb.append("SizeBytes: " + getSizeBytes() + ",");
if (getStreamViewType() != null)
sb.append("StreamViewType: " + 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.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
+ ((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);
}
}
}