Class Item


  • public class Item
    extends Object
    An item in DynamoDB. An item is a collection of attributes. Each attribute has a name and a value. An attribute value can be one of the followings:
    • String
    • Set<String>
    • Number (including any subtypes and primitive types)
    • Set<Number>
    • byte[]
    • Set<byte[]>
    • ByteBuffer
    • Set<ByteBuffer>
    • Boolean or boolean
    • null
    • Map<String,T>, where T can be any type on this list but must not induce any circular reference
    • List<T>, where T can be any type on this list but must not induce any circular reference
    For an Item to be successfully persisted in DynamoDB, at a minimum the respective attributes for the primary key must be specified.
    • Constructor Summary

      Constructors 
      Constructor Description
      Item()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Map<String,​Object> asMap()
      Returns all attributes of the current item as a map.
      Iterable<Map.Entry<String,​Object>> attributes()
      Returns all attributes of the current item.
      Item base64Decode​(String... binaryAttrNames)
      Utility method to decode the designated binary attributes from base-64 encoding; converting binary lists into binary sets.
      Item convertListsToSets​(String... listAttrNames)
      Utility method to converts the designated attributes from List into Set, throwing IllegalArgumentException should there be duplicate elements.
      boolean equals​(Object in)  
      static Item fromJSON​(String json)
      Convenient factory method - instantiates an Item from the given JSON string.
      static Item fromMap​(Map<String,​Object> attributes)
      Convenient factory method - instantiates an Item from the given map.
      Object get​(String attrName)
      Returns the value of the specified attribute in the current item as an object; or null if the attribute either doesn't exist or the attribute value is null.
      BigInteger getBigInteger​(String attrName)
      Returns the value of the specified attribute in the current item as an BigInteger; or null if the attribute doesn't exist.
      byte[] getBinary​(String attrName)
      Returns the value of the specified attribute in the current item as a byte array; or null if the attribute either doesn't exist or the attribute value is null.
      Set<byte[]> getBinarySet​(String attrName)
      Returns the value of the specified attribute in the current item as a set of byte arrays; or null if the attribute either doesn't exist or the attribute value is null.
      Boolean getBOOL​(String attrName)
      Returns the value of the specified attribute in the current item as a non-null Boolean.
      boolean getBoolean​(String attrName)
      Returns the value of the specified attribute in the current item as a primitive boolean.
      ByteBuffer getByteBuffer​(String attrName)
      Returns the value of the specified attribute in the current item as a ByteBuffer; or null if the attribute either doesn't exist or the attribute value is null.
      Set<ByteBuffer> getByteBufferSet​(String attrName)
      Returns the value of the specified attribute in the current item as a set of ByteBuffer; or null if the attribute either doesn't exist or the attribute value is null.
      double getDouble​(String attrName)
      Returns the value of the specified attribute in the current item as a double.
      float getFloat​(String attrName)
      Returns the value of the specified attribute in the current item as a float.
      int getInt​(String attrName)
      Returns the value of the specified attribute in the current item as an int.
      String getJSON​(String attrName)
      Returns the value of the specified attribute in the current item as a JSON string; or null if the attribute either doesn't exist or the attribute value is null.
      String getJSONPretty​(String attrName)
      Returns the value of the specified attribute in the current item as a JSON string with pretty indentation; or null if the attribute either doesn't exist or the attribute value is null.
      <T> List<T> getList​(String attrName)
      Returns the value of the specified attribute in the current item as a set of T's.; or null if the attribute either doesn't exist or the attribute value is null.
      long getLong​(String attrName)
      Returns the value of the specified attribute in the current item as an long.
      <T> Map<String,​T> getMap​(String attrName)
      Returns the value of the specified attribute in the current item as a map of string-to-T's; or null if the attribute either doesn't exist or the attribute value is null.
      <T extends Number>
      Map<String,​T>
      getMapOfNumbers​(String attrName, Class<T> valueType)
      Convenient method to return the specified attribute in the current item as a (copy of) map of string-to-T's where T must be a subclass of Number; or null if the attribute doesn't exist.
      BigDecimal getNumber​(String attrName)
      Returns the value of the specified attribute in the current item as a BigDecimal; or null if the attribute either doesn't exist or the attribute value is null.
      Set<BigDecimal> getNumberSet​(String attrName)
      Returns the value of the specified attribute in the current item as a set of BigDecimal's; or null if the attribute either doesn't exist or the attribute value is null.
      Map<String,​Object> getRawMap​(String attrName)
      Convenient method to return the value of the specified attribute in the current item as a map of string-to-Object's; or null if the attribute either doesn't exist or the attribute value is null.
      short getShort​(String attrName)
      Returns the value of the specified attribute in the current item as a short.
      String getString​(String attrName)
      Returns the value of the specified attribute in the current item as a string; or null if the attribute either doesn't exist or the attribute value is null.
      Set<String> getStringSet​(String attrName)
      Returns the value of the specified attribute in the current item as a set of strings; or null if the attribute either doesn't exist or the attribute value is null.
      Class<?> getTypeOf​(String attrName)
      Returns the type of the specified attribute in the current item; or null if the attribute either doesn't exist or the attribute value is null.
      boolean hasAttribute​(String attrName)
      Returns true if this item has the specified attribute; false otherwise.
      int hashCode()  
      boolean isNull​(String attrName)
      Returns true if the specified attribute exists with a null value; false otherwise.
      boolean isPresent​(String attrName)
      Returns true if this item contains the specified attribute; false otherwise.
      int numberOfAttributes()
      Returns the number of attributes of this item.
      Item removeAttribute​(String attrName)
      Removes the specified attribute from the current item.
      String toJSON()
      Returns this item as a JSON string.
      String toJSONPretty()
      Returns this item as a pretty JSON string.
      String toString()  
      Item with​(String attrName, Object val)
      Sets the value of the specified attribute to the given value.
      Item withBigDecimalSet​(String attrName, BigDecimal... vals)
      Sets the value of the specified attribute in the current item to the given value.
      Item withBigDecimalSet​(String attrName, Set<BigDecimal> val)
      Sets the value of the specified attribute in the current item to the given value.
      Item withBigInteger​(String attrName, BigInteger val)
      Sets the value of the specified attribute in the current item to the given value.
      Item withBinary​(String attrName, byte[] val)
      Sets the value of the specified attribute in the current item to the given value.
      Item withBinary​(String attrName, ByteBuffer val)
      Sets the value of the specified attribute in the current item to the given value.
      Item withBinarySet​(String attrName, byte[]... vals)
      Sets the value of the specified attribute in the current item to the given value.
      Item withBinarySet​(String attrName, ByteBuffer... vals)
      Sets the value of the specified attribute in the current item to the given value.
      Item withBinarySet​(String attrName, Set<byte[]> val)
      Sets the value of the specified attribute in the current item to the given value.
      Item withBoolean​(String attrName, boolean val)
      Sets the value of the specified attribute in the current item to the boolean value.
      Item withByteBufferSet​(String attrName, Set<ByteBuffer> val)
      Sets the value of the specified attribute in the current item to the given value.
      Item withDouble​(String attrName, double val)
      Sets the value of the specified attribute in the current item to the given value.
      Item withFloat​(String attrName, float val)
      Sets the value of the specified attribute in the current item to the given value.
      Item withInt​(String attrName, int val)
      Sets the value of the specified attribute in the current item to the given value.
      Item withJSON​(String attrName, String json)
      Sets the value of the specified attribute in the current item to the given JSON document in the form of a string.
      Item withKeyComponent​(String keyAttrName, Object keyAttrValue)
      Convenient methods - sets an attribute of this item for the specified key attribute name and value.
      Item withKeyComponents​(KeyAttribute... components)
      Convenient methods - sets the attributes of this item from the specified key components.
      Item withList​(String attrName, Object... vals)
      Sets the value of the specified attribute in the current item to the given values as a list.
      Item withList​(String attrName, List<?> val)
      Sets the value of the specified attribute in the current item to the given value.
      Item withLong​(String attrName, long val)
      Sets the value of the specified attribute in the current item to the given value.
      Item withMap​(String attrName, Map<String,​?> val)
      Sets the value of the specified attribute in the current item to the given value.
      Item withNull​(String attrName)
      Sets the value of the specified attribute to null.
      Item withNumber​(String attrName, Number val)
      Sets the value of the specified attribute in the current item to the given value.
      Item withNumber​(String attrName, BigDecimal val)
      Sets the value of the specified attribute in the current item to the given value.
      Item withNumberSet​(String attrName, Number... vals)
      Sets the value of the specified attribute in the current item to the given value.
      Item withNumberSet​(String attrName, Set<Number> vals)
      Sets the value of the specified attribute in the current item to the given value.
      Item withPrimaryKey​(PrimaryKey primaryKey)
      Convenient methods - sets the attributes of this item from the given key attributes.
      Item withPrimaryKey​(String hashKeyName, Object hashKeyValue)
      Convenient method to set the attributes of this item from the given hash-only primary key name and value.
      Item withPrimaryKey​(String hashKeyName, Object hashKeyValue, String rangeKeyName, Object rangeKeyValue)
      Convenient method to set the attributes of this item from the given hash and range primary key.
      Item withShort​(String attrName, short val)
      Sets the value of the specified attribute in the current item to the given value.
      Item withString​(String attrName, String val)
      Sets the value of the specified attribute in the current item to the given string value.
      Item withStringSet​(String attrName, String... val)
      Sets the value of the specified attribute in the current item to the given value.
      Item withStringSet​(String attrName, Set<String> val)
      Sets the value of the specified attribute in the current item to the given value.