/** * Create a new {@link ColumnSpecification} for the given {@code name}. * * @param name must not be {@literal null} or empty. * @return a new {@link ColumnSpecification} for {@code name}. */ public static ColumnSpecification name(String name) { return name(of(name)); }
@SuppressWarnings("unchecked") protected T column(CqlIdentifier name, DataType type, Optional<PrimaryKeyType> optionalKeyType, Optional<Ordering> optionalOrdering) { Assert.notNull(name, "Name must not be null"); Assert.notNull(type, "DataType must not be null"); Assert.notNull(optionalKeyType, "PrimaryKeyType must not be null"); Assert.notNull(optionalOrdering, "Ordering must not be null"); ColumnSpecification column = ColumnSpecification.name(name).type(type); optionalKeyType.ifPresent(keyType -> { column.keyType(keyType); optionalOrdering.filter(o -> keyType == CLUSTERED).ifPresent(column::ordering); if (keyType == PrimaryKeyType.PARTITIONED) { this.partitionKeyColumns.add(column); } if (keyType == PrimaryKeyType.CLUSTERED) { this.clusteredKeyColumns.add(column); } }); this.columns.add(column); if (!optionalKeyType.isPresent()) { this.nonKeyColumns.add(column); } return (T) this; }