[#5322] Create constant empty arrays Field[0] and String[0] for faster toArray() calls
This commit is contained in:
parent
f013a4c3c3
commit
88214ce406
@ -46,6 +46,8 @@ import static java.util.Arrays.asList;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.conf.ParamType.INDEXED;
|
||||
import static org.jooq.impl.Tools.EMPTY_CLAUSE;
|
||||
import static org.jooq.impl.Tools.EMPTY_QUERYPART;
|
||||
import static org.jooq.impl.Tools.DataKey.DATA_OMIT_CLAUSE_EVENT_EMISSION;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
@ -293,7 +295,7 @@ abstract class AbstractContext<C extends Context<C>> extends AbstractScope imple
|
||||
|
||||
@Override
|
||||
public final Clause[] clauses() {
|
||||
return visitClauses.toArray(new Clause[0]);
|
||||
return visitClauses.toArray(EMPTY_CLAUSE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -314,7 +316,7 @@ abstract class AbstractContext<C extends Context<C>> extends AbstractScope imple
|
||||
|
||||
@Override
|
||||
public final QueryPart[] queryParts() {
|
||||
return visitParts.toArray(new QueryPart[0]);
|
||||
return visitParts.toArray(EMPTY_QUERYPART);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -49,6 +49,7 @@ import static java.util.Arrays.asList;
|
||||
import static org.jooq.conf.RenderNameStyle.LOWER;
|
||||
import static org.jooq.conf.RenderNameStyle.UPPER;
|
||||
import static org.jooq.impl.DSL.select;
|
||||
import static org.jooq.impl.Tools.EMPTY_STRING;
|
||||
import static org.jooq.impl.Tools.fieldArray;
|
||||
import static org.jooq.impl.Tools.unqualify;
|
||||
import static org.jooq.util.sqlite.SQLiteDSL.rowid;
|
||||
@ -312,7 +313,7 @@ abstract class AbstractDMLQuery<R extends Record> extends AbstractQuery {
|
||||
names.add(field.getName());
|
||||
}
|
||||
|
||||
ctx.statement(connection.prepareStatement(ctx.sql(), names.toArray(new String[0])));
|
||||
ctx.statement(connection.prepareStatement(ctx.sql(), names.toArray(EMPTY_STRING)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,6 +62,8 @@ import static org.jooq.impl.ExpressionOperator.ADD;
|
||||
import static org.jooq.impl.ExpressionOperator.DIVIDE;
|
||||
import static org.jooq.impl.ExpressionOperator.MULTIPLY;
|
||||
import static org.jooq.impl.ExpressionOperator.SUBTRACT;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.EMPTY_STRING;
|
||||
import static org.jooq.tools.Convert.FALSE_VALUES;
|
||||
import static org.jooq.tools.Convert.TRUE_VALUES;
|
||||
import static org.jooq.tools.StringUtils.defaultString;
|
||||
@ -644,7 +646,7 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
Class<?> type = getType();
|
||||
|
||||
if (type == String.class)
|
||||
return ((Field<String>) this).in(Tools.inline(TRUE_VALUES.toArray(new String[0])));
|
||||
return ((Field<String>) this).in(Tools.inline(TRUE_VALUES.toArray(EMPTY_STRING)));
|
||||
else if (Number.class.isAssignableFrom(type))
|
||||
return ((Field<Number>) this).equal(inline((Number) getDataType().convert(1)));
|
||||
else if (Boolean.class.isAssignableFrom(type))
|
||||
@ -659,13 +661,13 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
Class<?> type = getType();
|
||||
|
||||
if (type == String.class)
|
||||
return ((Field<String>) this).in(Tools.inline(FALSE_VALUES.toArray(new String[0])));
|
||||
return ((Field<String>) this).in(Tools.inline(FALSE_VALUES.toArray(EMPTY_STRING)));
|
||||
else if (Number.class.isAssignableFrom(type))
|
||||
return ((Field<Number>) this).equal(inline((Number) getDataType().convert(0)));
|
||||
else if (Boolean.class.isAssignableFrom(type))
|
||||
return ((Field<Boolean>) this).equal(inline(false));
|
||||
else
|
||||
return cast(String.class).in(Tools.inline(FALSE_VALUES.toArray(new String[0])));
|
||||
return cast(String.class).in(Tools.inline(FALSE_VALUES.toArray(EMPTY_STRING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -822,7 +824,7 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
if (isAccidentalCollection(values))
|
||||
return in((Collection<?>) values[0]);
|
||||
|
||||
return in(Tools.fields(values, this).toArray(new Field<?>[0]));
|
||||
return in(Tools.fields(values, this).toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -837,7 +839,7 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
for (Object value : values)
|
||||
fields.add(Tools.field(value, this));
|
||||
|
||||
return in(fields.toArray(new Field<?>[0]));
|
||||
return in(fields.toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -862,7 +864,7 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
if (isAccidentalCollection(values))
|
||||
return notIn((Collection<?>) values[0]);
|
||||
|
||||
return notIn(Tools.fields(values, this).toArray(new Field<?>[0]));
|
||||
return notIn(Tools.fields(values, this).toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -877,7 +879,7 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
for (Object value : values)
|
||||
fields.add(Tools.field(value, this));
|
||||
|
||||
return notIn(fields.toArray(new Field<?>[0]));
|
||||
return notIn(fields.toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1787,7 +1789,7 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
@Override
|
||||
@Deprecated
|
||||
public final Field<String> concat(String... values) {
|
||||
return DSL.concat(Tools.combine(this, Tools.fields(values).toArray(new Field[0])));
|
||||
return DSL.concat(Tools.combine(this, Tools.fields(values).toArray(EMPTY_FIELD)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1850,7 +1852,7 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
@SafeVarargs
|
||||
|
||||
public final Field<T> greatest(T... others) {
|
||||
return DSL.greatest(this, Tools.fields(others).toArray(new Field[0]));
|
||||
return DSL.greatest(this, Tools.fields(others).toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1865,7 +1867,7 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
@SafeVarargs
|
||||
|
||||
public final Field<T> least(T... others) {
|
||||
return DSL.least(this, Tools.fields(others).toArray(new Field[0]));
|
||||
return DSL.least(this, Tools.fields(others).toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1940,7 +1942,7 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
@SafeVarargs
|
||||
|
||||
public final Field<T> coalesce(T option, T... options) {
|
||||
return DSL.coalesce(this, Tools.combine(Tools.field(option), Tools.fields(options).toArray(new Field[0])));
|
||||
return DSL.coalesce(this, Tools.combine(Tools.field(option), Tools.fields(options).toArray(EMPTY_FIELD)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -51,6 +51,7 @@ import static org.jooq.conf.ParamType.INLINED;
|
||||
import static org.jooq.conf.SettingsTools.executePreparedStatements;
|
||||
import static org.jooq.conf.SettingsTools.getParamType;
|
||||
import static org.jooq.impl.DSL.using;
|
||||
import static org.jooq.impl.Tools.EMPTY_PARAM;
|
||||
import static org.jooq.impl.Tools.blocking;
|
||||
import static org.jooq.impl.Tools.consumeExceptions;
|
||||
import static org.jooq.impl.Tools.DataKey.DATA_COUNT_BIND_VALUES;
|
||||
@ -185,7 +186,7 @@ abstract class AbstractQuery extends AbstractQueryPart implements Query, Attacha
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public Query bind(int index, Object value) {
|
||||
Param<?>[] params = getParams().values().toArray(new Param[0]);
|
||||
Param<?>[] params = getParams().values().toArray(EMPTY_PARAM);
|
||||
|
||||
if (index < 1 || index > params.length)
|
||||
throw new IllegalArgumentException("Index out of range for Query parameters : " + index);
|
||||
|
||||
@ -53,6 +53,8 @@ import static org.jooq.impl.DSL.name;
|
||||
import static org.jooq.impl.DSL.table;
|
||||
import static org.jooq.impl.DSL.using;
|
||||
import static org.jooq.impl.DSL.val;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.EMPTY_STRING;
|
||||
import static org.jooq.impl.Tools.consumeExceptions;
|
||||
import static org.jooq.impl.Tools.settings;
|
||||
|
||||
@ -981,7 +983,7 @@ public abstract class AbstractRoutine<T> extends AbstractQueryPart implements Ro
|
||||
names.add(pkg.getName());
|
||||
}
|
||||
names.add(name);
|
||||
return (AggregateFunction<T>) function(DSL.name(names.toArray(new String[0])), type, array);
|
||||
return (AggregateFunction<T>) function(DSL.name(names.toArray(EMPTY_STRING)), type, array);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1183,7 +1185,7 @@ public abstract class AbstractRoutine<T> extends AbstractQueryPart implements Ro
|
||||
fields.add(getInValues().get(parameter));
|
||||
}
|
||||
|
||||
Field<T> result = function(local.render(), getDataType(), fields.toArray(new Field[0]));
|
||||
Field<T> result = function(local.render(), getDataType(), fields.toArray(EMPTY_FIELD));
|
||||
|
||||
|
||||
// [#3592] Decrease SQL -> PL/SQL context switches with Oracle Scalar Subquery Caching
|
||||
|
||||
@ -57,6 +57,7 @@ import static org.jooq.JoinType.STRAIGHT_JOIN;
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.table;
|
||||
import static org.jooq.impl.DSL.val;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -42,6 +42,7 @@ package org.jooq.impl;
|
||||
|
||||
import static org.jooq.conf.ParamType.INLINED;
|
||||
import static org.jooq.conf.SettingsTools.executeStaticStatements;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.dataTypes;
|
||||
import static org.jooq.impl.Tools.fields;
|
||||
import static org.jooq.impl.Tools.visitAll;
|
||||
@ -60,7 +61,6 @@ import org.jooq.DSLContext;
|
||||
import org.jooq.DataType;
|
||||
import org.jooq.ExecuteContext;
|
||||
import org.jooq.ExecuteListener;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Param;
|
||||
import org.jooq.Query;
|
||||
import org.jooq.exception.ControlFlowSignal;
|
||||
@ -203,7 +203,7 @@ final class BatchSingle implements BatchBindStep {
|
||||
for (Entry<String, Param<?>> entry : collector.resultList)
|
||||
params.add(entry.getValue());
|
||||
|
||||
DataType<?>[] paramTypes = dataTypes(params.toArray(new Field[0]));
|
||||
DataType<?>[] paramTypes = dataTypes(params.toArray(EMPTY_FIELD));
|
||||
|
||||
try {
|
||||
listener.renderStart(ctx);
|
||||
|
||||
@ -44,6 +44,7 @@ import static java.util.Arrays.asList;
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.jooq.impl.DSL.row;
|
||||
import static org.jooq.impl.DSL.using;
|
||||
import static org.jooq.impl.Tools.EMPTY_RECORD;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -371,7 +372,7 @@ public abstract class DAOImpl<R extends UpdatableRecord<R>, P, T> implements DAO
|
||||
|
||||
// [#2573] Composite key T types are of type Record[N]
|
||||
else {
|
||||
return row(pk).in(ids.toArray(new Record[0]));
|
||||
return row(pk).in(ids.toArray(EMPTY_RECORD));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -71,6 +71,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.Term.ROW_NUMBER;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.combine;
|
||||
import static org.jooq.impl.Tools.configuration;
|
||||
|
||||
@ -9726,7 +9727,7 @@ public class DSL {
|
||||
*/
|
||||
@Support
|
||||
public static <Z, T> Field<Z> decode(T value, T search, Z result, Object... more) {
|
||||
return decode(Tools.field(value), Tools.field(search), Tools.field(result), Tools.fields(more).toArray(new Field[0]));
|
||||
return decode(Tools.field(value), Tools.field(search), Tools.field(result), Tools.fields(more).toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -9738,7 +9739,7 @@ public class DSL {
|
||||
*/
|
||||
@Support
|
||||
public static <Z, T> Field<Z> decode(Field<T> value, Field<T> search, Field<Z> result) {
|
||||
return decode(nullSafe(value), nullSafe(search), nullSafe(result), new Field[0]);
|
||||
return decode(nullSafe(value), nullSafe(search), nullSafe(result), EMPTY_FIELD);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -10047,7 +10048,7 @@ public class DSL {
|
||||
*/
|
||||
@Support
|
||||
public static <T> Field<T> coalesce(T value, T... values) {
|
||||
return coalesce0(Tools.field(value), Tools.fields(values).toArray(new Field[0]));
|
||||
return coalesce0(Tools.field(value), Tools.fields(values).toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -10826,7 +10827,7 @@ public class DSL {
|
||||
*/
|
||||
@Support
|
||||
public static Field<String> concat(String... values) {
|
||||
return concat(Tools.fields(values).toArray(new Field[0]));
|
||||
return concat(Tools.fields(values).toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -12527,7 +12528,7 @@ public class DSL {
|
||||
*/
|
||||
@Support
|
||||
public static <T> Field<T> greatest(T value, T... values) {
|
||||
return greatest(Tools.field(value), Tools.fields(values).toArray(new Field[0]));
|
||||
return greatest(Tools.field(value), Tools.fields(values).toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -12557,7 +12558,7 @@ public class DSL {
|
||||
*/
|
||||
@Support
|
||||
public static <T> Field<T> least(T value, T... values) {
|
||||
return least(Tools.field(value), Tools.fields(values).toArray(new Field[0]));
|
||||
return least(Tools.field(value), Tools.fields(values).toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -16576,7 +16577,7 @@ public class DSL {
|
||||
*/
|
||||
@Support
|
||||
public static RowN row(Object... values) {
|
||||
return row(Tools.fields(values).toArray(new Field[0]));
|
||||
return row(Tools.fields(values).toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
// [jooq-tools] START [row-expression]
|
||||
@ -17738,7 +17739,7 @@ public class DSL {
|
||||
*/
|
||||
protected static Field<?>[] nullSafe(Field<?>... fields) {
|
||||
if (fields == null)
|
||||
return new Field[0];
|
||||
return EMPTY_FIELD;
|
||||
|
||||
Field<?>[] result = new Field<?>[fields.length];
|
||||
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.Converters.inverse;
|
||||
import static org.jooq.impl.Tools.EMPTY_CLASS;
|
||||
import static org.jooq.tools.StringUtils.rightPad;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -185,7 +186,7 @@ public class DefaultConverterProvider implements ConverterProvider {
|
||||
synchronized (paths) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
Class<?>[] classes = vertices.toArray(new Class[0]);
|
||||
Class<?>[] classes = vertices.toArray(EMPTY_CLASS);
|
||||
Arrays.sort(classes, new Comparator<Class<?>>() {
|
||||
@Override
|
||||
public int compare(Class<?> o1, Class<?> o2) {
|
||||
|
||||
@ -50,6 +50,9 @@ import static org.jooq.impl.DSL.sequence;
|
||||
import static org.jooq.impl.DSL.sql;
|
||||
import static org.jooq.impl.DSL.table;
|
||||
import static org.jooq.impl.DSL.trueCondition;
|
||||
import static org.jooq.impl.Tools.EMPTY_QUERY;
|
||||
import static org.jooq.impl.Tools.EMPTY_TABLE_RECORD;
|
||||
import static org.jooq.impl.Tools.EMPTY_UPDATABLE_RECORD;
|
||||
import static org.jooq.impl.Tools.blocking;
|
||||
import static org.jooq.impl.Tools.list;
|
||||
import static org.jooq.tools.Convert.convert;
|
||||
@ -2272,7 +2275,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public Batch batch(Collection<? extends Query> queries) {
|
||||
return batch(queries.toArray(new Query[0]));
|
||||
return batch(queries.toArray(EMPTY_QUERY));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2302,7 +2305,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public Batch batchStore(Collection<? extends UpdatableRecord<?>> records) {
|
||||
return batchStore(records.toArray(new UpdatableRecord[0]));
|
||||
return batchStore(records.toArray(EMPTY_UPDATABLE_RECORD));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2312,7 +2315,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public Batch batchInsert(Collection<? extends TableRecord<?>> records) {
|
||||
return batchInsert(records.toArray(new TableRecord[0]));
|
||||
return batchInsert(records.toArray(EMPTY_TABLE_RECORD));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2322,7 +2325,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public Batch batchUpdate(Collection<? extends UpdatableRecord<?>> records) {
|
||||
return batchUpdate(records.toArray(new UpdatableRecord[0]));
|
||||
return batchUpdate(records.toArray(EMPTY_UPDATABLE_RECORD));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2332,7 +2335,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public Batch batchDelete(Collection<? extends UpdatableRecord<?>> records) {
|
||||
return batchDelete(records.toArray(new UpdatableRecord[0]));
|
||||
return batchDelete(records.toArray(EMPTY_UPDATABLE_RECORD));
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@ -43,6 +43,7 @@ package org.jooq.impl;
|
||||
import static java.util.Collections.nCopies;
|
||||
import static org.jooq.impl.DSL.field;
|
||||
import static org.jooq.impl.DSL.name;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.getAnnotatedGetter;
|
||||
import static org.jooq.impl.Tools.getAnnotatedMembers;
|
||||
import static org.jooq.impl.Tools.getAnnotatedSetters;
|
||||
@ -552,7 +553,7 @@ public class DefaultRecordMapper<R extends Record, E> implements RecordMapper<R,
|
||||
|
||||
Field<?>[] f = nestedFields.get(prefix);
|
||||
if (f == null) {
|
||||
f = nCopies(fields.length, field("")).toArray(new Field[0]);
|
||||
f = nCopies(fields.length, field("")).toArray(EMPTY_FIELD);
|
||||
nestedFields.put(prefix, f);
|
||||
}
|
||||
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import static java.lang.Boolean.FALSE;
|
||||
import static org.jooq.impl.Tools.EMPTY_EXECUTE_LISTENER;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -96,7 +97,7 @@ final class ExecuteListeners implements ExecuteListener {
|
||||
result.add(new StopWatchListener());
|
||||
}
|
||||
|
||||
return result.toArray(new ExecuteListener[0]);
|
||||
return result.toArray(EMPTY_EXECUTE_LISTENER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.indexOrFail;
|
||||
|
||||
import java.sql.SQLWarning;
|
||||
@ -74,7 +75,7 @@ final class Fields<R extends Record> extends AbstractQueryPart implements Record
|
||||
}
|
||||
|
||||
Fields(Collection<? extends Field<?>> fields) {
|
||||
this.fields = fields.toArray(new Field[0]);
|
||||
this.fields = fields.toArray(EMPTY_FIELD);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -40,6 +40,8 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -51,21 +53,13 @@ import javax.annotation.Generated;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.FieldLike;
|
||||
import org.jooq.InsertOnDuplicateSetMoreStep;
|
||||
import org.jooq.InsertOnConflictDoUpdateStep;
|
||||
import org.jooq.InsertOnDuplicateSetMoreStep;
|
||||
import org.jooq.InsertQuery;
|
||||
import org.jooq.InsertResultStep;
|
||||
import org.jooq.InsertSetMoreStep;
|
||||
import org.jooq.InsertSetStep;
|
||||
import org.jooq.InsertValuesStep1;
|
||||
import org.jooq.InsertValuesStep2;
|
||||
import org.jooq.InsertValuesStep3;
|
||||
import org.jooq.InsertValuesStep4;
|
||||
import org.jooq.InsertValuesStep5;
|
||||
import org.jooq.InsertValuesStep6;
|
||||
import org.jooq.InsertValuesStep7;
|
||||
import org.jooq.InsertValuesStep8;
|
||||
import org.jooq.InsertValuesStep9;
|
||||
import org.jooq.InsertValuesStep10;
|
||||
import org.jooq.InsertValuesStep11;
|
||||
import org.jooq.InsertValuesStep12;
|
||||
@ -76,9 +70,17 @@ import org.jooq.InsertValuesStep16;
|
||||
import org.jooq.InsertValuesStep17;
|
||||
import org.jooq.InsertValuesStep18;
|
||||
import org.jooq.InsertValuesStep19;
|
||||
import org.jooq.InsertValuesStep2;
|
||||
import org.jooq.InsertValuesStep20;
|
||||
import org.jooq.InsertValuesStep21;
|
||||
import org.jooq.InsertValuesStep22;
|
||||
import org.jooq.InsertValuesStep3;
|
||||
import org.jooq.InsertValuesStep4;
|
||||
import org.jooq.InsertValuesStep5;
|
||||
import org.jooq.InsertValuesStep6;
|
||||
import org.jooq.InsertValuesStep7;
|
||||
import org.jooq.InsertValuesStep8;
|
||||
import org.jooq.InsertValuesStep9;
|
||||
import org.jooq.InsertValuesStepN;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Record1;
|
||||
@ -564,7 +566,7 @@ class InsertImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
|
||||
|
||||
@Override
|
||||
public final InsertImpl columns(Collection<? extends Field<?>> f) {
|
||||
return columns(f.toArray(new Field[f.size()]));
|
||||
return columns(f.toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -54,6 +54,7 @@ import static org.jooq.impl.DSL.select;
|
||||
import static org.jooq.impl.DSL.selectFrom;
|
||||
import static org.jooq.impl.DSL.selectOne;
|
||||
import static org.jooq.impl.DSL.table;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.aliasedFields;
|
||||
import static org.jooq.impl.Tools.fieldNames;
|
||||
import static org.jooq.impl.Tools.DataKey.DATA_INSERT_SELECT_WITHOUT_INSERT_COLUMN_LIST;
|
||||
@ -439,11 +440,11 @@ final class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> impl
|
||||
// re-used.
|
||||
|
||||
Select<Record> rows = null;
|
||||
String[] aliases = fieldNames(insertMaps.getMap().keySet().toArray(new Field[0]));
|
||||
String[] aliases = fieldNames(insertMaps.getMap().keySet().toArray(EMPTY_FIELD));
|
||||
|
||||
for (FieldMapForInsert map : insertMaps.insertMaps) {
|
||||
Select<Record> row =
|
||||
select(aliasedFields(map.values().toArray(new Field[0]), aliases))
|
||||
select(aliasedFields(map.values().toArray(EMPTY_FIELD), aliases))
|
||||
.whereNotExists(
|
||||
selectOne()
|
||||
.from(table)
|
||||
|
||||
@ -40,6 +40,8 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Tools.EMPTY_STRING;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
@ -108,7 +110,7 @@ final class JSONReader implements Closeable {
|
||||
String asString = value == null ? null : String.valueOf(value);
|
||||
v.add(asString);
|
||||
}
|
||||
records.add(v.toArray(new String[0]));
|
||||
records.add(v.toArray(EMPTY_STRING));
|
||||
}
|
||||
|
||||
return records;
|
||||
|
||||
@ -40,6 +40,8 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -541,7 +543,7 @@ final class LoaderImpl<R extends Record> implements
|
||||
|
||||
@Override
|
||||
public final LoaderImpl<R> fields(Collection<? extends Field<?>> f) {
|
||||
return fields(f.toArray(new Field[0]));
|
||||
return fields(f.toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -57,6 +57,7 @@ import static org.jooq.impl.DSL.exists;
|
||||
import static org.jooq.impl.DSL.insertInto;
|
||||
import static org.jooq.impl.DSL.notExists;
|
||||
import static org.jooq.impl.DSL.nullSafe;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.DataKey.DATA_WRAP_DERIVED_TABLES_IN_PARENTHESES;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -711,10 +712,10 @@ implements
|
||||
// syntax, in case of which, the USING() was not added
|
||||
if (using == null) {
|
||||
upsertStyle = true;
|
||||
getUpsertValues().addAll(Tools.fields(values, getUpsertFields().toArray(new Field[0])));
|
||||
getUpsertValues().addAll(Tools.fields(values, getUpsertFields().toArray(EMPTY_FIELD)));
|
||||
}
|
||||
else {
|
||||
Field<?>[] fields = notMatchedInsert.keySet().toArray(new Field[0]);
|
||||
Field<?>[] fields = notMatchedInsert.keySet().toArray(EMPTY_FIELD);
|
||||
notMatchedInsert.putValues(Tools.fields(values, fields));
|
||||
}
|
||||
|
||||
|
||||
@ -4373,6 +4373,9 @@ import static java.util.Collections.singletonList;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -43,6 +43,7 @@ package org.jooq.impl;
|
||||
import static org.jooq.conf.ParamType.INLINED;
|
||||
import static org.jooq.impl.DSL.trueCondition;
|
||||
import static org.jooq.impl.DSL.using;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -201,7 +202,7 @@ implements
|
||||
.select(aliasedGroupingFields)
|
||||
.select(aggregationSelects)
|
||||
.from(pivot)
|
||||
.where(pivot.field(on).in(in.toArray(new Field[0])))
|
||||
.where(pivot.field(on).in(in.toArray(EMPTY_FIELD)))
|
||||
.groupBy(aliasedGroupingFields)
|
||||
.asTable();
|
||||
|
||||
|
||||
@ -40,6 +40,8 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Tools.EMPTY_QUERY;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.stream.Stream;
|
||||
@ -60,7 +62,7 @@ final class QueriesImpl implements Queries {
|
||||
|
||||
@Override
|
||||
public final Query[] queries() {
|
||||
return queries.toArray(new Query[0]);
|
||||
return queries.toArray(EMPTY_QUERY);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
|
||||
@ -60,6 +60,7 @@ import static org.jooq.impl.DSL.name;
|
||||
import static org.jooq.impl.DSL.notExists;
|
||||
import static org.jooq.impl.DSL.row;
|
||||
import static org.jooq.impl.DSL.select;
|
||||
import static org.jooq.impl.Tools.EMPTY_STRING;
|
||||
import static org.jooq.impl.Tools.DataKey.DATA_ROW_VALUE_EXPRESSION_PREDICATE_SUBQUERY;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -197,7 +198,7 @@ final class RowSubqueryCondition extends AbstractCondition {
|
||||
}
|
||||
|
||||
Select<Record> subselect =
|
||||
select().from(right.asTable(table, names.toArray(new String[0])))
|
||||
select().from(right.asTable(table, names.toArray(EMPTY_STRING)))
|
||||
.where(condition);
|
||||
|
||||
switch (comparator) {
|
||||
|
||||
@ -44,6 +44,7 @@ import static org.jooq.impl.DSL.condition;
|
||||
import static org.jooq.impl.DSL.exists;
|
||||
import static org.jooq.impl.DSL.notExists;
|
||||
import static org.jooq.impl.DSL.table;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -49,6 +49,7 @@ import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
import static org.jooq.impl.RecordDelegate.delegate;
|
||||
import static org.jooq.impl.RecordDelegate.RecordLifecycleType.INSERT;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.indexOrFail;
|
||||
import static org.jooq.impl.Tools.DataKey.DATA_OMIT_RETURNING_CLAUSE;
|
||||
|
||||
@ -141,7 +142,7 @@ public class TableRecordImpl<R extends TableRecord<R>> extends AbstractRecord im
|
||||
|
||||
@Override
|
||||
public final int insert(Collection<? extends Field<?>> storeFields) {
|
||||
return insert(storeFields.toArray(new Field[0]));
|
||||
return insert(storeFields.toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
final int storeInsert(final Field<?>[] storeFields) {
|
||||
@ -215,7 +216,7 @@ public class TableRecordImpl<R extends TableRecord<R>> extends AbstractRecord im
|
||||
|
||||
// [#1859] In some databases, not all fields can be fetched via getGeneratedKeys()
|
||||
if (asList(DERBY, H2, MARIADB, MYSQL).contains(configuration().family()) && this instanceof UpdatableRecord)
|
||||
((UpdatableRecord<?>) this).refresh(key.toArray(new Field[0]));
|
||||
((UpdatableRecord<?>) this).refresh(key.toArray(EMPTY_FIELD));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -135,6 +135,7 @@ import org.jooq.ExecuteListener;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.Param;
|
||||
import org.jooq.Query;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.RecordType;
|
||||
@ -148,6 +149,7 @@ import org.jooq.Schema;
|
||||
import org.jooq.SelectField;
|
||||
import org.jooq.SortField;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableRecord;
|
||||
import org.jooq.UDT;
|
||||
import org.jooq.UDTRecord;
|
||||
import org.jooq.UpdatableRecord;
|
||||
@ -173,7 +175,24 @@ import org.jooq.types.UShort;
|
||||
*/
|
||||
final class Tools {
|
||||
|
||||
static final JooqLogger log = JooqLogger.getLogger(Tools.class);
|
||||
static final JooqLogger log = JooqLogger.getLogger(Tools.class);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Empty arrays for use with Collection.toArray()
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
static final Class<?>[] EMPTY_CLASS = {};
|
||||
static final Clause[] EMPTY_CLAUSE = {};
|
||||
static final Collection<?>[] EMPTY_COLLECTION = {};
|
||||
static final ExecuteListener[] EMPTY_EXECUTE_LISTENER = {};
|
||||
static final Field<?>[] EMPTY_FIELD = {};
|
||||
static final Param<?>[] EMPTY_PARAM = {};
|
||||
static final Query[] EMPTY_QUERY = {};
|
||||
static final QueryPart[] EMPTY_QUERYPART = {};
|
||||
static final Record[] EMPTY_RECORD = {};
|
||||
static final String[] EMPTY_STRING = {};
|
||||
static final TableRecord<?>[] EMPTY_TABLE_RECORD = {};
|
||||
static final UpdatableRecord<?>[] EMPTY_UPDATABLE_RECORD = {};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Some constants for use with Context.data()
|
||||
@ -639,7 +658,7 @@ final class Tools {
|
||||
}
|
||||
|
||||
static final Field<?>[] fieldArray(Collection<? extends Field<?>> fields) {
|
||||
return fields == null ? null : fields.toArray(new Field[0]);
|
||||
return fields == null ? null : fields.toArray(EMPTY_FIELD);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -803,7 +822,7 @@ final class Tools {
|
||||
}
|
||||
|
||||
static final Field<?>[] fieldsByName(Collection<String> fieldNames) {
|
||||
return fieldsByName(null, fieldNames.toArray(new String[0]));
|
||||
return fieldsByName(null, fieldNames.toArray(EMPTY_STRING));
|
||||
}
|
||||
|
||||
static final Field<?>[] fieldsByName(String[] fieldNames) {
|
||||
@ -811,7 +830,7 @@ final class Tools {
|
||||
}
|
||||
|
||||
static final Field<?>[] fieldsByName(String tableName, Collection<String> fieldNames) {
|
||||
return fieldsByName(tableName, fieldNames.toArray(new String[0]));
|
||||
return fieldsByName(tableName, fieldNames.toArray(EMPTY_STRING));
|
||||
}
|
||||
|
||||
static final Field<?>[] fieldsByName(String tableName, String[] fieldNames) {
|
||||
@ -3000,7 +3019,7 @@ final class Tools {
|
||||
result.add(fieldNames(col.size()));
|
||||
}
|
||||
|
||||
result.add(col.toArray(new String[0]));
|
||||
result.add(col.toArray(EMPTY_STRING));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@ -50,6 +50,7 @@ import static org.jooq.impl.RecordDelegate.RecordLifecycleType.DELETE;
|
||||
import static org.jooq.impl.RecordDelegate.RecordLifecycleType.REFRESH;
|
||||
import static org.jooq.impl.RecordDelegate.RecordLifecycleType.STORE;
|
||||
import static org.jooq.impl.RecordDelegate.RecordLifecycleType.UPDATE;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.settings;
|
||||
|
||||
import java.math.BigInteger;
|
||||
@ -142,7 +143,7 @@ public class UpdatableRecordImpl<R extends UpdatableRecord<R>> extends TableReco
|
||||
|
||||
@Override
|
||||
public final int store(Collection<? extends Field<?>> storeFields) {
|
||||
return store(storeFields.toArray(new Field[0]));
|
||||
return store(storeFields.toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -157,7 +158,7 @@ public class UpdatableRecordImpl<R extends UpdatableRecord<R>> extends TableReco
|
||||
|
||||
@Override
|
||||
public final int update(Collection<? extends Field<?>> storeFields) {
|
||||
return update(storeFields.toArray(new Field[0]));
|
||||
return update(storeFields.toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
private final int store0(Field<?>[] storeFields) {
|
||||
@ -345,7 +346,7 @@ public class UpdatableRecordImpl<R extends UpdatableRecord<R>> extends TableReco
|
||||
|
||||
@Override
|
||||
public final void refresh(Collection<? extends Field<?>> refreshFields) {
|
||||
refresh(refreshFields.toArray(new Field[0]));
|
||||
refresh(refreshFields.toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
Reference in New Issue
Block a user