/* * Copyright 2010-2019 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; /** *

* 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. *

*/ public class AttributeValue implements Serializable { /** *

* 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 nULL; /** *

* An attribute of type Boolean. For example: *

*

* "BOOL": true *

*/ private Boolean bOOL; /** * Default constructor for AttributeValue object. Callers should use the * setter or fluent setter (with...) methods to initialize any additional * object members. */ public AttributeValue() { } /** * 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. For example: *

*

* "S": "Hello" *

*/ 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. For example: *

*

* "SS": ["Giraffe", "Hippo" ,"Zebra"] *

*/ public AttributeValue(java.util.List sS) { setSS(sS); } /** *

* An attribute of type String. For example: *

*

* "S": "Hello" *

* * @return

* An attribute of type String. For example: *

*

* "S": "Hello" *

*/ public String getS() { return s; } /** *

* An attribute of type String. For example: *

*

* "S": "Hello" *

* * @param s

* An attribute of type String. For example: *

*

* "S": "Hello" *

*/ public void setS(String s) { this.s = s; } /** *

* An attribute of type String. For example: *

*

* "S": "Hello" *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param s

* An attribute of type String. For example: *

*

* "S": "Hello" *

* @return A reference to this updated object so that method calls can be * chained together. */ public AttributeValue withS(String s) { this.s = 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. *

* * @return

* 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. *

*/ public String getN() { return 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. 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. *

*/ 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. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param 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 A reference to this updated object so that method calls can be * chained together. */ public AttributeValue withN(String n) { this.n = n; return this; } /** *

* An attribute of type Binary. For example: *

*

* "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk" *

* * @return

* An attribute of type Binary. For example: *

*

* "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk" *

*/ public java.nio.ByteBuffer getB() { return b; } /** *

* An attribute of type Binary. For example: *

*

* "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk" *

* * @param b

* An attribute of type Binary. For example: *

*

* "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk" *

*/ public void setB(java.nio.ByteBuffer b) { this.b = b; } /** *

* An attribute of type Binary. For example: *

*

* "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk" *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param b

* An attribute of type Binary. For example: *

*

* "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk" *

* @return A reference to this updated object so that method calls can be * chained together. */ public AttributeValue withB(java.nio.ByteBuffer b) { this.b = b; return this; } /** *

* An attribute of type String Set. For example: *

*

* "SS": ["Giraffe", "Hippo" ,"Zebra"] *

* * @return

* An attribute of type String Set. For example: *

*

* "SS": ["Giraffe", "Hippo" ,"Zebra"] *

*/ 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. For example: *

*

* "SS": ["Giraffe", "Hippo" ,"Zebra"] *

*/ public void setSS(java.util.Collection sS) { if (sS == null) { this.sS = null; return; } this.sS = new java.util.ArrayList(sS); } /** *

* An attribute of type String Set. For example: *

*

* "SS": ["Giraffe", "Hippo" ,"Zebra"] *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param sS

* An attribute of type String Set. For example: *

*

* "SS": ["Giraffe", "Hippo" ,"Zebra"] *

* @return A reference to this updated object so that method calls can be * chained together. */ public AttributeValue withSS(String... sS) { if (getSS() == null) { this.sS = new java.util.ArrayList(sS.length); } for (String value : sS) { this.sS.add(value); } return this; } /** *

* An attribute of type String Set. For example: *

*

* "SS": ["Giraffe", "Hippo" ,"Zebra"] *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param sS

* An attribute of type String Set. For example: *

*

* "SS": ["Giraffe", "Hippo" ,"Zebra"] *

* @return A reference to this updated object so that method calls can be * chained together. */ public AttributeValue withSS(java.util.Collection 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. 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. *

*/ 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. 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. *

*/ public void setNS(java.util.Collection nS) { if (nS == null) { this.nS = null; return; } this.nS = new java.util.ArrayList(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. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param 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. *

* @return A reference to this updated object so that method calls can be * chained together. */ public AttributeValue withNS(String... nS) { if (getNS() == null) { this.nS = new java.util.ArrayList(nS.length); } for (String value : nS) { this.nS.add(value); } 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. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param 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. *

* @return A reference to this updated object so that method calls can be * chained together. */ public AttributeValue withNS(java.util.Collection nS) { setNS(nS); return this; } /** *

* An attribute of type Binary Set. For example: *

*

* "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="] *

* * @return

* An attribute of type Binary Set. For example: *

*

* "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="] *

*/ 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. For example: *

*

* "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="] *

*/ public void setBS(java.util.Collection bS) { if (bS == null) { this.bS = null; return; } this.bS = new java.util.ArrayList(bS); } /** *

* An attribute of type Binary Set. For example: *

*

* "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="] *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param bS

* An attribute of type Binary Set. For example: *

*

* "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="] *

* @return A reference to this updated object so that method calls can be * chained together. */ public AttributeValue withBS(java.nio.ByteBuffer... bS) { if (getBS() == null) { this.bS = new java.util.ArrayList(bS.length); } for (java.nio.ByteBuffer value : bS) { this.bS.add(value); } return this; } /** *

* An attribute of type Binary Set. For example: *

*

* "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="] *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param bS

* An attribute of type Binary Set. For example: *

*

* "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="] *

* @return A reference to this updated object so that method calls can be * chained together. */ public AttributeValue withBS(java.util.Collection 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. For example: *

*

* "M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}} *

*/ 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. For example: *

*

* "M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}} *

*/ public void setM(java.util.Map m) { this.m = m; } /** *

* An attribute of type Map. For example: *

*

* "M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}} *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param m

* An attribute of type Map. For example: *

*

* "M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}} *

* @return A reference to this updated object so that method calls can be * chained together. */ public AttributeValue withM(java.util.Map m) { this.m = m; return this; } /** *

* An attribute of type Map. For example: *

*

* "M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}} *

*

* The method adds a new key-value pair into M parameter, and returns a * reference to this object so that method calls can be chained together. * * @param key The key of the entry to be added into M. * @param value The corresponding value of the entry to be added into M. * @return A reference to this updated object so that method calls can be * chained together. */ 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. *

* 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. For example: *

*

* "L": ["Cookies", "Coffee", 3.14159] *

*/ 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. For example: *

*

* "L": ["Cookies", "Coffee", 3.14159] *

*/ public void setL(java.util.Collection l) { if (l == null) { this.l = null; return; } this.l = new java.util.ArrayList(l); } /** *

* An attribute of type List. For example: *

*

* "L": ["Cookies", "Coffee", 3.14159] *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param l

* An attribute of type List. For example: *

*

* "L": ["Cookies", "Coffee", 3.14159] *

* @return A reference to this updated object so that method calls can be * chained together. */ public AttributeValue withL(AttributeValue... l) { if (getL() == null) { this.l = new java.util.ArrayList(l.length); } for (AttributeValue value : l) { this.l.add(value); } return this; } /** *

* An attribute of type List. For example: *

*

* "L": ["Cookies", "Coffee", 3.14159] *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param l

* An attribute of type List. For example: *

*

* "L": ["Cookies", "Coffee", 3.14159] *

* @return A reference to this updated object so that method calls can be * chained together. */ public AttributeValue withL(java.util.Collection l) { setL(l); return this; } /** *

* An attribute of type Null. For example: *

*

* "NULL": true *

* * @return

* An attribute of type Null. For example: *

*

* "NULL": true *

*/ public Boolean isNULL() { return nULL; } /** *

* An attribute of type Null. For example: *

*

* "NULL": true *

* * @return

* An attribute of type Null. For example: *

*

* "NULL": true *

*/ public Boolean getNULL() { return nULL; } /** *

* An attribute of type Null. For example: *

*

* "NULL": true *

* * @param nULL

* An attribute of type Null. For example: *

*

* "NULL": true *

*/ public void setNULL(Boolean nULL) { this.nULL = nULL; } /** *

* An attribute of type Null. For example: *

*

* "NULL": true *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param nULL

* An attribute of type Null. For example: *

*

* "NULL": true *

* @return A reference to this updated object so that method calls can be * chained together. */ public AttributeValue withNULL(Boolean nULL) { this.nULL = nULL; return this; } /** *

* An attribute of type Boolean. For example: *

*

* "BOOL": true *

* * @return

* An attribute of type Boolean. For example: *

*

* "BOOL": true *

*/ public Boolean isBOOL() { return bOOL; } /** *

* An attribute of type Boolean. For example: *

*

* "BOOL": true *

* * @return

* An attribute of type Boolean. For example: *

*

* "BOOL": true *

*/ public Boolean getBOOL() { return bOOL; } /** *

* An attribute of type Boolean. For example: *

*

* "BOOL": true *

* * @param bOOL

* An attribute of type Boolean. For example: *

*

* "BOOL": true *

*/ public void setBOOL(Boolean bOOL) { this.bOOL = bOOL; } /** *

* An attribute of type Boolean. For example: *

*

* "BOOL": true *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param bOOL

* An attribute of type Boolean. For example: *

*

* "BOOL": true *

* @return A reference to this updated object so that method calls can be * chained together. */ public AttributeValue withBOOL(Boolean bOOL) { this.bOOL = bOOL; 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 (getS() != null) sb.append("S: " + getS() + ","); if (getN() != null) sb.append("N: " + getN() + ","); if (getB() != null) sb.append("B: " + getB() + ","); if (getSS() != null) sb.append("SS: " + getSS() + ","); if (getNS() != null) sb.append("NS: " + getNS() + ","); if (getBS() != null) sb.append("BS: " + getBS() + ","); if (getM() != null) sb.append("M: " + getM() + ","); if (getL() != null) sb.append("L: " + getL() + ","); if (getNULL() != null) sb.append("NULL: " + getNULL() + ","); if (getBOOL() != null) sb.append("BOOL: " + getBOOL()); sb.append("}"); return sb.toString(); } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getS() == null) ? 0 : getS().hashCode()); hashCode = prime * hashCode + ((getN() == null) ? 0 : getN().hashCode()); hashCode = prime * hashCode + ((getB() == null) ? 0 : getB().hashCode()); hashCode = prime * hashCode + ((getSS() == null) ? 0 : getSS().hashCode()); hashCode = prime * hashCode + ((getNS() == null) ? 0 : getNS().hashCode()); hashCode = prime * hashCode + ((getBS() == null) ? 0 : getBS().hashCode()); hashCode = prime * hashCode + ((getM() == null) ? 0 : getM().hashCode()); hashCode = prime * hashCode + ((getL() == null) ? 0 : getL().hashCode()); hashCode = prime * hashCode + ((getNULL() == null) ? 0 : getNULL().hashCode()); hashCode = prime * hashCode + ((getBOOL() == null) ? 0 : getBOOL().hashCode()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof AttributeValue == false) return false; AttributeValue other = (AttributeValue) obj; if (other.getS() == null ^ this.getS() == null) return false; if (other.getS() != null && other.getS().equals(this.getS()) == false) return false; if (other.getN() == null ^ this.getN() == null) return false; if (other.getN() != null && other.getN().equals(this.getN()) == false) return false; if (other.getB() == null ^ this.getB() == null) return false; if (other.getB() != null && other.getB().equals(this.getB()) == false) return false; if (other.getSS() == null ^ this.getSS() == null) return false; if (other.getSS() != null && other.getSS().equals(this.getSS()) == false) return false; if (other.getNS() == null ^ this.getNS() == null) return false; if (other.getNS() != null && other.getNS().equals(this.getNS()) == false) return false; if (other.getBS() == null ^ this.getBS() == null) return false; if (other.getBS() != null && other.getBS().equals(this.getBS()) == false) return false; if (other.getM() == null ^ this.getM() == null) return false; if (other.getM() != null && other.getM().equals(this.getM()) == false) return false; if (other.getL() == null ^ this.getL() == null) return false; if (other.getL() != null && other.getL().equals(this.getL()) == false) return false; if (other.getNULL() == null ^ this.getNULL() == null) return false; if (other.getNULL() != null && other.getNULL().equals(this.getNULL()) == false) return false; if (other.getBOOL() == null ^ this.getBOOL() == null) return false; if (other.getBOOL() != null && other.getBOOL().equals(this.getBOOL()) == false) return false; return true; } }