diff --git a/jOOQ/src/main/java/org/jooq/CreateIndexStep.java b/jOOQ/src/main/java/org/jooq/CreateIndexStep.java index a7bbea23fe..9b20aaf334 100644 --- a/jOOQ/src/main/java/org/jooq/CreateIndexStep.java +++ b/jOOQ/src/main/java/org/jooq/CreateIndexStep.java @@ -56,6 +56,8 @@ import static org.jooq.SQLDialect.SQLITE; // ... // ... +import java.util.Collection; + /** * A {@link Query} that can create indexes. * @@ -69,15 +71,33 @@ public interface CreateIndexStep { @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE }) CreateIndexWhereStep on(Table table, OrderField... fields); + /** + * Specify the table and column expressions on which to create an index. + */ + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE }) + CreateIndexWhereStep on(Table table, Collection> fields); + /** * Specify the table and column expressions on which to create an index. */ @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE }) CreateIndexWhereStep on(Name tableName, Name... fieldNames); + /** + * Specify the table and column expressions on which to create an index. + */ + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE }) + CreateIndexWhereStep on(Name tableName, Collection fieldNames); + /** * Specify the table and column expressions on which to create an index. */ @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE }) CreateIndexWhereStep on(String tableName, String... fieldNames); + + /** + * Specify the table and column expressions on which to create an index. + */ + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE }) + CreateIndexWhereStep on(String tableName, Collection fieldNames); } diff --git a/jOOQ/src/main/java/org/jooq/impl/CreateIndexImpl.java b/jOOQ/src/main/java/org/jooq/impl/CreateIndexImpl.java index 5210182529..ef7aa70796 100644 --- a/jOOQ/src/main/java/org/jooq/impl/CreateIndexImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/CreateIndexImpl.java @@ -55,7 +55,10 @@ import static org.jooq.impl.Keywords.K_INDEX; import static org.jooq.impl.Keywords.K_ON; import static org.jooq.impl.Keywords.K_UNIQUE; import static org.jooq.impl.Keywords.K_WHERE; +import static org.jooq.impl.Tools.EMPTY_NAME; +import static org.jooq.impl.Tools.EMPTY_ORDERFIELD; import static org.jooq.impl.Tools.EMPTY_SORTFIELD; +import static org.jooq.impl.Tools.EMPTY_STRING; import java.util.Collection; import java.util.EnumSet; @@ -127,16 +130,31 @@ final class CreateIndexImpl extends AbstractQuery implements return this; } + @Override + public final CreateIndexImpl on(Table t, Collection> fields) { + return on(t, fields.toArray(EMPTY_ORDERFIELD)); + } + @Override public final CreateIndexImpl on(Name tableName, Name... fieldNames) { return on(table(tableName), Tools.fieldsByName(fieldNames)); } + @Override + public final CreateIndexImpl on(Name tableName, Collection fieldNames) { + return on(tableName, fieldNames.toArray(EMPTY_NAME)); + } + @Override public final CreateIndexImpl on(String tableName, String... fieldNames) { return on(table(name(tableName)), Tools.fieldsByName(fieldNames)); } + @Override + public final CreateIndexImpl on(String tableName, Collection fieldNames) { + return on(tableName, fieldNames.toArray(EMPTY_STRING)); + } + @Override public final CreateIndexImpl where(Condition condition) { where = condition; diff --git a/jOOQ/src/main/java/org/jooq/impl/Tools.java b/jOOQ/src/main/java/org/jooq/impl/Tools.java index bc3f2e6543..a4a6ed9dd2 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Tools.java +++ b/jOOQ/src/main/java/org/jooq/impl/Tools.java @@ -267,6 +267,7 @@ final class Tools { static final int[] EMPTY_INT = {}; static final Name[] EMPTY_NAME = {}; static final Param[] EMPTY_PARAM = {}; + static final OrderField[] EMPTY_ORDERFIELD = {}; static final Query[] EMPTY_QUERY = {}; static final QueryPart[] EMPTY_QUERYPART = {}; static final Record[] EMPTY_RECORD = {};