All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cfdsl.dynamodb.property.AttributeDefinition Maven / Gradle / Ivy

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);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy