[jOOQ/jOOQ#11009] Refactor some Tools methods. Java 6 fix.
This commit is contained in:
parent
fea20a899a
commit
9704a1c12c
@ -273,7 +273,7 @@ abstract class AbstractField<T> extends AbstractTypedNamed<T> implements Field<T
|
||||
|
||||
@Override
|
||||
public final SortField<Integer> sortAsc(Collection<T> sortList) {
|
||||
return Tools.isEmpty(sortList) ? sortConstant() : DSL.field(this, fieldsArray(sortList.toArray(), getDataType())).asc();
|
||||
return Tools.isEmpty(sortList) ? this.<Integer>sortConstant() : DSL.field(this, fieldsArray(sortList.toArray(), getDataType())).asc();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -284,7 +284,7 @@ abstract class AbstractField<T> extends AbstractTypedNamed<T> implements Field<T
|
||||
|
||||
@Override
|
||||
public final SortField<Integer> sortDesc(Collection<T> sortList) {
|
||||
return Tools.isEmpty(sortList) ? sortConstant() : DSL.field(this, fieldsArray(sortList.toArray(), getDataType())).desc();
|
||||
return Tools.isEmpty(sortList) ? this.<Integer>sortConstant() : DSL.field(this, fieldsArray(sortList.toArray(), getDataType())).desc();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -295,7 +295,7 @@ abstract class AbstractField<T> extends AbstractTypedNamed<T> implements Field<T
|
||||
|
||||
@Override
|
||||
public final <Z> SortField<Z> sort(Map<T, Z> sortMap) {
|
||||
return sortMap == null || sortMap.isEmpty() ? sortConstant() : DSL.case_(this).mapValues(sortMap).asc();
|
||||
return sortMap == null || sortMap.isEmpty() ? this.<Z>sortConstant() : DSL.case_(this).mapValues(sortMap).asc();
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
|
||||
@ -37,6 +37,9 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Tools.fieldsArray;
|
||||
import static org.jooq.impl.Tools.row0;
|
||||
|
||||
import org.jooq.Converter;
|
||||
import org.jooq.EmbeddableRecord;
|
||||
import org.jooq.Field;
|
||||
@ -91,7 +94,7 @@ public class EmbeddableRecordImpl<R extends EmbeddableRecord<R>> extends Abstrac
|
||||
*/
|
||||
@Override
|
||||
public Row valuesRow() {
|
||||
return Tools.row0(Tools.fields(intoArray(), fields.fields.fields()));
|
||||
return row0(fieldsArray(intoArray(), fields.fields.fields()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@ -86,6 +86,6 @@ class RecordImplN extends AbstractRecord implements InternalRecord {
|
||||
|
||||
@Override
|
||||
public final RowImplN valuesRow() {
|
||||
return new RowImplN(Tools.fields(values, fields.fields.fields));
|
||||
return new RowImplN(Tools.fieldsArray(values, fields.fields.fields));
|
||||
}
|
||||
}
|
||||
|
||||
@ -697,7 +697,7 @@ implements
|
||||
|
||||
@Override
|
||||
public final Condition and(Record record) {
|
||||
return and(new RowImplN(Tools.fields(record.intoArray(), record.fields())));
|
||||
return and(new RowImplN(Tools.fieldsArray(record.intoArray(), record.fields())));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@ -51,7 +51,9 @@ import static org.jooq.conf.SettingsTools.updatablePrimaryKeys;
|
||||
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.fieldsArray;
|
||||
import static org.jooq.impl.Tools.indexOrFail;
|
||||
import static org.jooq.impl.Tools.row0;
|
||||
import static org.jooq.impl.Tools.settings;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.DATA_OMIT_RETURNING_CLAUSE;
|
||||
|
||||
@ -136,7 +138,7 @@ public class TableRecordImpl<R extends TableRecord<R>> extends AbstractRecord im
|
||||
*/
|
||||
@Override
|
||||
public Row valuesRow() {
|
||||
return Tools.row0(Tools.fields(intoArray(), fields.fields.fields()));
|
||||
return row0(fieldsArray(intoArray(), fields.fields.fields()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@ -1850,12 +1850,17 @@ final class Tools {
|
||||
}
|
||||
|
||||
static final <T> List<Field<T>> fields(T[] values) {
|
||||
if (values == null)
|
||||
return new ArrayList<>();
|
||||
return asList(fieldsArray(values));
|
||||
}
|
||||
|
||||
List<Field<T>> result = new ArrayList<>(values.length);
|
||||
@SuppressWarnings("unchecked")
|
||||
static final <T> Field<T>[] fieldsArray(T[] values) {
|
||||
if (values == null)
|
||||
return (Field<T>[]) EMPTY_FIELD;
|
||||
|
||||
Field<T>[] result = new Field[values.length];
|
||||
for (int i = 0; i < values.length; i++)
|
||||
result.add(field(values[i]));
|
||||
result[i] = field(values[i]);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -1872,16 +1877,7 @@ final class Tools {
|
||||
}
|
||||
|
||||
static final List<Field<?>> fields(Object[] values, Field<?>[] fields) {
|
||||
if (values == null || fields == null)
|
||||
return new ArrayList<>();
|
||||
|
||||
int length = Math.min(values.length, fields.length);
|
||||
List<Field<?>> result = new ArrayList<>(length);
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
result.add(field(values[i], fields[i]));
|
||||
|
||||
return result;
|
||||
return asList(fieldsArray(values, fields));
|
||||
}
|
||||
|
||||
static final Field<?>[] fieldsArray(Object[] values, Field<?>[] fields) {
|
||||
@ -1897,39 +1893,8 @@ final class Tools {
|
||||
return result;
|
||||
}
|
||||
|
||||
static final <T> List<Field<T>> fields(Object[] values, Class<T> type) {
|
||||
if (values == null || type == null)
|
||||
return new ArrayList<>();
|
||||
|
||||
List<Field<T>> result = new ArrayList<>(values.length);
|
||||
for (int i = 0; i < values.length; i++)
|
||||
result.add(field(values[i], type));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static final List<Field<?>> fields(Object[] values, Class<?>[] types) {
|
||||
if (values == null || types == null)
|
||||
return new ArrayList<>();
|
||||
|
||||
int length = Math.min(values.length, types.length);
|
||||
List<Field<?>> result = new ArrayList<>(length);
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
result.add(field(values[i], types[i]));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static final <T> List<Field<T>> fields(Object[] values, DataType<T> type) {
|
||||
if (values == null || type == null)
|
||||
return new ArrayList<>();
|
||||
|
||||
List<Field<T>> result = new ArrayList<>(values.length);
|
||||
for (Object value : values)
|
||||
result.add(field(value, type));
|
||||
|
||||
return result;
|
||||
return asList(fieldsArray(values, type));
|
||||
}
|
||||
|
||||
static final <T> List<Field<T>> fields(Collection<?> values, DataType<T> type) {
|
||||
@ -1943,31 +1908,6 @@ final class Tools {
|
||||
return result;
|
||||
}
|
||||
|
||||
static final List<Field<?>> fields(Object[] values, DataType<?>[] types) {
|
||||
if (values == null || types == null)
|
||||
return new ArrayList<>();
|
||||
|
||||
int length = Math.min(values.length, types.length);
|
||||
List<Field<?>> result = new ArrayList<>(length);
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
result.add(field(values[i], types[i]));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static final <T> Field<T>[] fieldsArray(T[] values) {
|
||||
if (values == null)
|
||||
return (Field<T>[]) EMPTY_FIELD;
|
||||
|
||||
Field<T>[] result = new Field[values.length];
|
||||
for (int i = 0; i < values.length; i++)
|
||||
result[i] = field(values[i]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static final <T> Field<T>[] fieldsArray(Object[] values, DataType<T> type) {
|
||||
if (values == null)
|
||||
@ -1980,6 +1920,10 @@ final class Tools {
|
||||
return result;
|
||||
}
|
||||
|
||||
static final List<Field<?>> fields(Object[] values, DataType<?>[] types) {
|
||||
return asList(fieldsArray(values, types));
|
||||
}
|
||||
|
||||
static final Field<?>[] fieldsArray(Object[] values, DataType<?>[] types) {
|
||||
if (values == null || types == null)
|
||||
return EMPTY_FIELD;
|
||||
|
||||
@ -39,6 +39,8 @@ package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.DefaultExecuteContext.localConfiguration;
|
||||
import static org.jooq.impl.DefaultExecuteContext.localData;
|
||||
import static org.jooq.impl.Tools.fieldsArray;
|
||||
import static org.jooq.impl.Tools.row0;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.sql.SQLInput;
|
||||
@ -92,7 +94,7 @@ public class UDTRecordImpl<R extends UDTRecord<R>> extends AbstractRecord implem
|
||||
*/
|
||||
@Override
|
||||
public Row valuesRow() {
|
||||
return Tools.row0(Tools.fields(intoArray(), fields.fields.fields()));
|
||||
return row0(fieldsArray(intoArray(), fields.fields.fields()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
Reference in New Issue
Block a user