/** * Create a new {@link FieldSpecification} given {@link CqlIdentifier name} and {@link DataType}. * * @param name must not be {@literal null}. * @param type must not be {@literal null}. * @return */ public static FieldSpecification of(CqlIdentifier name, DataType type) { return new FieldSpecification(name, type); }
/** * Adds an {@literal ADD} to the list of field changes. * * @param name must not {@literal null}. * @param type must not be {@literal null}. * @return {@code this} specification. */ @SuppressWarnings("unchecked") public T field(CqlIdentifier name, DataType type) { fields.add(FieldSpecification.of(name, type)); return (T) this; }
@Override public String toString() { return toCql(new StringBuilder()).toString(); } }
public String toCql() { return toCql(new StringBuilder()).toString(); }
/** * Create a new {@link FieldSpecification} for the given {@code name} and {@link DataType} * * @param name must not be {@literal null} or empty. * @param type must not be {@literal null}. */ public static FieldSpecification of(String name, DataType type) { return new FieldSpecification(CqlIdentifier.of(name), type); }
private StringBuilder columns(StringBuilder cql) { // begin columns cql.append(" ("); boolean first = true; for (FieldSpecification column : spec().getFields()) { if (!first) { cql.append(", "); } column.toCql(cql); first = false; } cql.append(")"); // end columns return cql; } }