
lambdify.aws.events.dynamodb.AttributeValue Maven / Gradle / Ivy
/*
* Copyright 2012-2017 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 lambdify.aws.events.dynamodb;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;
/**
*
* Represents the data for an attribute.
*
*
* Each attribute value is described as a name-value pair. The name is the data type, and the value is the data itself.
*
*
* For more information, see Data Types in the Amazon DynamoDB Developer Guide.
*
*
* @see AWS API
* Documentation
*/
@NoArgsConstructor
@EqualsAndHashCode
@ToString
public class AttributeValue implements Serializable, Cloneable {
/**
*
* An attribute of type String. For example:
*
*
* "S": "Hello"
*
*/
private String s;
/**
*
* An attribute of type Number. For example:
*
*
* "N": "123.45"
*
*
* Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and
* libraries. However, DynamoDB treats them as number type attributes for mathematical operations.
*
*/
private String n;
/**
*
* An attribute of type Binary. For example:
*
*
* "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk"
*
*/
private java.nio.ByteBuffer b;
/**
*
* An attribute of type String Set. For example:
*
*
* "SS": ["Giraffe", "Hippo" ,"Zebra"]
*
*/
private java.util.List sS;
/**
*
* An attribute of type Number Set. For example:
*
*
* "NS": ["42.2", "-19", "7.5", "3.14"]
*
*
* Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and
* libraries. However, DynamoDB treats them as number type attributes for mathematical operations.
*
*/
private java.util.List nS;
/**
*
* An attribute of type Binary Set. For example:
*
*
* "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="]
*
*/
private java.util.List bS;
/**
*
* An attribute of type Map. For example:
*
*
* "M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}}
*
*/
private java.util.Map m;
/**
*
* An attribute of type List. For example:
*
*
* "L": ["Cookies", "Coffee", 3.14159]
*
*/
private java.util.List l;
/**
*
* An attribute of type Null. For example:
*
*
* "NULL": true
*
*/
private Boolean nULLValue;
/**
*
* An attribute of type Boolean. For example:
*
*
* "BOOL": true
*
*/
private Boolean bOOL;
/**
* Constructs a new AttributeValue object. Callers should use the setter or fluent setter (with...) methods to
* initialize any additional object members.
*
* @param s
* An attribute of type String.
*/
public AttributeValue(String s) {
setS(s);
}
/**
* Constructs a new AttributeValue object. Callers should use the setter or fluent setter (with...) methods to
* initialize any additional object members.
*
* @param sS
* An attribute of type String Set.
*/
public AttributeValue(java.util.List sS) {
setSS(sS);
}
/**
*
* An attribute of type String. For example:
*
*
* "S": "Hello"
*
*
* @param s
* An attribute of type String.
*/
@JsonProperty("S") public void setS(String s) {
this.s = s;
}
/**
*
* An attribute of type String. For example:
*
*
* "S": "Hello"
*
*
* @return An attribute of type String.
*/
@JsonProperty("S") public String getS() {
return this.s;
}
/**
*
* An attribute of type String. For example:
*
*
* "S": "Hello"
*
*
* @param s
* An attribute of type String.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AttributeValue withS(String s) {
setS(s);
return this;
}
/**
*
* An attribute of type Number. For example:
*
*
* "N": "123.45"
*
*
* Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and
* libraries. However, DynamoDB treats them as number type attributes for mathematical operations.
*
*
* @param n
* An attribute of type Number.
* Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and
* libraries. However, DynamoDB treats them as number type attributes for mathematical operations.
*/
@JsonProperty("N") public void setN(String n) {
this.n = n;
}
/**
*
* An attribute of type Number. For example:
*
*
* "N": "123.45"
*
*
* Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and
* libraries. However, DynamoDB treats them as number type attributes for mathematical operations.
*
*
* @return An attribute of type Number.
* Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages
* and libraries. However, DynamoDB treats them as number type attributes for mathematical operations.
*/
@JsonProperty("N") public String getN() {
return this.n;
}
/**
*
* An attribute of type Number. For example:
*
*
* "N": "123.45"
*
*
* Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and
* libraries. However, DynamoDB treats them as number type attributes for mathematical operations.
*
*
* @param n
* An attribute of type Number.
* Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and
* libraries. However, DynamoDB treats them as number type attributes for mathematical operations.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AttributeValue withN(String n) {
setN(n);
return this;
}
/**
*
* An attribute of type Binary. For example:
*
*
* "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk"
*
*
* The AWS SDK for Java performs a Base64 encoding on this field before sending this request to the AWS service.
* Users of the SDK should not perform Base64 encoding on this field.
*
*
* Warning: ByteBuffers returned by the SDK are mutable. Changes to the content or position of the byte buffer will
* be seen by all objects that have a reference to this object. It is recommended to call ByteBuffer.duplicate() or
* ByteBuffer.asReadOnlyBuffer() before using or reading from the buffer. This behavior will be changed in a future
* major version of the SDK.
*
*
* @param b
* An attribute of type Binary.
*/
@JsonProperty("B") public void setB(java.nio.ByteBuffer b) {
this.b = b;
}
/**
*
* An attribute of type Binary. For example:
*
*
* "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk"
*
*
* {@code ByteBuffer}s are stateful. Calling their {@code get} methods changes their {@code position}. We recommend
* using {@link java.nio.ByteBuffer#asReadOnlyBuffer()} to create a read-only view of the buffer with an independent
* {@code position}, and calling {@code get} methods on this rather than directly on the returned {@code ByteBuffer}.
* Doing so will ensure that anyone else using the {@code ByteBuffer} will not be affected by changes to the
* {@code position}.
*
*
* @return An attribute of type Binary.
*/
@JsonProperty("B") public java.nio.ByteBuffer getB() {
return this.b;
}
/**
*
* An attribute of type Binary. For example:
*
*
* "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk"
*
*
* The AWS SDK for Java performs a Base64 encoding on this field before sending this request to the AWS service.
* Users of the SDK should not perform Base64 encoding on this field.
*
*
* Warning: ByteBuffers returned by the SDK are mutable. Changes to the content or position of the byte buffer will
* be seen by all objects that have a reference to this object. It is recommended to call ByteBuffer.duplicate() or
* ByteBuffer.asReadOnlyBuffer() before using or reading from the buffer. This behavior will be changed in a future
* major version of the SDK.
*
*
* @param b
* An attribute of type Binary.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AttributeValue withB(java.nio.ByteBuffer b) {
setB(b);
return this;
}
/**
*
* An attribute of type String Set. For example:
*
*
* "SS": ["Giraffe", "Hippo" ,"Zebra"]
*
*
* @return An attribute of type String Set.
*/
@JsonProperty("SS") public java.util.List getSS() {
return sS;
}
/**
*
* An attribute of type String Set. For example:
*
*
* "SS": ["Giraffe", "Hippo" ,"Zebra"]
*
*
* @param sS
* An attribute of type String Set.
*/
@JsonProperty("SS") public void setSS(java.util.List sS) {
this.sS = null;
}
/**
*
* An attribute of type String Set. For example:
*
*
* "SS": ["Giraffe", "Hippo" ,"Zebra"]
*
*
* NOTE: This method appends the values to the existing list (if any). Use
* {@link #setSS(java.util.List)} or {@link #withSS(java.util.List)} if you want to override the
* existing values.
*
*
* @param sS
* An attribute of type String Set.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AttributeValue withSS(String... sS) {
if (this.sS == null) {
setSS(new java.util.ArrayList(sS.length));
}
for (String ele : sS) {
this.sS.add(ele);
}
return this;
}
/**
*
* An attribute of type String Set. For example:
*
*
* "SS": ["Giraffe", "Hippo" ,"Zebra"]
*
*
* @param sS
* An attribute of type String Set.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AttributeValue withSS(java.util.List sS) {
setSS(sS);
return this;
}
/**
*
* An attribute of type Number Set. For example:
*
*
* "NS": ["42.2", "-19", "7.5", "3.14"]
*
*
* Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and
* libraries. However, DynamoDB treats them as number type attributes for mathematical operations.
*
*
* @return An attribute of type Number Set.
* Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages
* and libraries. However, DynamoDB treats them as number type attributes for mathematical operations.
*/
@JsonProperty("NS") public java.util.List getNS() {
return nS;
}
/**
*
* An attribute of type Number Set. For example:
*
*
* "NS": ["42.2", "-19", "7.5", "3.14"]
*
*
* Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and
* libraries. However, DynamoDB treats them as number type attributes for mathematical operations.
*
*
* @param nS
* An attribute of type Number Set.
* Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and
* libraries. However, DynamoDB treats them as number type attributes for mathematical operations.
*/
@JsonProperty("NS") public void setNS(java.util.List nS) {
if ( nS == null ) {
this.nS = null;
return;
}
this.nS = nS;
}
/**
*
* An attribute of type Number Set. For example:
*
*
* "NS": ["42.2", "-19", "7.5", "3.14"]
*
*
* Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and
* libraries. However, DynamoDB treats them as number type attributes for mathematical operations.
*
*
* NOTE: This method appends the values to the existing list (if any). Use
* {@link #setNS(java.util.List)} or {@link #withNS(java.util.List)} if you want to override the
* existing values.
*
*
* @param nS
* An attribute of type Number Set.
* Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and
* libraries. However, DynamoDB treats them as number type attributes for mathematical operations.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AttributeValue withNS(String... nS) {
if (this.nS == null) {
setNS(new java.util.ArrayList(nS.length));
}
for (String ele : nS) {
this.nS.add(ele);
}
return this;
}
/**
*
* An attribute of type Number Set. For example:
*
*
* "NS": ["42.2", "-19", "7.5", "3.14"]
*
*
* Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and
* libraries. However, DynamoDB treats them as number type attributes for mathematical operations.
*
*
* @param nS
* An attribute of type Number Set.
* Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and
* libraries. However, DynamoDB treats them as number type attributes for mathematical operations.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AttributeValue withNS(java.util.List nS) {
setNS(nS);
return this;
}
/**
*
* An attribute of type Binary Set. For example:
*
*
* "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="]
*
*
* @return An attribute of type Binary Set.
*/
@JsonProperty("BS") public java.util.List getBS() {
return bS;
}
/**
*
* An attribute of type Binary Set. For example:
*
*
* "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="]
*
*
* @param bS
* An attribute of type Binary Set.
*/
@JsonProperty("BS") public void setBS(java.util.List bS) {
this.bS = bS;
}
/**
*
* An attribute of type Binary Set. For example:
*
*
* "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="]
*
*
* NOTE: This method appends the values to the existing list (if any). Use
* {@link #setBS(java.util.List)} or {@link #withBS(java.util.List)} if you want to override the
* existing values.
*
*
* @param bS
* An attribute of type Binary Set.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AttributeValue withBS(java.nio.ByteBuffer... bS) {
if (this.bS == null) {
setBS(new java.util.ArrayList(bS.length));
}
for (java.nio.ByteBuffer ele : bS) {
this.bS.add(ele);
}
return this;
}
/**
*
* An attribute of type Binary Set. For example:
*
*
* "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="]
*
*
* @param bS
* An attribute of type Binary Set.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AttributeValue withBS(java.util.List bS) {
setBS(bS);
return this;
}
/**
*
* An attribute of type Map. For example:
*
*
* "M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}}
*
*
* @return An attribute of type Map.
*/
@JsonProperty("M") public java.util.Map getM() {
return m;
}
/**
*
* An attribute of type Map. For example:
*
*
* "M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}}
*
*
* @param m
* An attribute of type Map.
*/
@JsonProperty("M") public void setM(java.util.Map m) {
this.m = m;
}
/**
*
* An attribute of type Map. For example:
*
*
* "M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}}
*
*
* @param m
* An attribute of type Map.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AttributeValue withM(java.util.Map m) {
setM(m);
return this;
}
public AttributeValue addMEntry(String key, AttributeValue value) {
if (null == this.m) {
this.m = new java.util.HashMap();
}
if (this.m.containsKey(key))
throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided.");
this.m.put(key, value);
return this;
}
/**
* Removes all the entries added into M.
*
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AttributeValue clearMEntries() {
this.m = null;
return this;
}
/**
*
* An attribute of type List. For example:
*
*
* "L": ["Cookies", "Coffee", 3.14159]
*
*
* @return An attribute of type List.
*/
@JsonProperty("L") public java.util.List getL() {
return l;
}
/**
*
* An attribute of type List. For example:
*
*
* "L": ["Cookies", "Coffee", 3.14159]
*
*
* @param l
* An attribute of type List.
*/
@JsonProperty("L") public void setL(java.util.List l) {
this.l = l;
}
/**
*
* An attribute of type List. For example:
*
*
* "L": ["Cookies", "Coffee", 3.14159]
*
*
* NOTE: This method appends the values to the existing list (if any). Use
* {@link #setL(java.util.List)} or {@link #withL(java.util.List)} if you want to override the existing
* values.
*
*
* @param l
* An attribute of type List.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AttributeValue withL(AttributeValue... l) {
if (this.l == null) {
setL(new java.util.ArrayList(l.length));
}
for (AttributeValue ele : l) {
this.l.add(ele);
}
return this;
}
/**
*
* An attribute of type List. For example:
*
*
* "L": ["Cookies", "Coffee", 3.14159]
*
*
* @param l
* An attribute of type List.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AttributeValue withL(java.util.List l) {
setL(l);
return this;
}
/**
*
* An attribute of type Null. For example:
*
*
* "NULL": true
*
*
* @param nULLValue
* An attribute of type Null.
*/
@JsonProperty("NULL") public void setNULL(Boolean nULLValue) {
this.nULLValue = nULLValue;
}
/**
*
* An attribute of type Null. For example:
*
*
* "NULL": true
*
*
* @return An attribute of type Null.
*/
@JsonProperty("NULL") public Boolean getNULL() {
return this.nULLValue;
}
/**
*
* An attribute of type Null. For example:
*
*
* "NULL": true
*
*
* @param nULLValue
* An attribute of type Null.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AttributeValue withNULL(Boolean nULLValue) {
setNULL(nULLValue);
return this;
}
/**
*
* An attribute of type Null. For example:
*
*
* "NULL": true
*
*
* @return An attribute of type Null.
*/
public Boolean isNULL() {
return this.nULLValue;
}
/**
*
* An attribute of type Boolean. For example:
*
*
* "BOOL": true
*
*
* @param bOOL
* An attribute of type Boolean.
*/
@JsonProperty("BOOL") public void setBOOL(Boolean bOOL) {
this.bOOL = bOOL;
}
/**
*
* An attribute of type Boolean. For example:
*
*
* "BOOL": true
*
*
* @return An attribute of type Boolean.
*/
@JsonProperty("BOOL") public Boolean getBOOL() {
return this.bOOL;
}
/**
*
* An attribute of type Boolean. For example:
*
*
* "BOOL": true
*
*
* @param bOOL
* An attribute of type Boolean.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AttributeValue withBOOL(Boolean bOOL) {
setBOOL(bOOL);
return this;
}
/**
*
* An attribute of type Boolean. For example:
*
*
* "BOOL": true
*
*
* @return An attribute of type Boolean.
*/
public Boolean isBOOL() {
return this.bOOL;
}
public static AttributeValue create(){
return new AttributeValue();
}
public static AttributeValue create( long number ) {
return create().withN( String.valueOf( number ) );
}
public static AttributeValue create( double number ) {
return create().withN( String.valueOf( number ) );
}
public static AttributeValue create( int number ) {
return create().withN( String.valueOf( number ) );
}
public static AttributeValue create( boolean bool ) {
return create().withBOOL( bool );
}
public static AttributeValue create( String str ) {
return create().withS( str );
}
}