/** * Adds an {@literal RENAME} to the list of field changes. * * @param from must not be {@literal null}. * @param to must not be {@literal null} or empty. * @return {@code this} {@link AlterUserTypeSpecification}. */ public AlterUserTypeSpecification rename(CqlIdentifier from, CqlIdentifier to) { return add(new RenameColumnSpecification(from, to)); }
/** * Adds an {@code ADD} to the list of column changes. * * @param column must not be {@literal null}. * @param type must not be {@literal null}. * @return {@literal this} {@link AlterTableSpecification}. * @since 2.0 */ public AlterTableSpecification add(CqlIdentifier column, DataType type) { return add(AddColumnSpecification.addColumn(column, type)); }
/** * Adds a {@code RENAME} to the list of column changes. * * @param from must not be {@literal null}. * @param to must not be {@literal null}. * @return {@literal this} {@link AlterTableSpecification}. * @since 2.0 */ public AlterTableSpecification rename(CqlIdentifier from, CqlIdentifier to) { return add(new RenameColumnSpecification(from, to)); }
/** * Configure datacenter replication given {@link DataCenterReplication}. * * @return this. */ public CreateKeyspaceSpecification withNetworkReplication(DataCenterReplication... dcrs) { MapBuilder<Option, Object> builder = MapBuilder.map(Option.class, Object.class).entry( new DefaultOption("class", String.class, true, false, true), ReplicationStrategy.NETWORK_TOPOLOGY_STRATEGY.getValue()); for (DataCenterReplication dcr : dcrs) { builder.entry(new DefaultOption(dcr.getDataCenter(), Long.class, true, false, false), dcr.getReplicationFactor()); } return with(KeyspaceOption.REPLICATION, builder.build()); }
/** * Convenience method that calls {@code with(option, null)}. * * @return this */ public T with(TableOption option) { return with(option.getName(), null, option.escapesValue(), option.quotesValue()); }
/** * Convenience method that calls {@code with(option, null)}. * * @return this */ public T with(KeyspaceOption option) { return with(option.getName(), null, option.escapesValue(), option.quotesValue()); }
/** * Configure simple replication with a {@code replicationFactor}. * * @return this. */ public CreateKeyspaceSpecification withSimpleReplication(long replicationFactor) { return with(KeyspaceOption.REPLICATION, MapBuilder.map(Option.class, Object.class) .entry(new DefaultOption("class", String.class, true, false, true), ReplicationStrategy.SIMPLE_STRATEGY.getValue()) .entry(new DefaultOption("replication_factor", Long.class, true, false, false), replicationFactor).build()); }
/** * Adds an {@literal ALTER} to the list of column changes. * * @param column must not be {@literal null}. * @param type must not be {@literal null}. * @return {@literal this} {@link AlterTableSpecification}. * @since 2.0 */ public AlterTableSpecification alter(CqlIdentifier column, DataType type) { return add(AlterColumnSpecification.alterColumn(column, type)); }
/** * Adds an {@literal ADD} to the list of field changes. * * @param field must not be {@literal null}. * @param type must not be {@literal null}. * @return {@code this} {@link AlterUserTypeSpecification}. */ public AlterUserTypeSpecification add(CqlIdentifier field, DataType type) { return add(AddColumnSpecification.addColumn(field, type)); }
/** * Adds an {@literal ALTER} to the list of field changes. * * @param field must not be {@literal null}. * @param type must not be {@literal null}. * @return {@code this} {@link AlterUserTypeSpecification}. */ public AlterUserTypeSpecification alter(CqlIdentifier field, DataType type) { return add(AlterColumnSpecification.alterColumn(field, type)); }
public AlterTableSpecification drop(CqlIdentifier column) { return add(DropColumnSpecification.dropColumn(column)); }
/** * Causes the inclusion of an {@code FULL} clause. * * @return this * @since 2.0 */ public CreateIndexSpecification full() { return columnFunction(ColumnFunction.FULL); }
/** * Identifies this column as a clustered key column with default ordering. Sets the column's {@link #keyType} to * {@link PrimaryKeyType#CLUSTERED} and its {@link #ordering} to {@link #DEFAULT_ORDERING}. * * @return this */ public ColumnSpecification clustered() { return clustered(DEFAULT_ORDERING); }
/** * Create a new {@link DropColumnSpecification} for the given {@code name}. * * @param name must not be {@literal null} or empty. */ public static DropColumnSpecification dropColumn(CqlIdentifier name) { return new DropColumnSpecification(name); } }
/** * Entry point into the {@link CreateIndexSpecification}'s fluent API to create a index. Convenient if imported * statically. */ public static CreateIndexSpecification createIndex() { return new CreateIndexSpecification(); }
/** * Entry point into the {@link CreateUserTypeSpecification}'s fluent API given {@code name} to create a type. * Convenient if imported statically. * * @param name must not {@literal null}. * @return a new {@link CreateUserTypeSpecification}. */ public static CreateUserTypeSpecification createType(CqlIdentifier name) { return new CreateUserTypeSpecification(name); }
/** * Entry point into the {@link CreateKeyspaceSpecification}'s fluent API given {@code name} to create a keyspace. * Convenient if imported statically. * * @param name must not be {@literal null}. * @return a new {@link CreateKeyspaceSpecification}. */ public static CreateKeyspaceSpecification createKeyspace(KeyspaceIdentifier name) { return new CreateKeyspaceSpecification(name); }
/** * Sets the given table option. This is a convenience method that calls * {@link #with(String, Object, boolean, boolean)} appropriately from the given {@link TableOption} and value for that * option. * * @param option The option to set. * @param value The value of the option. Must be type-compatible with the {@link TableOption}. * @return this * @see #with(String, Object, boolean, boolean) */ public T with(TableOption option, Object value) { option.checkValue(value); return with(option.getName(), value, option.escapesValue(), option.quotesValue()); }
/** * Causes the inclusion of an {@code KEYS} clause. * * @return this * @since 2.0 */ public CreateIndexSpecification keys() { return columnFunction(ColumnFunction.KEYS); }
/** * Identifies this column as a clustered key column with the given ordering. Sets the column's {@link #keyType} to * {@link PrimaryKeyType#CLUSTERED} and its {@link #ordering} to the given {@link Ordering}. * * @return this */ public ColumnSpecification clustered(Ordering order) { return clustered(order, true); }