List of usage examples for com.amazonaws.services.dynamodbv2.xspec ExpressionSpecBuilder ExpressionSpecBuilder
public ExpressionSpecBuilder()
From source file:com.github.fge.jsonpatch.JsonPatch.java
License:LGPL
/** * Converts this JsonPatch into an ExpressionSpecBuilder * @return an expression spec builder that contains the updates contained in this * patch/*from ww w . ja va2 s . c o m*/ */ public ExpressionSpecBuilder get() { ExpressionSpecBuilder builder = new ExpressionSpecBuilder(); for (JsonPatchOperation operation : operations) { operation.applyToBuilder(builder); } return builder; }
From source file:jp.classmethod.aws.dynamodb.DynamoDbRepository.java
License:Open Source License
@Override public <S extends E> S update(S domain, VersionCondition condition) { Preconditions.checkNotNull(domain, "domain must not be null"); final Item domainItem = convertDomainToItem(domain); Preconditions.checkArgument(domainItem.hasAttribute(hashKeyName), "hash key must be set in domain object when updating: " + hashKeyName); ExpressionSpecBuilder builder = new ExpressionSpecBuilder(); builder.withCondition(ExpressionSpecBuilder.S(hashKeyName).exists()); if (condition != null) { Preconditions.checkState(versionProperty != null); builder.withCondition(ExpressionSpecBuilder.N(versionProperty).eq(condition.getVersion())); }/*from w w w . ja v a2s.c o m*/ PutItemExpressionSpec xSpec = builder.buildForPut(); PutItemSpec spec = new PutItemSpec().withItem(domainItem).withExpressionSpec(xSpec); try { table.putItem(spec); } catch (AmazonClientException e) { throw processUpdateItemException(getId(domain), e); } // PutItem does not accept ReturnValue.ALL_NEW return domain; }