@Override public PutItemOutcome putItem(Item item, String conditionExpression, Map<String, String> nameMap, Map<String, Object> valueMap) { return doPutItem(new PutItemSpec() .withItem(item) .withConditionExpression(conditionExpression) .withNameMap(nameMap) .withValueMap(valueMap)); }
public PutItemSpec withConditionalOperator( ConditionalOperator conditionalOperator) { getRequest().setConditionalOperator(conditionalOperator); return this; }
@Override public PutItemSpec withProgressListener(ProgressListener progressListener) { setProgressListener(progressListener); return this; }
@Override public PutItemOutcome putItem(Item item, Expected ... expected) { return doPutItem(new PutItemSpec() .withItem(item) .withExpected(expected)); }
@Override public PutItemOutcome putItem(Item item) { return doPutItem(new PutItemSpec().withItem(item)); }
/** * Convenient method to specify expressions (and the associated name map and * value map) via {@link PutItemExpressionSpec}. */ @Beta public PutItemSpec withExpressionSpec(PutItemExpressionSpec xspec) { return withConditionExpression(xspec.getConditionExpression()) .withNameMap(xspec.getNameMap()) .withValueMap(xspec.getValueMap()) ; } }
private PutItemOutcome doPutItem(PutItemSpec spec) { // set the table name String tableName = getTable().getTableName(); PutItemRequest req = spec.getRequest().withTableName(tableName); // set up the item Item item = spec.getItem(); final Map<String,AttributeValue> attributes = InternalUtils.toAttributeValues(item); // set up the expected attribute map, if any final Map<String, ExpectedAttributeValue> expectedMap = InternalUtils.toExpectedAttributeValueMap(spec.getExpected()); // set up the value map, if any (when expression API is used) final Map<String,AttributeValue> attrValMap = InternalUtils.fromSimpleMap(spec.getValueMap()); // set up the request req.withItem(attributes) .withExpected(expectedMap) .withExpressionAttributeNames(spec.getNameMap()) .withExpressionAttributeValues(attrValMap) ; PutItemResult result = getClient().putItem(req); return new PutItemOutcome(result); } }
/** * Convenient method to specify expressions (and the associated name map and * value map) via {@link PutItemExpressionSpec}. */ @Beta public PutItemSpec withExpressionSpec(PutItemExpressionSpec xspec) { return withConditionExpression(xspec.getConditionExpression()) .withNameMap(xspec.getNameMap()) .withValueMap(xspec.getValueMap()) ; } }
@Override public PutItemOutcome putItem(Item item, Expected ... expected) { return doPutItem(new PutItemSpec() .withItem(item) .withExpected(expected)); }
private PutItemOutcome doPutItem(PutItemSpec spec) { // set the table name String tableName = getTable().getTableName(); PutItemRequest req = spec.getRequest().withTableName(tableName); // set up the item Item item = spec.getItem(); final Map<String,AttributeValue> attributes = InternalUtils.toAttributeValues(item); // set up the expected attribute map, if any final Map<String, ExpectedAttributeValue> expectedMap = InternalUtils.toExpectedAttributeValueMap(spec.getExpected()); // set up the value map, if any (when expression API is used) final Map<String,AttributeValue> attrValMap = InternalUtils.fromSimpleMap(spec.getValueMap()); // set up the request req.withItem(attributes) .withExpected(expectedMap) .withExpressionAttributeNames(spec.getNameMap()) .withExpressionAttributeValues(attrValMap) ; PutItemResult result = getClient().putItem(req); return new PutItemOutcome(result); } }
@Override public PutItemOutcome putItem(Item item) { return doPutItem(new PutItemSpec().withItem(item)); }
@Override public PutItemOutcome putItem(Item item, String conditionExpression, Map<String, String> nameMap, Map<String, Object> valueMap) { return doPutItem(new PutItemSpec() .withItem(item) .withConditionExpression(conditionExpression) .withNameMap(nameMap) .withValueMap(valueMap)); }
public PutItemSpec withReturnConsumedCapacity( ReturnConsumedCapacity returnConsumedCapacity) { getRequest().setReturnConsumedCapacity(returnConsumedCapacity); return this; }
@Override public PutItemSpec withProgressListener(ProgressListener progressListener) { setProgressListener(progressListener); return this; }
PutItemSpec putItemSpec = new PutItemSpec() .withItem(item) .withConditionExpression("attribute_not_exists(#yr) and attribute_not_exists(title)") .withNameMap(new NameMap() .with("#yr", "year"));
public PutItemSpec withReturnItemCollectionMetrics( ReturnItemCollectionMetrics returnItemCollectionMetrics) { getRequest() .setReturnItemCollectionMetrics(returnItemCollectionMetrics); return this; }
public String getReturnConsumedCapacity() { return getRequest().getReturnConsumedCapacity(); }
public String getReturnValues() { return getRequest().getReturnValues(); }
public PutItemSpec withConditionExpression(String conditionExpression) { getRequest().setConditionExpression(conditionExpression); return this; }
public PutItemSpec withReturnValues(ReturnValue returnValues) { getRequest().setReturnValues(returnValues); return this; }