cfdsl.dynamodb.property.AttributeDefinition Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cfdsl Show documentation
Show all versions of cfdsl Show documentation
Java DSL for Amazon CloudFormation templates
The newest version!
package cfdsl.dynamodb.property;
import cfdsl.EmbeddedProperty;
public final class AttributeDefinition extends EmbeddedProperty {
private final String attributeName;
private AttributeDefinition(Builder b, String attributeName) {
super(b);
this.attributeName = attributeName;
}
String getAttributeName() {
return attributeName;
}
public KeySchema hashBasedPrimaryKey() {
return new KeySchema.Builder(attributeName, "HASH").build();
}
public KeySchema rangeBasedPrimaryKey() {
return new KeySchema.Builder(attributeName, "RANGE").build();
}
public static AttributeDefinition string(String attributeName) {
return new Builder(attributeName, "S").build();
}
public static AttributeDefinition numeric(String attributeName) {
return new Builder(attributeName, "N").build();
}
public static AttributeDefinition binary(String attributeName) {
return new Builder(attributeName, "B").build();
}
public static final class Builder extends EmbeddedProperty.Builder {
private final String attributeName;
private Builder(String attributeName, String attributeType) {
addProperty("AttributeName", this.attributeName = attributeName);
addProperty("AttributeType", attributeType);
}
@Override
public AttributeDefinition build() {
return new AttributeDefinition(this, attributeName);
}
}
}