Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2015 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;
 

Represents the data for an attribute. You can set one, and only one, of the elements.

Each attribute in an item is a name-value pair. An attribute can be single-valued or multi-valued set. For example, a book item can have title and authors attributes. Each book has one title but can have many authors. The multi-valued attribute is a set; duplicate values are not allowed.

 
 public class AttributeValue implements SerializableCloneable {

    
A String data type.
 
     private String s;

    
A Number data type.
 
     private String n;

    
A Binary data type.
 
     private java.nio.ByteBuffer b;

    
A String Set data type.
 
A Number Set data type.
 
A Binary Set data type.
 
A Map of attribute values.
 
     private java.util.Map<String,AttributeValuem;

    
A List of attribute values.
 
A Null data type.
 
     private Boolean nULL;

    
A Boolean data type.
 
     private Boolean bOOL;

    
Default constructor for a new AttributeValue object. Callers should use the setter or fluent setter (with...) methods to initialize this object after creating it.
 
     public AttributeValue() {}
    
    
Constructs a new AttributeValue object. Callers should use the setter or fluent setter (with...) methods to initialize any additional object members.

Parameters:
s A String data type.
 
     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.

Parameters:
sS A String Set data type.
    public AttributeValue(java.util.List<StringsS) {
        setSS(sS);
    }

    
A String data type.

Returns:
A String data type.
    public String getS() {
        return ;
    }
    
    
A String data type.

Parameters:
s A String data type.
    public void setS(String s) {
        this. = s;
    }
    
    
A String data type.

Returns a reference to this object so that method calls can be chained together.

Parameters:
s A String data type.
Returns:
A reference to this updated object so that method calls can be chained together.
    public AttributeValue withS(String s) {
        this. = s;
        return this;
    }

    
A Number data type.

Returns:
A Number data type.
    public String getN() {
        return ;
    }
    
    
A Number data type.

Parameters:
n A Number data type.
    public void setN(String n) {
        this. = n;
    }
    
    
A Number data type.

Returns a reference to this object so that method calls can be chained together.

Parameters:
n A Number data type.
Returns:
A reference to this updated object so that method calls can be chained together.
    public AttributeValue withN(String n) {
        this. = n;
        return this;
    }

    
A Binary data type.

Returns:
A Binary data type.
    public java.nio.ByteBuffer getB() {
        return ;
    }
    
    
A Binary data type.

Parameters:
b A Binary data type.
    public void setB(java.nio.ByteBuffer b) {
        this. = b;
    }
    
    
A Binary data type.

Returns a reference to this object so that method calls can be chained together.

Parameters:
b A Binary data type.
Returns:
A reference to this updated object so that method calls can be chained together.
    public AttributeValue withB(java.nio.ByteBuffer b) {
        this. = b;
        return this;
    }

    
A String Set data type.

Returns:
A String Set data type.
    public java.util.List<StringgetSS() {
        return ;
    }
    
    
A String Set data type.

Parameters:
sS A String Set data type.
    public void setSS(java.util.Collection<StringsS) {
        if (sS == null) {
            this. = null;
            return;
        }
        sSCopy.addAll(sS);
        this. = sSCopy;
    }
    
    
A String Set data type.

NOTE: This method appends the values to the existing list (if any). Use setSS(java.util.Collection) or withSS(java.util.Collection) if you want to override the existing values.

Returns a reference to this object so that method calls can be chained together.

Parameters:
sS A String Set data type.
Returns:
A reference to this updated object so that method calls can be chained together.
    public AttributeValue withSS(String... sS) {
        if (getSS() == nullsetSS(new java.util.ArrayList<String>(sS.length));
        for (String value : sS) {
            getSS().add(value);
        }
        return this;
    }
    
    
A String Set data type.

Returns a reference to this object so that method calls can be chained together.

Parameters:
sS A String Set data type.
Returns:
A reference to this updated object so that method calls can be chained together.
        if (sS == null) {
            this. = null;
        } else {
            sSCopy.addAll(sS);
            this. = sSCopy;
        }
        return this;
    }

    
A Number Set data type.

Returns:
A Number Set data type.
    public java.util.List<StringgetNS() {
        return ;
    }
    
    
A Number Set data type.

Parameters:
nS A Number Set data type.
    public void setNS(java.util.Collection<StringnS) {
        if (nS == null) {
            this. = null;
            return;
        }
        nSCopy.addAll(nS);
        this. = nSCopy;
    }
    
    
A Number Set data type.

NOTE: This method appends the values to the existing list (if any). Use setNS(java.util.Collection) or withNS(java.util.Collection) if you want to override the existing values.

Returns a reference to this object so that method calls can be chained together.

Parameters:
nS A Number Set data type.
Returns:
A reference to this updated object so that method calls can be chained together.
    public AttributeValue withNS(String... nS) {
        if (getNS() == nullsetNS(new java.util.ArrayList<String>(nS.length));
        for (String value : nS) {
            getNS().add(value);
        }
        return this;
    }
    
    
A Number Set data type.

Returns a reference to this object so that method calls can be chained together.

Parameters:
nS A Number Set data type.
Returns:
A reference to this updated object so that method calls can be chained together.
        if (nS == null) {
            this. = null;
        } else {
            nSCopy.addAll(nS);
            this. = nSCopy;
        }
        return this;
    }

    
A Binary Set data type.

Returns:
A Binary Set data type.
    public java.util.List<java.nio.ByteBuffergetBS() {
        return ;
    }
    
    
A Binary Set data type.

Parameters:
bS A Binary Set data type.
    public void setBS(java.util.Collection<java.nio.ByteBufferbS) {
        if (bS == null) {
            this. = null;
            return;
        }
        bSCopy.addAll(bS);
        this. = bSCopy;
    }
    
    
A Binary Set data type.

NOTE: This method appends the values to the existing list (if any). Use setBS(java.util.Collection) or withBS(java.util.Collection) if you want to override the existing values.

Returns a reference to this object so that method calls can be chained together.

Parameters:
bS A Binary Set data type.
Returns:
A reference to this updated object so that method calls can be chained together.
    public AttributeValue withBS(java.nio.ByteBuffer... bS) {
        if (getBS() == nullsetBS(new java.util.ArrayList<java.nio.ByteBuffer>(bS.length));
        for (java.nio.ByteBuffer value : bS) {
            getBS().add(value);
        }
        return this;
    }
    
    
A Binary Set data type.

Returns a reference to this object so that method calls can be chained together.

Parameters:
bS A Binary Set data type.
Returns:
A reference to this updated object so that method calls can be chained together.
        if (bS == null) {
            this. = null;
        } else {
            bSCopy.addAll(bS);
            this. = bSCopy;
        }
        return this;
    }

    
A Map of attribute values.

Returns:
A Map of attribute values.
    public java.util.Map<String,AttributeValuegetM() {
        
        return ;
    }
    
    
A Map of attribute values.

Parameters:
m A Map of attribute values.
    public void setM(java.util.Map<String,AttributeValuem) {
        this. = m;
    }
    
    
A Map of attribute values.

Returns a reference to this object so that method calls can be chained together.

Parameters:
m A Map of attribute values.
Returns:
A reference to this updated object so that method calls can be chained together.
        setM(m);
        return this;
    }

    
A Map of attribute values.

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.

Parameters:
key The key of the entry to be added into M.
value The corresponding value of the entry to be added into M.
  public AttributeValue addMEntry(String keyAttributeValue value) {
    if (null == this.) {
      this. = new java.util.HashMap<String,AttributeValue>();
    }
    if (this..containsKey(key))
      throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided.");
    this..put(keyvalue);
    return this;
  }

  
Removes all the entries added into M.

Returns a reference to this object so that method calls can be chained together.

    this. = null;
    return this;
  }
  
    
A List of attribute values.

Returns:
A List of attribute values.
    public java.util.List<AttributeValuegetL() {
        return ;
    }
    
    
A List of attribute values.

Parameters:
l A List of attribute values.
    public void setL(java.util.Collection<AttributeValuel) {
        if (l == null) {
            this. = null;
            return;
        }
        lCopy.addAll(l);
        this. = lCopy;
    }
    
    
A List of attribute values.

NOTE: This method appends the values to the existing list (if any). Use setL(java.util.Collection) or withL(java.util.Collection) if you want to override the existing values.

Returns a reference to this object so that method calls can be chained together.

Parameters:
l A List of attribute values.
Returns:
A reference to this updated object so that method calls can be chained together.
    public AttributeValue withL(AttributeValue... l) {
        if (getL() == nullsetL(new java.util.ArrayList<AttributeValue>(l.length));
        for (AttributeValue value : l) {
            getL().add(value);
        }
        return this;
    }
    
    
A List of attribute values.

Returns a reference to this object so that method calls can be chained together.

Parameters:
l A List of attribute values.
Returns:
A reference to this updated object so that method calls can be chained together.
        if (l == null) {
            this. = null;
        } else {
            lCopy.addAll(l);
            this. = lCopy;
        }
        return this;
    }

    
A Null data type.

Returns:
A Null data type.
    public Boolean isNULL() {
        return ;
    }
    
    
A Null data type.

Parameters:
nULL A Null data type.
    public void setNULL(Boolean nULL) {
        this. = nULL;
    }
    
    
A Null data type.

Returns a reference to this object so that method calls can be chained together.

Parameters:
nULL A Null data type.
Returns:
A reference to this updated object so that method calls can be chained together.
    public AttributeValue withNULL(Boolean nULL) {
        this. = nULL;
        return this;
    }

    
A Null data type.

Returns:
A Null data type.
    public Boolean getNULL() {
        return ;
    }

    
A Boolean data type.

Returns:
A Boolean data type.
    public Boolean isBOOL() {
        return ;
    }
    
    
A Boolean data type.

Parameters:
bOOL A Boolean data type.
    public void setBOOL(Boolean bOOL) {
        this. = bOOL;
    }
    
    
A Boolean data type.

Returns a reference to this object so that method calls can be chained together.

Parameters:
bOOL A Boolean data type.
Returns:
A reference to this updated object so that method calls can be chained together.
    public AttributeValue withBOOL(Boolean bOOL) {
        this. = bOOL;
        return this;
    }

    
A Boolean data type.

Returns:
A Boolean data type.
    public Boolean getBOOL() {
        return ;
    }

    
Returns a string representation of this object; useful for testing and debugging.

Returns:
A string representation of this object.
See also:
java.lang.Object.toString()
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getS() != nullsb.append("S: " + getS() + ",");
        if (getN() != nullsb.append("N: " + getN() + ",");
        if (getB() != nullsb.append("B: " + getB() + ",");
        if (getSS() != nullsb.append("SS: " + getSS() + ",");
        if (getNS() != nullsb.append("NS: " + getNS() + ",");
        if (getBS() != nullsb.append("BS: " + getBS() + ",");
        if (getM() != nullsb.append("M: " + getM() + ",");
        if (getL() != nullsb.append("L: " + getL() + ",");
        if (isNULL() != nullsb.append("NULL: " + isNULL() + ",");
        if (isBOOL() != nullsb.append("BOOL: " + isBOOL() );
        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 + ((isNULL() == null) ? 0 : isNULL().hashCode()); 
        hashCode = prime * hashCode + ((isBOOL() == null) ? 0 : isBOOL().hashCode()); 
        return hashCode;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == objreturn true;
        if (obj == nullreturn false;
        if (obj instanceof AttributeValue == falsereturn false;
        AttributeValue other = (AttributeValue)obj;
        
        if (other.getS() == null ^ this.getS() == nullreturn false;
        if (other.getS() != null && other.getS().equals(this.getS()) == falsereturn false
        if (other.getN() == null ^ this.getN() == nullreturn false;
        if (other.getN() != null && other.getN().equals(this.getN()) == falsereturn false
        if (other.getB() == null ^ this.getB() == nullreturn false;
        if (other.getB() != null && other.getB().equals(this.getB()) == falsereturn false
        if (other.getSS() == null ^ this.getSS() == nullreturn false;
        if (other.getSS() != null && other.getSS().equals(this.getSS()) == falsereturn false
        if (other.getNS() == null ^ this.getNS() == nullreturn false;
        if (other.getNS() != null && other.getNS().equals(this.getNS()) == falsereturn false
        if (other.getBS() == null ^ this.getBS() == nullreturn false;
        if (other.getBS() != null && other.getBS().equals(this.getBS()) == falsereturn false
        if (other.getM() == null ^ this.getM() == nullreturn false;
        if (other.getM() != null && other.getM().equals(this.getM()) == falsereturn false
        if (other.getL() == null ^ this.getL() == nullreturn false;
        if (other.getL() != null && other.getL().equals(this.getL()) == falsereturn false
        if (other.isNULL() == null ^ this.isNULL() == nullreturn false;
        if (other.isNULL() != null && other.isNULL().equals(this.isNULL()) == falsereturn false
        if (other.isBOOL() == null ^ this.isBOOL() == nullreturn false;
        if (other.isBOOL() != null && other.isBOOL().equals(this.isBOOL()) == falsereturn false
        return true;
    }
    
    @Override
    public AttributeValue clone() {
        try {
            return (AttributeValuesuper.clone();
        
        } catch (CloneNotSupportedException e) {
            throw new IllegalStateException(
                    "Got a CloneNotSupportedException from Object.clone() "
                    + "even though we're Cloneable!",
                    e);
        }
        
    }
}
    
New to GrepCode? Check out our FAQ X