@Override public UpdateItemOutcome updateItem( String hashKeyName, Object hashKeyValue, String rangeKeyName, Object rangeKeyValue, Collection<Expected> expected, AttributeUpdate... attributeUpdates) { return updateItem(new PrimaryKey(hashKeyName, hashKeyValue, rangeKeyName, rangeKeyValue), expected, attributeUpdates); }
/** * Adds a primary key (that consists of a hash-key and a range-key) to be * deleted in a batch write operation. * * @param hashKeyName hash key attribute name * @param hashKeyValue hash key value * @param rangeKeyName range key attribute name * @param rangeKeyValue range key value * @return the current instance for method chaining purposes */ public TableWriteItems addHashAndRangePrimaryKeyToDelete( String hashKeyName, Object hashKeyValue, String rangeKeyName, Object rangeKeyValue) { this.addPrimaryKeyToDelete( new PrimaryKey() .addComponent(hashKeyName, hashKeyValue) .addComponent(rangeKeyName, rangeKeyValue)); return this; }
/** * Constructs with the specified key components. */ public PrimaryKey(KeyAttribute ...components) { addComponents(components); }
/** * @see ScanRequest#withExclusiveStartKey(Map) */ public ScanSpec withExclusiveStartKey(PrimaryKey exclusiveStartKey) { if (exclusiveStartKey == null) this.exclusiveStartKey = null; else { this.exclusiveStartKey = exclusiveStartKey.getComponents(); } return this; }
private void checkConsistency(PrimaryKey primaryKey) { if (this.primaryKeysToDelete.size() > 0) { // use the first one as the representative final Set<String> nameSet = primaryKeysToDelete.get(0).getComponentNameSet(); if (!nameSet.equals(primaryKey.getComponentNameSet())) throw new IllegalArgumentException( "primary key must be added with consistent key attribute name(s)"); } }
/** * Constructs with a hash key. */ public PrimaryKey(String hashKeyName, Object hashKeyValue) { addComponent(hashKeyName, hashKeyValue); }
public QuerySpec withExclusiveStartKey(PrimaryKey exclusiveStartKey) { if (exclusiveStartKey == null) this.exclusiveStartKey = null; else { this.exclusiveStartKey = exclusiveStartKey.getComponents(); } return this; }
private void checkConsistency(PrimaryKey primaryKey) { if (this.primaryKeys.size() > 0) { // use the first one as the representative final Set<String> nameSet = primaryKeys.get(0).getComponentNameSet(); if (!nameSet.equals(primaryKey.getComponentNameSet())) throw new IllegalArgumentException( "primary key must be added with consistent key attribute name(s)"); } }
/** * Constructs with a hash key and a range key. */ public PrimaryKey(String hashKeyName, Object hashKeyValue, String rangeKeyName, Object rangeKeyValue) { if (hashKeyName.equals(rangeKeyName)) throw new IllegalArgumentException("hashKyeName must not be the same as the rangeKeyName"); addComponent(hashKeyName, hashKeyValue); addComponent(rangeKeyName, rangeKeyValue); }
@Override public DeleteItemOutcome deleteItem(String hashKeyName, Object hashKeyValue) { return deleteItem(new PrimaryKey(hashKeyName, hashKeyValue)); }
/** * Adds a primary key (that consists of a hash-key and a range-key) to be * included in the batch get-item operation. * * @param hashKeyName hash key attribute name * @param hashKeyValue hash key value * @param rangeKeyName range key attribute name * @param rangeKeyValue range key value * @return the current instance for method chaining purposes */ public TableKeysAndAttributes addHashAndRangePrimaryKey( String hashKeyName, Object hashKeyValue, String rangeKeyName, Object rangeKeyValue) { this.addPrimaryKey( new PrimaryKey() .addComponent(hashKeyName, hashKeyValue) .addComponent(rangeKeyName, rangeKeyValue)); return this; }
/** * Sets the primary key. */ public AbstractSpecWithPrimaryKey<T> withPrimaryKey(PrimaryKey primaryKey) { if (primaryKey == null) this.keyComponents = null; else { this.keyComponents = primaryKey.getComponents(); } return this; }
/** * Used to specify multiple primary keys. A primary key could consist of * either a hash-key or both a hash-key and a range-key depending on the * schema of the table. */ public TableKeysAndAttributes withPrimaryKeys(PrimaryKey... primaryKeys) { if (primaryKeys == null) this.primaryKeys = null; else { Set<String> pkNameSet = null; for (PrimaryKey pk : primaryKeys) { if (pkNameSet == null) pkNameSet = pk.getComponentNameSet(); else { if (!pkNameSet.equals(pk.getComponentNameSet())) { throw new IllegalArgumentException( "primary key attribute names must be consistent for the specified primary keys"); } } } this.primaryKeys = new ArrayList<PrimaryKey>(Arrays.asList(primaryKeys)); } return this; }
/** * Constructs with a hash key. */ public PrimaryKey(String hashKeyName, Object hashKeyValue) { addComponent(hashKeyName, hashKeyValue); }
/** * Constructs with the specified key components. */ public PrimaryKey(KeyAttribute ...components) { addComponents(components); }
/** * Adds a hash-only primary key to be included in the batch get-item * operation. * * @param hashKeyName name of the hash key attribute name * @param hashKeyValue name of the hash key value * @return the current instance for method chaining purposes */ public TableKeysAndAttributes addHashOnlyPrimaryKey( String hashKeyName, Object hashKeyValue) { this.addPrimaryKey(new PrimaryKey(hashKeyName, hashKeyValue)); return this; }
Object rangeKeyValue = alternatingHashRangeKeyValues[i+1]; this.addPrimaryKey( new PrimaryKey() .addComponent(hashKeyName, hashKeyValue) .addComponent(rangeKeyName, rangeKeyValue) );
/** * Converts the specified primary key into the low-level representation. */ public static Map<String, AttributeValue> toAttributeValueMap( PrimaryKey primaryKey) { if (primaryKey == null) return null; return toAttributeValueMap(primaryKey.getComponents()); }
/** * Used to specify multiple primary keys to be deleted from the current * table. A primary key could consist of either a hash-key or both a * hash-key and a range-key depending on the schema of the table. */ public TableWriteItems withPrimaryKeysToDelete( PrimaryKey... primaryKeysToDelete) { if (primaryKeysToDelete == null) this.primaryKeysToDelete = null; else { Set<String> pkNameSet = null; for (PrimaryKey pk : primaryKeysToDelete) { if (pkNameSet == null) pkNameSet = pk.getComponentNameSet(); else { if (!pkNameSet.equals(pk.getComponentNameSet())) { throw new IllegalArgumentException( "primary key attribute names must be consistent for the specified primary keys"); } } } this.primaryKeysToDelete = new ArrayList<PrimaryKey>( Arrays.asList(primaryKeysToDelete)); } return this; }
/** * Constructs with a hash key and a range key. */ public PrimaryKey(String hashKeyName, Object hashKeyValue, String rangeKeyName, Object rangeKeyValue) { if (hashKeyName.equals(rangeKeyName)) throw new IllegalArgumentException("hashKyeName must not be the same as the rangeKeyName"); addComponent(hashKeyName, hashKeyValue); addComponent(rangeKeyName, rangeKeyValue); }