List of usage examples for com.amazonaws.services.dynamodbv2.model AttributeValue withNS
public AttributeValue withNS(java.util.Collection<String> nS)
An attribute of type Number Set.
From source file:io.apptik.json.aws.DynamoDb2Item.java
License:Apache License
@Override protected AttributeValue get(JsonElement el, String key) { AttributeValue atVal = new AttributeValue(); if (el.isNumber()) { atVal.withN(el.toString());/*w w w .j av a2 s . co m*/ } else if (el.isJsonArray()) { boolean isNumberArr = true; ArrayList<String> attrList = new ArrayList<String>(); for (JsonElement arrEl : el.asJsonArray()) { if (isNumberArr && !arrEl.isNumber()) isNumberArr = false; attrList.add(arrEl.toString()); } if (isNumberArr) { atVal.withNS(attrList); } else { atVal.withSS(attrList); } } else { atVal.withS(el.toString()); } return atVal; }
From source file:org.socialsignin.spring.data.dynamodb.repository.query.AbstractDynamoDBQueryCriteria.java
License:Apache License
protected <P> List<AttributeValue> addAttributeValue(List<AttributeValue> attributeValueList, Object attributeValue, String propertyName, Class<P> propertyType, boolean expandCollectionValues) { AttributeValue attributeValueObject = new AttributeValue(); if (ClassUtils.isAssignable(String.class, propertyType)) { List<String> attributeValueAsList = getAttributeValueAsList(attributeValue); if (expandCollectionValues && attributeValueAsList != null) { attributeValueObject.withSS(attributeValueAsList); } else {/*from www. j a v a2 s.com*/ attributeValueObject.withS((String) attributeValue); } } else if (ClassUtils.isAssignable(Number.class, propertyType)) { List<Number> attributeValueAsList = getAttributeValueAsList(attributeValue); if (expandCollectionValues && attributeValueAsList != null) { List<String> attributeValueAsStringList = getNumberListAsStringList(attributeValueAsList); attributeValueObject.withNS(attributeValueAsStringList); } else { attributeValueObject.withN(attributeValue.toString()); } } else if (ClassUtils.isAssignable(Boolean.class, propertyType)) { List<Boolean> attributeValueAsList = getAttributeValueAsList(attributeValue); if (expandCollectionValues && attributeValueAsList != null) { List<String> attributeValueAsStringList = getBooleanListAsStringList(attributeValueAsList); attributeValueObject.withNS(attributeValueAsStringList); } else { boolean boolValue = ((Boolean) attributeValue).booleanValue(); attributeValueObject.withN(boolValue ? "1" : "0"); } } else if (ClassUtils.isAssignable(Date.class, propertyType)) { List<Date> attributeValueAsList = getAttributeValueAsList(attributeValue); if (expandCollectionValues && attributeValueAsList != null) { List<String> attributeValueAsStringList = getDateListAsStringList(attributeValueAsList); attributeValueObject.withSS(attributeValueAsStringList); } else { Date date = (Date) attributeValue; String marshalledDate = new Date2IsoDynamoDBMarshaller().marshall(date); attributeValueObject.withS(marshalledDate); } } else if (ClassUtils.isAssignable(Instant.class, propertyType)) { List<Instant> attributeValueAsList = getAttributeValueAsList(attributeValue); if (expandCollectionValues && attributeValueAsList != null) { List<String> attributeValueAsStringList = getInstantListAsStringList(attributeValueAsList); attributeValueObject.withSS(attributeValueAsStringList); } else { Instant date = (Instant) attributeValue; String marshalledDate = new Instant2IsoDynamoDBMarshaller().marshall(date); attributeValueObject.withS(marshalledDate); } } else { throw new RuntimeException("Cannot create condition for type:" + attributeValue.getClass() + " property conditions must be String,Number or Boolean, or have a DynamoDBMarshaller configured"); } attributeValueList.add(attributeValueObject); return attributeValueList; }