[#7357] Overload CreateIndexStep.on() clauses with Collection accepting version

This commit is contained in:
lukaseder 2018-03-29 15:01:38 +02:00
parent a7e429de44
commit 6db5349e8c
3 changed files with 39 additions and 0 deletions

View File

@ -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<? extends 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(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<? extends 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(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<? extends String> fieldNames);
}

View File

@ -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<? extends OrderField<?>> 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<? extends Name> 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<? extends String> fieldNames) {
return on(tableName, fieldNames.toArray(EMPTY_STRING));
}
@Override
public final CreateIndexImpl where(Condition condition) {
where = condition;

View File

@ -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 = {};