public Item with(String attrName, Object val) {
        if (val == null)
            return withNull(attrName);
        if (val instanceof String)
            return withString(attrName, (String)val);
        if (val instanceof Number)
            return withNumber(attrName, (Number)val);
        if (val instanceof byte[])
            return withBinary(attrName, (byte[])val);
        if (val instanceof ByteBuffer)
            return withBinary(attrName, (ByteBuffer)val);
        if (val instanceof Boolean)
            return withBoolean(attrName, (Boolean)val);
        if (val instanceof List)
            return withList(attrName, (List<?>)val);
        if (val instanceof Map) {
            @SuppressWarnings("unchecked")
            Map<String,?> map = (Map<String,?>)val;
            return withMap(attrName, map);
        }
        if (val instanceof Set) {
            Set<?> set = (Set<?>)val;
            // Treat an empty set as a set of String
            if (set.size() == 0) {
                @SuppressWarnings("unchecked")
                Set<String> ss = (Set<String>)val;
                return withStringSet(attrName, ss);
            }
            // Try to locate the first non-null element and use that as the
            // representative type
            Object representative = null;
            for (Object o: set) {
                if (o != null)
                    representative = o;
            }
            // If all elements are null, treat the element type as String
            if (representative == null || representative instanceof String) {
                @SuppressWarnings("unchecked")
                Set<String> ss = (Set<String>)val;
                return withStringSet(attrName, ss);
            }
            if (representative instanceof Number) {
                @SuppressWarnings("unchecked")
                Set<Number> ns = (Set<Number>)val;
                return withNumberSet(attrName, ns);
            }
            if (representative instanceof byte[]) {
                @SuppressWarnings("unchecked")
                Set<byte[]> bs = (Set<byte[]>)val;
                return withBinarySet(attrName, bs);
            }
            if (representative instanceof ByteBuffer) {
                @SuppressWarnings("unchecked")
                Set<ByteBuffer> bs = (Set<ByteBuffer>)val;
                return withByteBufferSet(attrName, bs);
            }
            throw new UnsupportedOperationException("Set of "
                    + representative.getClass() + " is not currently supported");
        }
        throw new UnsupportedOperationException("Input type "
                + val.getClass() + " is not currently supported");
    }
Sets the value of the specified attribute to the given value. An
attribute value can be a
<ul>
<li>Number</li>
<li>String</li>
<li>binary (ie byte array or byte buffer)</li>
<li>boolean</li>
<li>null</li>
<li>list (of any of the types on this list)</li>
<li>map (with string key to value of any of the types on this list)</li>
<li>set (of any of the types on this list)</li>
</ul>
aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/document/Item.java