@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAttributeName() == null) ? 0 : getAttributeName().hashCode()); hashCode = prime * hashCode + ((getKeyType() == null) ? 0 : getKeyType().hashCode()); return hashCode; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getAttributeName() != null) sb.append("AttributeName: ").append(getAttributeName()).append(","); if (getKeyType() != null) sb.append("KeyType: ").append(getKeyType()); sb.append("}"); return sb.toString(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof KeySchemaElement == false) return false; KeySchemaElement other = (KeySchemaElement) obj; if (other.getAttributeName() == null ^ this.getAttributeName() == null) return false; if (other.getAttributeName() != null && other.getAttributeName().equals(this.getAttributeName()) == false) return false; if (other.getKeyType() == null ^ this.getKeyType() == null) return false; if (other.getKeyType() != null && other.getKeyType().equals(this.getKeyType()) == false) return false; return true; }
/** * Marshall the given parameter object. */ public void marshall(KeySchemaElement keySchemaElement, ProtocolMarshaller protocolMarshaller) { if (keySchemaElement == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(keySchemaElement.getAttributeName(), ATTRIBUTENAME_BINDING); protocolMarshaller.marshall(keySchemaElement.getKeyType(), KEYTYPE_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } }
/** * Gets the global secondary index. * @param indexName The index name. * @return The global secondary index or null. */ public GlobalSecondaryIndex globalSecondaryIndex(final String indexName) { if (!globalSecondaryIndexes.containsKey(indexName)) { return null; } final GlobalSecondaryIndex gsi = globalSecondaryIndexes.get(indexName); final GlobalSecondaryIndex copy = new GlobalSecondaryIndex().withIndexName(gsi.getIndexName()); copy.withProjection(new Projection().withProjectionType(gsi.getProjection().getProjectionType())); for (final KeySchemaElement key : gsi.getKeySchema()) { copy.withKeySchema(new KeySchemaElement(key.getAttributeName(), key.getKeyType())); } return copy; }
/** * Gets the local secondary index by name. * @param indexNames The index name. * @return The local secondary index, or null. */ public LocalSecondaryIndex localSecondaryIndex(final String indexName) { if (!localSecondaryIndexes.containsKey(indexName)) { return null; } final LocalSecondaryIndex lsi = localSecondaryIndexes.get(indexName); final LocalSecondaryIndex copy = new LocalSecondaryIndex().withIndexName(lsi.getIndexName()); copy.withProjection(new Projection().withProjectionType(lsi.getProjection().getProjectionType())); for (final KeySchemaElement key : lsi.getKeySchema()) { copy.withKeySchema(new KeySchemaElement(key.getAttributeName(), key.getKeyType())); } return copy; }
private void runTest(AmazonDynamoDB client) { CreateTableRequest request = new CreateTableRequest() .withAttributeDefinitions(new AttributeDefinition( "Name", ScalarAttributeType.S)) .withKeySchema(new KeySchemaElement("Name", KeyType.HASH)) .withProvisionedThroughput(new ProvisionedThroughput( new Long(10), new Long(10))) .withTableName("foo"); client.createTable(request); final TableDescription tableDescription = client.describeTable("foo").getTable(); assertNotNull("the description is not null", tableDescription); assertEquals("the table has the right name", "foo", tableDescription.getTableName()); assertEquals("the name has the right primary key", "Name", tableDescription.getKeySchema().get(0).getAttributeName()); } }
private static boolean isKeyAttribute(KeySchemaElement element, String attributeName) { return element.getAttributeName().equals(attributeName); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAttributeName() == null) ? 0 : getAttributeName().hashCode()); hashCode = prime * hashCode + ((getKeyType() == null) ? 0 : getKeyType().hashCode()); return hashCode; }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getAttributeName() != null) sb.append("AttributeName: " + getAttributeName() + ","); if (getKeyType() != null) sb.append("KeyType: " + getKeyType()); sb.append("}"); return sb.toString(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof KeySchemaElement == false) return false; KeySchemaElement other = (KeySchemaElement) obj; if (other.getAttributeName() == null ^ this.getAttributeName() == null) return false; if (other.getAttributeName() != null && other.getAttributeName().equals(this.getAttributeName()) == false) return false; if (other.getKeyType() == null ^ this.getKeyType() == null) return false; if (other.getKeyType() != null && other.getKeyType().equals(this.getKeyType()) == false) return false; return true; } }
public void marshall(KeySchemaElement keySchemaElement, AwsJsonWriter jsonWriter) throws Exception { jsonWriter.beginObject(); if (keySchemaElement.getAttributeName() != null) { String attributeName = keySchemaElement.getAttributeName(); jsonWriter.name("AttributeName"); jsonWriter.value(attributeName); } if (keySchemaElement.getKeyType() != null) { String keyType = keySchemaElement.getKeyType(); jsonWriter.name("KeyType"); jsonWriter.value(keyType); } jsonWriter.endObject(); }
.getAttributeName(); if (!existingLsiRangeKeyName.equals(lsiRangeKeyName)) { throw new DynamoDBMappingException("Multiple range keys ["
final String existingKeyName = existingKey.getAttributeName(); final String existingKeyType = existingKey.getKeyType();
final String keyName = element.getAttributeName(); for (final AttributeDefinition ad : this.tableDescription.getAttributeDefinitions()) { if (ad.getAttributeName().equals(keyName)) {
protected Map<String, AttributeValue> createKeyMap(final String tableName, final Map<String, AttributeValue> item) { if (tableName == null) { throw new IllegalArgumentException("must specify a tableName"); } if (item == null) { throw new IllegalArgumentException("must specify an item"); } List<KeySchemaElement> schema = getTableSchema(tableName); Map<String, AttributeValue> key = new HashMap<String, AttributeValue>(schema.size()); for (KeySchemaElement element : schema) { key.put(element.getAttributeName(), item.get(element.getAttributeName())); } return key; }
protected static Map<String, AttributeValue> getKeyFromItem(String tableName, Map<String, AttributeValue> item, TransactionManager txManager) { if(item == null) { throw new InvalidRequestException("PutItem must contain an Item", null, tableName, null, null); } Map<String, AttributeValue> newKey = new HashMap<String, AttributeValue>(); List<KeySchemaElement> schema = txManager.getTableSchema(tableName); for(KeySchemaElement schemaElement : schema) { AttributeValue val = item.get(schemaElement.getAttributeName()); if(val == null) { throw new InvalidRequestException("PutItem request must contain the key attribute " + schemaElement.getAttributeName(), null, tableName, null, null); } newKey.put(schemaElement.getAttributeName(), item.get(schemaElement.getAttributeName())); } return newKey; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAttributeName() == null) ? 0 : getAttributeName().hashCode()); hashCode = prime * hashCode + ((getKeyType() == null) ? 0 : getKeyType().hashCode()); return hashCode; }
/** * Marshall the given parameter object. */ public void marshall(KeySchemaElement keySchemaElement, ProtocolMarshaller protocolMarshaller) { if (keySchemaElement == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(keySchemaElement.getAttributeName(), ATTRIBUTENAME_BINDING); protocolMarshaller.marshall(keySchemaElement.getKeyType(), KEYTYPE_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } }
private void addColumnFromKeySchema(String indexName, List<KeySchemaElement> keySchema, MutableTable table, boolean primaryKey) { for (final KeySchemaElement keySchemaElement : keySchema) { final String attributeName = keySchemaElement.getAttributeName(); if (table.getColumnByName(attributeName) == null) { final String keyType = keySchemaElement.getKeyType(); final MutableColumn column = new MutableColumn(attributeName, table).setPrimaryKey(primaryKey); appendRemarks(column, indexName + " member ('" + keyType + "' type)"); table.addColumn(column); } } }