/** * <p> * An attribute of type Number. For example: * </p> * <p> * <code>"N": "123.45"</code> * </p> * <p> * 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. * </p> * * @param n * An attribute of type Number. For example:</p> * <p> * <code>"N": "123.45"</code> * </p> * <p> * 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; }
attributeValue.setN(context.getUnmarshaller(String.class).unmarshall(context));
public static AttributeValue toAttributeValue(Object value) { if (value instanceof AttributeValue) { return (AttributeValue) value; } final AttributeValue attributeValue = new AttributeValue(); if (value == null) { attributeValue.setNULL(true); } else if (value instanceof Number) { attributeValue.setN(value.toString()); } else if (value instanceof Boolean) { attributeValue.setBOOL((Boolean) value); } else if (value instanceof String) { attributeValue.setS(value.toString()); } else { // TODO: Actually there's a few more value types we should support, // see AttributeValue.setXxxx throw new UnsupportedOperationException("Unsupported value type: " + value); } return attributeValue; }
.unmarshall(context)); } else if (name.equals("N")) { attributeValue.setN(StringJsonUnmarshaller.getInstance() .unmarshall(context)); } else if (name.equals("B")) {
private AttributeValue convertAttributeValue(JsonNode value) { AttributeValue attr = new AttributeValue(); if (value.isTextual()) { attr.setS(value.textValue()); } else if (value.isNumber()) { attr.setN(value.asText()); } else if (value.isBoolean()) { attr.setBOOL(value.asBoolean()); } else if (value.isArray()) { attr.setSS(IntStream.range(0, value.size()).mapToObj(i -> value.get(i).asText()) .collect(Collectors.toList())); } else if (value.isObject()) { Map<String, AttributeValue> map = new HashMap<>(value.size()); Iterator<Entry<String, JsonNode>> fields = value.fields(); while (fields.hasNext()) { Entry<String, JsonNode> next = fields.next(); map.put(next.getKey(), convertAttributeValue(next.getValue())); } attr.setM(map); } else if (!value.isNull()) { throw new IllegalStateException(); } return attr; }
sourceDestinationMap.put(val, clonedVal); if (val.getN() != null) { clonedVal.setN(val.getN()); } else if (val.getS() != null) { clonedVal.setS(val.getS());
@Override public AttributeValue convertToAttributeValue() { if (value == null) { return null; } final AttributeValue av = new AttributeValue(); switch (type) { case String: av.setS(String.valueOf(this.value)); break; case Number: av.setN(String.valueOf(this.value)); break; case Binary: av.setB((ByteBuffer) this.value); break; default: throw new IllegalStateException("invalid primitive type"); } return av; }
break; case 'n': result.setN(readString(in)); break; case 'N':
/** * <p> * An attribute of type Number. For example: * </p> * <p> * <code>"N": "123.45"</code> * </p> * <p> * 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. * </p> * * @param n * An attribute of type Number. For example:</p> * <p> * <code>"N": "123.45"</code> * </p> * <p> * 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; }
break; case 'n': result.setN(readString(in)); break; case 'N':
attributeValue.setN(context.getUnmarshaller(String.class).unmarshall(context));