[jOOQ/jOOQ#11031] Extract common API from Cursor | Record | RecordType |

Result | Row | TableLike | UDT to new Fields type
This commit is contained in:
Lukas Eder 2020-11-26 15:31:06 +01:00
parent 056ca3a427
commit cbd9e9ef01
48 changed files with 847 additions and 1427 deletions

View File

@ -77,7 +77,7 @@ import org.jetbrains.annotations.Nullable;
* @param <R> The cursor's record type
* @author Lukas Eder
*/
public interface Cursor<R extends Record> extends Iterable<R>, Formattable , AutoCloseable {
public interface Cursor<R extends Record> extends Fields, Iterable<R>, Formattable , AutoCloseable {
/**
* Get this cursor's row type.
@ -85,129 +85,6 @@ public interface Cursor<R extends Record> extends Iterable<R>, Formattable , Aut
@NotNull
RecordType<R> recordType();
/**
* Get this cursor's fields as a {@link Row}.
*/
@NotNull
Row fieldsRow();
/**
* Get a specific field from this Cursor.
* <p>
* This will return:
* <ul>
* <li>A field that is the same as the argument field (by identity
* comparison).</li>
* <li>A field that is equal to the argument field (exact matching fully
* qualified name).</li>
* <li>A field that is equal to the argument field (partially matching
* qualified name).</li>
* <li>A field whose name is equal to the name of the argument field.</li>
* <li><code>null</code> otherwise.
* </ul>
* If several fields have the same name, the first one is returned and a
* warning is logged.
*
* @see Row#field(Field)
*/
@Nullable
<T> Field<T> field(Field<T> field);
/**
* Get a specific field from this Cursor.
*
* @see Row#field(String)
*/
@Nullable
Field<?> field(String name);
/**
* Get a specific qualified field from this Cursor.
*
* @see Row#field(Name)
*/
@Nullable
Field<?> field(Name name);
/**
* Get a specific field from this Cursor.
*
* @see Row#field(int)
*/
@Nullable
Field<?> field(int index);
/**
* Get all fields from this Cursor.
*
* @see Row#fields()
*/
@NotNull
Field<?>[] fields();
/**
* Get all fields from this Cursor, providing some fields.
*
* @return All available fields
* @see Row#fields(Field...)
*/
@NotNull
Field<?>[] fields(Field<?>... fields);
/**
* Get all fields from this Cursor, providing some field names.
*
* @return All available fields
* @see Row#fields(String...)
*/
@NotNull
Field<?>[] fields(String... fieldNames);
/**
* Get all fields from this Cursor, providing some field names.
*
* @return All available fields
* @see Row#fields(Name...)
*/
@NotNull
Field<?>[] fields(Name... fieldNames);
/**
* Get all fields from this Cursor, providing some field indexes.
*
* @return All available fields
* @see Row#fields(int...)
*/
@NotNull
Field<?>[] fields(int... fieldIndexes);
/**
* Get a field's index from this cursor.
*
* @param field The field to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this cursor.
*/
int indexOf(Field<?> field);
/**
* Get a field's index from this cursor.
*
* @param fieldName The field name to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this cursor.
*/
int indexOf(String fieldName);
/**
* Get a field's index from this cursor.
*
* @param fieldName The field name to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this cursor
*/
int indexOf(Name fieldName);
/**
* Check whether this cursor has a next record.
* <p>

View File

@ -0,0 +1,307 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq;
import java.util.stream.Stream;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* A common super type for various types that can provide a set of fields,
* similar to a {@link Record}.
*
* @author Lukas Eder
*/
public interface Fields {
/**
* Get all fields.
*/
@NotNull
Field<?>[] fields();
/**
* Get all fields as a {@link Row}.
*/
@NotNull
Row fieldsRow();
/**
* Get this table's fields as a {@link Stream}, if this table knows its
* field references.
*/
@NotNull
Stream<Field<?>> fieldStream();
/**
* Get a field by field reference.
* <p>
* This will return:
* <ul>
* <li>A field that is the same as the argument field (by identity
* comparison).</li>
* <li>A field that is equal to the argument field (exact matching fully
* qualified name).</li>
* <li>A field that is equal to the argument field (partially matching
* qualified name).</li>
* <li>A field whose name is equal to the name of the argument field.</li>
* <li><code>null</code> otherwise.
* </ul>
* If several fields have the same name, the first one is returned and a
* warning is logged.
*/
@Nullable
<T> Field<T> field(Field<T> field);
/**
* Get a field by unqualified name.
*
* @param name The unqualified name of the field
*/
@Nullable
Field<?> field(String name);
/**
* Get a field by unqualified name coerced to <code>type</code>.
*
* @param name The unqualified name of the field
* @param type The type to coerce the resulting field to
*/
@Nullable
<T> Field<T> field(String name, Class<T> type);
/**
* Get a field by unqualified name coerced to <code>dataType</code>.
*
* @param name The unqualified name of the field
* @param dataType The data type to coerce the resulting field to
*/
@Nullable
<T> Field<T> field(String name, DataType<T> dataType);
/**
* Get a field by qualified name.
*
* @param name The qualified name of the field
*/
@Nullable
Field<?> field(Name name);
/**
* Get a field by qualified name coerced to <code>type</code>.
*
* @param name The qualified name of the field
* @param type The type to coerce the resulting field to
*/
@Nullable
<T> Field<T> field(Name name, Class<T> type);
/**
* Get a field by qualified name coerced to <code>dataType</code>.
*
* @param name The qualified name of the field
* @param dataType The data type to coerce the resulting field to
*/
@Nullable
<T> Field<T> field(Name name, DataType<T> dataType);
/**
* Get a field by index.
*
* @param index The 0-based index of the field
*/
@Nullable
Field<?> field(int index);
/**
* Get a field by index coerced to <code>type</code>.
*
* @param index The 0-based index of the field
* @param type The type to coerce the resulting field to
*/
@Nullable
<T> Field<T> field(int index, Class<T> type);
/**
* Get a field by index coerced to <code>dataType</code>.
*
* @param index The 0-based index of the field
* @param dataType The data type to coerce the resulting field to
*/
@Nullable
<T> Field<T> field(int index, DataType<T> dataType);
/**
* Get all fields, filtering by some fields.
*
* @param fields The fields to include after looking them up via
* {@link #field(Field)}.
* @see #field(Field)
*/
@NotNull
Field<?>[] fields(Field<?>... fields);
/**
* Get all fields, filtering by some unqualified field names.
*
* @param names The unqualified field names to include after looking them up
* via {@link #field(String)}.
* @see #field(String)
*/
@NotNull
Field<?>[] fields(String... names);
/**
* Get all fields, filtering by some qualified field names.
*
* @param names The qualified field names to include after looking them up
* via {@link #field(Name)}.
* @see #field(Name)
*/
@NotNull
Field<?>[] fields(Name... names);
/**
* Get all fields, filtering by some field indexes.
*
* @param names The 0-based field indexes to include after looking them up
* via {@link #field(int)}.
* @see #field(int)
*/
@NotNull
Field<?>[] fields(int... indexes);
/**
* Get a field's index from this type.
*
* @param field The field to look for
* @return The field's 0-based index or <code>-1</code> if the field is not
* available.
*/
int indexOf(Field<?> field);
/**
* Get a field's index from this type.
*
* @param name The unqualified field name to look for
* @return The field's 0-based index or <code>-1</code> if the field is not
* available.
*/
int indexOf(String name);
/**
* Get a field's index from this type.
*
* @param name The qualified field name to look for
* @return The field's 0-based index or <code>-1</code> if the field is not
* available.
*/
int indexOf(Name name);
/**
* Get an array of field types for this type.
* <p>
* Entries in the resulting array correspond to {@link Field#getType()} for
* the corresponding <code>Field</code> in {@link #fields()}
*/
@NotNull
Class<?>[] types();
/**
* Get the field type for a given field index.
*
* @param index The field's 0-based index
*/
@Nullable
Class<?> type(int index);
/**
* Get the field type for a given unqualified field name.
*
* @param name The unqualified field name
*/
@Nullable
Class<?> type(String name);
/**
* Get the field type for a given qualified field name.
*
* @param name The qualified field name
*/
@Nullable
Class<?> type(Name name);
/**
* Get an array of field data types for this type.
* <p>
* Entries in the resulting array correspond to {@link Field#getDataType()} for
* the corresponding <code>Field</code> in {@link #fields()}
*/
@NotNull
DataType<?>[] dataTypes();
/**
* Get the field data type for a given field index.
*
* @param index The field's 0-based index
*/
@Nullable
DataType<?> dataType(int index);
/**
* Get the field data type for a given qualified field name.
*
* @param name The qualified field name
*/
@Nullable
DataType<?> dataType(String name);
/**
* Get the field data type for a given qualified field name.
*
* @param name The qualified field name
*/
@Nullable
DataType<?> dataType(Name name);
}

View File

@ -125,130 +125,7 @@ import org.jetbrains.annotations.Nullable;
* @author Lukas Eder
* @see Result
*/
public interface Record extends Attachable, Comparable<Record>, Formattable {
/**
* Get this record's fields as a {@link Row}.
*/
@NotNull
Row fieldsRow();
/**
* Get a specific field from this Record.
* <p>
* This will return:
* <ul>
* <li>A field that is the same as the argument field (by identity
* comparison).</li>
* <li>A field that is equal to the argument field (exact matching fully
* qualified name).</li>
* <li>A field that is equal to the argument field (partially matching
* qualified name).</li>
* <li>A field whose name is equal to the name of the argument field.</li>
* <li><code>null</code> otherwise.
* </ul>
* If several fields have the same name, the first one is returned and a
* warning is logged.
*
* @see Row#field(Field)
*/
@Nullable
<T> Field<T> field(Field<T> field);
/**
* Get a specific field from this Record.
*
* @see Row#field(String)
*/
@Nullable
Field<?> field(String name);
/**
* Get a specific qualified field from this Record.
*
* @see Row#field(Name)
*/
@Nullable
Field<?> field(Name name);
/**
* Get a specific field from this Record.
*
* @see Row#field(int)
*/
@Nullable
Field<?> field(int index);
/**
* Get all fields from this Record.
*
* @see Row#fields()
*/
@NotNull
Field<?>[] fields();
/**
* Get all fields from this Record, providing some fields.
*
* @return All available fields
* @see Row#fields(Field...)
*/
@NotNull
Field<?>[] fields(Field<?>... fields);
/**
* Get all fields from this Record, providing some field names.
*
* @return All available fields
* @see Row#fields(String...)
*/
@NotNull
Field<?>[] fields(String... fieldNames);
/**
* Get all fields from this Record, providing some field names.
*
* @return All available fields
* @see Row#fields(Name...)
*/
@NotNull
Field<?>[] fields(Name... fieldNames);
/**
* Get all fields from this Record, providing some field indexes.
*
* @return All available fields
* @see Row#fields(int...)
*/
@NotNull
Field<?>[] fields(int... fieldIndexes);
/**
* Get a field's index from this record.
*
* @param field The field to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this record.
*/
int indexOf(Field<?> field);
/**
* Get a field's index from this record.
*
* @param fieldName The field name to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this record.
*/
int indexOf(String fieldName);
/**
* Get a field's index from this record.
*
* @param fieldName The field name to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this record
*/
int indexOf(Name fieldName);
public interface Record extends Fields, Attachable, Comparable<Record>, Formattable {
/**
* Get this record's values as a {@link Row}.
@ -398,7 +275,7 @@ public interface Record extends Attachable, Comparable<Record>, Formattable {
/**
* Get a value from this record, providing a field index.
*
* @param index The field's index
* @param index The 0-based field index in this record.
* @return The value of a field's index contained in this record
* @throws IllegalArgumentException If the argument index is not contained
* in the record
@ -414,7 +291,7 @@ public interface Record extends Attachable, Comparable<Record>, Formattable {
* value to <code>U</code>
*
* @param <U> The conversion type parameter
* @param index The field's index
* @param index The 0-based field index in this record.
* @param type The conversion type
* @return The value of a field's index contained in this record
* @throws IllegalArgumentException If the argument index is not contained
@ -428,7 +305,7 @@ public interface Record extends Attachable, Comparable<Record>, Formattable {
* Get a converted value from this record, providing a field index.
*
* @param <U> The conversion type parameter
* @param index The field's index
* @param index The 0-based field index in this record.
* @param converter The data type converter
* @return The value of a field's index contained in this record
* @throws IllegalArgumentException If the argument index is not contained
@ -533,6 +410,7 @@ public interface Record extends Attachable, Comparable<Record>, Formattable {
* the database. Every record also references the originally fetched values.
* This method returns such an original value for a field.
*
* @param fieldIndex The 0-based field index in this record.
* @see #original()
*/
@Nullable
@ -589,6 +467,7 @@ public interface Record extends Attachable, Comparable<Record>, Formattable {
* Check if a field's value has been changed from its original as fetched
* from the database.
*
* @param fieldIndex The 0-based field index in this record.
* @see #changed()
* @see #original(int)
*/
@ -647,6 +526,7 @@ public interface Record extends Attachable, Comparable<Record>, Formattable {
* {@link #original(int)} value will be reset to the corresponding "current"
* value as well
*
* @param fieldIndex The 0-based field index in this record.
* @see #changed()
* @see #changed(int)
*/
@ -693,6 +573,8 @@ public interface Record extends Attachable, Comparable<Record>, Formattable {
/**
* Reset a given value to its {@link #original(int)} value and its
* {@link #changed(int)} flag to <code>false</code>.
*
* @param fieldIndex The 0-based field index in this record.
*/
void reset(int fieldIndex);
@ -1249,7 +1131,7 @@ public interface Record extends Attachable, Comparable<Record>, Formattable {
* contained in the <code>fieldIndexes</code> argument will be mapped.
*
* @param source The source object to copy data from
* @param fieldIndexes The record's fields indexes to use for mapping
* @param fieldIndexes The record's 0-based field indexes to use for mapping
* @throws MappingException wrapping any reflection exception that might
* have occurred while mapping records
* @see #into(Class)
@ -1332,6 +1214,7 @@ public interface Record extends Attachable, Comparable<Record>, Formattable {
* This is the same as {@link #fromMap(Map)}, except that only fields
* contained in the <code>fieldIndexes</code> argument will be mapped.
*
* @param fieldIndexes The 0-based field indexes in this record.
* @see #intoMap()
* @see #fromMap(Map)
*/
@ -1407,6 +1290,7 @@ public interface Record extends Attachable, Comparable<Record>, Formattable {
* fields contained in the <code>fieldIndexes</code> argument will be
* mapped.
*
* @param fieldIndexes The 0-based field indexes in this record.
* @see #intoArray()
* @see #fromArray(Object...)
*/
@ -1752,6 +1636,7 @@ public interface Record extends Attachable, Comparable<Record>, Formattable {
* [#2211] Future versions of jOOQ might remove this method. It is
* recommended to use {@link #get(int)} instead.
*
* @param index The 0-based field index in this record.
* @see #get(int)
*/
Object getValue(int index) throws IllegalArgumentException;
@ -1759,7 +1644,7 @@ public interface Record extends Attachable, Comparable<Record>, Formattable {
/**
* Get a value from this record, providing a field index.
*
* @param index The field's index
* @param index The 0-based field index in this record.
* @param defaultValue The default value instead of <code>null</code>
* @return The value of a field's index contained in this record, or
* defaultValue, if <code>null</code>
@ -1776,6 +1661,7 @@ public interface Record extends Attachable, Comparable<Record>, Formattable {
* [#2211] Future versions of jOOQ might remove this method. It is
* recommended to use {@link #get(int, Class)} instead.
*
* @param index The 0-based field index in this record.
* @see #get(int, Class)
*/
<T> T getValue(int index, Class<? extends T> type) throws IllegalArgumentException, DataTypeException;
@ -1788,7 +1674,7 @@ public interface Record extends Attachable, Comparable<Record>, Formattable {
* value to <code>U</code>
*
* @param <U> The conversion type parameter
* @param index The field's index
* @param index The 0-based field index in this record.
* @param type The conversion type
* @param defaultValue The default value instead of <code>null</code>
* @return The value of a field's index contained in this record, or
@ -1808,6 +1694,7 @@ public interface Record extends Attachable, Comparable<Record>, Formattable {
* [#2211] Future versions of jOOQ might remove this method. It is
* recommended to use {@link #get(int, Converter)} instead.
*
* @param index The 0-based field index in this record.
* @see #get(int, Converter)
*/
<U> U getValue(int index, Converter<?, ? extends U> converter) throws IllegalArgumentException, DataTypeException;
@ -1816,7 +1703,7 @@ public interface Record extends Attachable, Comparable<Record>, Formattable {
* Get a converted value from this record, providing a field index.
*
* @param <U> The conversion type parameter
* @param index The field's index
* @param index The 0-based field index in this record.
* @param converter The data type converter
* @param defaultValue The default value instead of <code>null</code>
* @return The value of a field's index contained in this record, or

View File

@ -37,9 +37,6 @@
*/
package org.jooq;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* A record type for {@link Table}, {@link Cursor}, {@link Result} and other
* objects.
@ -54,265 +51,11 @@ import org.jetbrains.annotations.Nullable;
*
* @author Lukas Eder
*/
public interface RecordType<R extends Record> {
public interface RecordType<R extends Record> extends Fields {
/**
* Get the degree of this record type.
*/
int size();
/**
* Get a specific field from this record type.
* <p>
* This will return:
* <ul>
* <li>A field that is the same as the argument field (by identity
* comparison).</li>
* <li>A field that is equal to the argument field (exact matching fully
* qualified name).</li>
* <li>A field that is equal to the argument field (partially matching
* qualified name).</li>
* <li>A field whose name is equal to the name of the argument field.</li>
* <li><code>null</code> otherwise.
* </ul>
* If several fields have the same name, the first one is returned and a
* warning is logged.
*
* @param <T> The generic field type
* @param field The field to fetch
* @return The field itself or an aliased field
*/
@Nullable
<T> Field<T> field(Field<T> field);
/**
* Get a specific field from this record type.
*
* @param fieldName The field to fetch
* @return The field with the given name
*/
@Nullable
Field<?> field(String fieldName);
/**
* Get a specific field from this record type coerced to <code>type</code>.
*
* @param fieldName The field to fetch
* @param type The type to coerce the resulting field to
* @return The field with the given name
*/
@Nullable
<T> Field<T> field(String fieldName, Class<T> type);
/**
* Get a specific field from this record type coerced to <code>dataType</code>.
*
* @param fieldName The field to fetch
* @param dataType The data type to coerce the resulting field to
* @return The field with the given name
*/
@Nullable
<T> Field<T> field(String fieldName, DataType<T> dataType);
/**
* Get a specific qualified field from this record type.
*
* @param fieldName The field to fetch
* @return The field with the given name
*/
@Nullable
Field<?> field(Name fieldName);
/**
* Get a specific field from this record type coerced to <code>type</code>.
*
* @param fieldName The field to fetch
* @param type The type to coerce the resulting field to
* @return The field with the given name
*/
@Nullable
<T> Field<T> field(Name fieldName, Class<T> type);
/**
* Get a specific field from this record type coerced to <code>dataType</code>.
*
* @param fieldName The field to fetch
* @param dataType The data type to coerce the resulting field to
* @return The field with the given name
*/
@Nullable
<T> Field<T> field(Name fieldName, DataType<T> dataType);
/**
* Get a specific field from this record type.
*
* @param fieldIndex The field's index of the field to fetch
* @return The field with the given name
*/
@Nullable
Field<?> field(int fieldIndex);
/**
* Get a specific field from this record type coerced to <code>type</code>.
*
* @param fieldIndex The field's index of the field to fetch
* @param type The type to coerce the resulting field to
* @return The field with the given name
*/
@Nullable
<T> Field<T> field(int fieldIndex, Class<T> type);
/**
* Get a specific field from this record type coerced to <code>dataType</code>.
*
* @param fieldIndex The field's index of the field to fetch
* @param dataType The data type to coerce the resulting field to
* @return The field with the given name
*/
@Nullable
<T> Field<T> field(int fieldIndex, DataType<T> dataType);
/**
* Get all fields from this record type.
*
* @return All available fields
*/
@NotNull
Field<?>[] fields();
/**
* Get all fields from this record type, providing some fields.
*
* @return All available fields
* @see #field(Field)
*/
@NotNull
Field<?>[] fields(Field<?>... fields);
/**
* Get all fields from this record type, providing some field names.
*
* @return All available fields
* @see #field(String)
*/
@NotNull
Field<?>[] fields(String... fieldNames);
/**
* Get all fields from this record type, providing some field names.
*
* @return All available fields
* @see #field(Name)
*/
@NotNull
Field<?>[] fields(Name... fieldNames);
/**
* Get all fields from this record type, providing some field indexes.
*
* @return All available fields
* @see #field(int)
*/
@NotNull
Field<?>[] fields(int... fieldIndexes);
/**
* Get a field's index from this record type.
*
* @param field The field to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this <code>Row</code>
*/
int indexOf(Field<?> field);
/**
* Get a field's index from this record type.
*
* @param fieldName The field name to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this <code>Row</code>
*/
int indexOf(String fieldName);
/**
* Get a field's index from this record type.
*
* @param fieldName The field name to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this <code>Row</code>
*/
int indexOf(Name fieldName);
/**
* Get an array of types for this record type.
* <p>
* Entries in the resulting array correspond to {@link Field#getType()} for
* the corresponding <code>Field</code> in {@link #fields()}
*/
@NotNull
Class<?>[] types();
/**
* Get the type for a given field index.
*
* @param fieldIndex The field's index of the field's type to fetch
* @return The field's type
*/
@Nullable
Class<?> type(int fieldIndex);
/**
* Get the type for a given field name.
*
* @param fieldName The field's name of the field's type to fetch
* @return The field's type
*/
@Nullable
Class<?> type(String fieldName);
/**
* Get the type for a given field name.
*
* @param fieldName The field's name of the field's type to fetch
* @return The field's type
*/
@Nullable
Class<?> type(Name fieldName);
/**
* Get an array of data types for this record type.
* <p>
* Entries in the resulting array correspond to {@link Field#getDataType()}
* for the corresponding <code>Field</code> in {@link #fields()}
*/
@NotNull
DataType<?>[] dataTypes();
/**
* Get the data type for a given field index.
*
* @param fieldIndex The field's index of the field's data type to fetch
* @return The field's data type
*/
@Nullable
DataType<?> dataType(int fieldIndex);
/**
* Get the data type for a given field name.
*
* @param fieldName The field's name of the field's data type to fetch
* @return The field's data type
*/
@Nullable
DataType<?> dataType(String fieldName);
/**
* Get the data type for a given field name.
*
* @param fieldName The field's name of the field's data type to fetch
* @return The field's data type
*/
@Nullable
DataType<?> dataType(Name fieldName);
}

View File

@ -60,7 +60,7 @@ import org.jetbrains.annotations.Nullable;
* @author Lukas Eder
* @see SelectQuery#getResult()
*/
public interface Result<R extends Record> extends List<R>, Attachable, Formattable {
public interface Result<R extends Record> extends Fields, List<R>, Attachable, Formattable {
/**
* Get this result's record type.
@ -68,177 +68,6 @@ public interface Result<R extends Record> extends List<R>, Attachable, Formattab
@NotNull
RecordType<R> recordType();
/**
* Get this result's fields as a {@link Row}.
*/
@NotNull
Row fieldsRow();
/**
* Get a specific field from this Result.
* <p>
* This will return:
* <ul>
* <li>A field that is the same as the argument field (by identity
* comparison).</li>
* <li>A field that is equal to the argument field (exact matching fully
* qualified name).</li>
* <li>A field that is equal to the argument field (partially matching
* qualified name).</li>
* <li>A field whose name is equal to the name of the argument field.</li>
* <li><code>null</code> otherwise.
* </ul>
* If several fields have the same name, the first one is returned and a
* warning is logged.
*
* @see Row#field(Field)
*/
@Nullable
<T> Field<T> field(Field<T> field);
/**
* Get a specific field from this Result.
*
* @see Row#field(String)
*/
@Nullable
Field<?> field(String name);
/**
* Get a specific field from this Result, coerced to <code>type</code>.
*
* @see Row#field(String, Class)
*/
@Nullable
<T> Field<T> field(String name, Class<T> type);
/**
* Get a specific field from this Result, coerced to <code>dataType</code>.
*
* @see Row#field(String, DataType)
*/
@Nullable
<T> Field<T> field(String name, DataType<T> dataType);
/**
* Get a specific field from this Result.
*
* @see Row#field(Name)
*/
@Nullable
Field<?> field(Name name);
/**
* Get a specific field from this Result, coerced to <code>type</code>.
*
* @see Row#field(Name, Class)
*/
@Nullable
<T> Field<T> field(Name name, Class<T> type);
/**
* Get a specific field from this Result, coerced to <code>dataType</code>.
*
* @see Row#field(Name, DataType)
*/
@Nullable
<T> Field<T> field(Name name, DataType<T> dataType);
/**
* Get a specific field from this Result.
*
* @see Row#field(int)
*/
@Nullable
Field<?> field(int index);
/**
* Get a specific field from this Result, coerced to <code>type</code>.
*
* @see Row#field(int, Class)
*/
@Nullable
<T> Field<T> field(int index, Class<T> type);
/**
* Get a specific field from this Result, coerced to <code>dataType</code>.
*
* @see Row#field(int, DataType)
*/
@Nullable
<T> Field<T> field(int index, DataType<T> dataType);
/**
* Get all fields from this Result.
*
* @see Row#fields()
*/
@NotNull
Field<?>[] fields();
/**
* Get all fields from this Result, providing some fields.
*
* @return All available fields
* @see Row#fields(Field...)
*/
@NotNull
Field<?>[] fields(Field<?>... fields);
/**
* Get all fields from this Result, providing some field names.
*
* @return All available fields
* @see Row#fields(String...)
*/
@NotNull
Field<?>[] fields(String... fieldNames);
/**
* Get all fields from this Result, providing some field names.
*
* @return All available fields
* @see Row#fields(Name...)
*/
@NotNull
Field<?>[] fields(Name... fieldNames);
/**
* Get all fields from this Result, providing some field indexes.
*
* @return All available fields
* @see Row#fields(int...)
*/
@NotNull
Field<?>[] fields(int... fieldIndexes);
/**
* Get a field's index from this result.
*
* @param field The field to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this result.
*/
int indexOf(Field<?> field);
/**
* Get a field's index from this result.
*
* @param fieldName The field name to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this result.
*/
int indexOf(String fieldName);
/**
* Get a field's index from this result.
*
* @param fieldName The field name to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this result
*/
int indexOf(Name fieldName);
/**
* Convenience method to fetch a value at a given position in the result.
*

View File

@ -37,12 +37,9 @@
*/
package org.jooq;
import java.util.stream.Stream;
import org.jooq.impl.DSL;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* A row value expression.
@ -80,275 +77,13 @@ import org.jetbrains.annotations.Nullable;
*
* @author Lukas Eder
*/
public interface Row extends FieldOrRow {
public interface Row extends Fields, FieldOrRow {
/**
* Get the degree of this row value expression.
*/
int size();
/**
* Get the fields from this row as a {@link Stream}.
*/
@NotNull
Stream<Field<?>> fieldStream();
/**
* Get a specific field from this row.
* <p>
* This will return:
* <ul>
* <li>A field that is the same as the argument field (by identity
* comparison).</li>
* <li>A field that is equal to the argument field (exact matching fully
* qualified name).</li>
* <li>A field that is equal to the argument field (partially matching
* qualified name).</li>
* <li>A field whose name is equal to the name of the argument field.</li>
* <li><code>null</code> otherwise.
* </ul>
* If several fields have the same name, the first one is returned and a
* warning is logged.
*
* @param <T> The generic field type
* @param field The field to fetch
* @return The field itself or an aliased field
*/
@Nullable
<T> Field<T> field(Field<T> field);
/**
* Get a specific field from this row.
*
* @param fieldName The field to fetch
* @return The field with the given name
*/
@Nullable
Field<?> field(String fieldName);
/**
* Get a specific field from this row and coerce it to <code>type</code>.
*
* @param fieldName The field to fetch
* @param type The type to coerce the resulting field to
* @return The field with the given name
*/
@Nullable
<T> Field<T> field(String fieldName, Class<T> type);
/**
* Get a specific field from this row and coerce it to <code>dataType</code>.
*
* @param fieldName The field to fetch
* @param dataType The type to coerce the resulting field to
* @return The field with the given name
*/
@Nullable
<T> Field<T> field(String fieldName, DataType<T> dataType);
/**
* Get a specific field from this row.
*
* @param fieldName The field to fetch
* @return The field with the given name
*/
@Nullable
Field<?> field(Name fieldName);
/**
* Get a specific field from this row and coerce it to <code>type</code>.
*
* @param fieldName The field to fetch
* @param type The type to coerce the resulting field to
* @return The field with the given name
*/
@Nullable
<T> Field<T> field(Name fieldName, Class<T> type);
/**
* Get a specific field from this row and coerce it to <code>dataType</code>.
*
* @param fieldName The field to fetch
* @param dataType The type to coerce the resulting field to
* @return The field with the given name
*/
@Nullable
<T> Field<T> field(Name fieldName, DataType<T> dataType);
/**
* Get a specific field from this row.
*
* @param fieldIndex The field's index of the field to fetch
* @return The field with the given name
*/
@Nullable
Field<?> field(int fieldIndex);
/**
* Get a specific field from this row and coerce it to <code>type</code>.
*
* @param fieldIndex The field's index of the field to fetch
* @param type The type to coerce the resulting field to
* @return The field with the given name
*/
@Nullable
<T> Field<T> field(int fieldIndex, Class<T> type);
/**
* Get a specific field from this row and coerce it to <code>dataType</code>.
*
* @param fieldIndex The field's index of the field to fetch
* @param dataType The type to coerce the resulting field to
* @return The field with the given name
*/
@Nullable
<T> Field<T> field(int fieldIndex, DataType<T> dataType);
/**
* Get all fields from this row.
*
* @return All available fields
*/
@NotNull
Field<?>[] fields();
/**
* Get all fields from this row, providing some fields.
*
* @return All available fields
* @see #field(Field)
*/
@NotNull
Field<?>[] fields(Field<?>... fields);
/**
* Get all fields from this row, providing some field names.
*
* @return All available fields
* @see #field(String)
*/
@NotNull
Field<?>[] fields(String... fieldNames);
/**
* Get all fields from this row, providing some field names.
*
* @return All available fields
* @see #field(Name)
*/
@NotNull
Field<?>[] fields(Name... fieldNames);
/**
* Get all fields from this row, providing some field indexes.
*
* @return All available fields
* @see #field(int)
*/
@NotNull
Field<?>[] fields(int... fieldIndexes);
/**
* Get a field's index from this row.
*
* @param field The field to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this <code>Row</code>
*/
int indexOf(Field<?> field);
/**
* Get a field's index from this row.
*
* @param fieldName The field name to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this <code>Row</code>
*/
int indexOf(String fieldName);
/**
* Get a field's index from this row.
*
* @param fieldName The field name to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this <code>Row</code>
*/
int indexOf(Name fieldName);
/**
* Get an array of types for this row.
* <p>
* Entries in the resulting array correspond to {@link Field#getType()} for
* the corresponding <code>Field</code> in {@link #fields()}
*/
@NotNull
Class<?>[] types();
/**
* Get the type for a given field index.
*
* @param fieldIndex The field's index of the field's type to fetch
* @return The field's type
*/
@Nullable
Class<?> type(int fieldIndex);
/**
* Get the type for a given field name.
*
* @param fieldName The field's name of the field's type to fetch
* @return The field's type
*/
@Nullable
Class<?> type(String fieldName);
/**
* Get the type for a given field name.
*
* @param fieldName The field's name of the field's type to fetch
* @return The field's type
*/
@Nullable
Class<?> type(Name fieldName);
/**
* Get an array of data types for this row.
* <p>
* Entries in the resulting array correspond to {@link Field#getDataType()}
* for the corresponding <code>Field</code> in {@link #fields()}
*/
@NotNull
DataType<?>[] dataTypes();
/**
* Get the data type for a given field index.
*
* @param fieldIndex The field's index of the field's data type to fetch
* @return The field's data type
*/
@Nullable
DataType<?> dataType(int fieldIndex);
/**
* Get the data type for a given field name.
*
* @param fieldName The field's name of the field's data type to fetch
* @return The field's data type
*/
@Nullable
DataType<?> dataType(String fieldName);
/**
* Get the data type for a given field name.
*
* @param fieldName The field's name of the field's data type to fetch
* @return The field's data type
*/
@Nullable
DataType<?> dataType(Name fieldName);
// ------------------------------------------------------------------------
// [NOT] NULL predicates
// ------------------------------------------------------------------------

View File

@ -39,10 +39,8 @@ package org.jooq;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Stream;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* An object that can behave like a table (a table-like object).
@ -52,203 +50,7 @@ import org.jetbrains.annotations.Nullable;
* @param <R> The record type
* @author Lukas Eder
*/
public interface TableLike<R extends Record> extends QueryPart {
/**
* Get this table's fields as a {@link Row}, if this table knows its field
* references.
*/
@NotNull
Row fieldsRow();
/**
* Get this table's fields as a {@link Stream}, if this table knows its
* field references.
*/
@NotNull
Stream<Field<?>> fieldStream();
/**
* Get a specific field from this table, if this table knows its field
* references.
* <p>
* This will return:
* <ul>
* <li>A field that is the same as the argument field (by identity
* comparison).</li>
* <li>A field that is equal to the argument field (exact matching fully
* qualified name).</li>
* <li>A field that is equal to the argument field (partially matching
* qualified name).</li>
* <li>A field whose name is equal to the name of the argument field.</li>
* <li><code>null</code> otherwise.
* </ul>
* If several fields have the same name, the first one is returned and a
* warning is logged.
*
* @see Row#field(Field)
*/
@Nullable
<T> Field<T> field(Field<T> field);
/**
* Get a specific field from this table, if this table knows its field
* references.
*
* @see Row#field(String)
*/
@Nullable
Field<?> field(String name);
/**
* Get a specific field from this table and coerce it to <code>type</code>,
* if this table knows its field references.
*
* @see Row#field(String, Class)
*/
@Nullable
<T> Field<T> field(String name, Class<T> type);
/**
* Get a specific field from this table and coerce it to
* <code>dataType</code>, if this table knows its field references.
*
* @see Row#field(String, DataType)
*/
@Nullable
<T> Field<T> field(String name, DataType<T> dataType);
/**
* Get a specific field from this table, if this table knows its field
* references.
*
* @see Row#field(Name)
*/
@Nullable
Field<?> field(Name name);
/**
* Get a specific field from this table and coerce it to <code>type</code>,
* if this table knows its field references.
*
* @see Row#field(Name, Class)
*/
@Nullable
<T> Field<T> field(Name name, Class<T> type);
/**
* Get a specific field from this table and coerce it to
* <code>dataType</code>, if this table knows its field references.
*
* @see Row#field(Name, DataType)
*/
@Nullable
<T> Field<T> field(Name name, DataType<T> dataType);
/**
* Get a specific field from this table, if this table knows its field
* references.
*
* @see Row#field(int)
*/
@Nullable
Field<?> field(int index);
/**
* Get a specific field from this table and coerce it to <code>type</code>,
* if this table knows its field references.
*
* @see Row#field(int, Class)
*/
@Nullable
<T> Field<T> field(int index, Class<T> type);
/**
* Get a specific field from this table and coerce it to
* <code>dataType</code>, if this table knows its field references.
*
* @see Row#field(int, DataType)
*/
@Nullable
<T> Field<T> field(int index, DataType<T> dataType);
/**
* Get all fields from this table, if this table knows its field references,
* or an empty array otherwise.
*
* @see Row#fields()
*/
@NotNull
Field<?>[] fields();
/**
* Get all fields from this table, providing some fields, if this table
* knows its field references.
*
* @return All available fields
* @see Row#fields(Field...)
*/
@NotNull
Field<?>[] fields(Field<?>... fields);
/**
* Get all fields from this table, providing some field names, if this table
* knows its field references.
*
* @return All available fields
* @see Row#fields(String...)
*/
@NotNull
Field<?>[] fields(String... fieldNames);
/**
* Get all fields from this table, providing some field names, if this table
* knows its field references.
*
* @return All available fields
* @see Row#fields(Name...)
*/
@NotNull
Field<?>[] fields(Name... fieldNames);
/**
* Get all fields from this table, providing some field indexes, if this
* table knows its field references.
*
* @return All available fields
* @see Row#fields(int...)
*/
@NotNull
Field<?> [] fields(int... fieldIndexes);
/**
* Get a field's index from this table.
*
* @param field The field to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this table.
*/
int indexOf(Field<?> field);
/**
* Get a field's index from this table.
*
* @param fieldName The field name to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this table.
*/
int indexOf(String fieldName);
/**
* Get a field's index from this table.
*
* @param fieldName The field name to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this table
*/
int indexOf(Name fieldName);
public interface TableLike<R extends Record> extends Fields, QueryPart {
/**
* The underlying table representation of this object.

View File

@ -37,8 +37,6 @@
*/
package org.jooq;
import java.util.stream.Stream;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -51,138 +49,7 @@ import org.jetbrains.annotations.Nullable;
* @param <R> The record type
* @author Lukas Eder
*/
public interface UDT<R extends UDTRecord<R>> extends Qualified {
/**
* Get this UDT's fields as a {@link Row}.
*/
@NotNull
Row fieldsRow();
/**
* Get this table's fields as a {@link Stream}.
*/
@NotNull
Stream<Field<?>> fieldStream();
/**
* Get a specific field from this UDT.
* <p>
* This will return:
* <ul>
* <li>A field that is the same as the argument field (by identity
* comparison).</li>
* <li>A field that is equal to the argument field (exact matching fully
* qualified name).</li>
* <li>A field that is equal to the argument field (partially matching
* qualified name).</li>
* <li>A field whose name is equal to the name of the argument field.</li>
* <li><code>null</code> otherwise.
* </ul>
* If several fields have the same name, the first one is returned and a
* warning is logged.
*
* @see Row#field(Field)
*/
@Nullable
<T> Field<T> field(Field<T> field);
/**
* Get a specific field from this UDT.
*
* @see Row#field(String)
*/
@Nullable
Field<?> field(String name);
/**
* Get a specific field from this UDT.
*
* @see Row#field(Name)
*/
@Nullable
Field<?> field(Name name);
/**
* Get a specific field from this UDT.
*
* @see Row#field(int)
*/
@Nullable
Field<?> field(int index);
/**
* Get all fields from this UDT.
*
* @see Row#fields()
*/
@Nullable
Field<?>[] fields();
/**
* Get all fields from this UDT, providing some fields.
*
* @return All available fields
* @see Row#fields(Field...)
*/
@Nullable
Field<?>[] fields(Field<?>... fields);
/**
* Get all fields from this UDT, providing some field names.
*
* @return All available fields
* @see Row#fields(String...)
*/
@Nullable
Field<?>[] fields(String... fieldNames);
/**
* Get all fields from this UDT, providing some field names.
*
* @return All available fields
* @see Row#fields(Name...)
*/
@Nullable
Field<?>[] fields(Name... fieldNames);
/**
* Get all fields from this UDT, providing some field indexes.
*
* @return All available fields
* @see Row#fields(int...)
*/
@Nullable
Field<?>[] fields(int... fieldIndexes);
/**
* Get a field's index from this udt.
*
* @param field The field to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this udt.
*/
int indexOf(Field<?> field);
/**
* Get a field's index from this udt.
*
* @param fieldName The field name to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this udt.
*/
int indexOf(String fieldName);
/**
* Get a field's index from this udt.
*
* @param fieldName The field name to look for
* @return The field's index or <code>-1</code> if the field is not
* contained in this udt
*/
int indexOf(Name fieldName);
public interface UDT<R extends UDTRecord<R>> extends Fields, Qualified {
/**
* Get the UDT package.

View File

@ -60,6 +60,7 @@ import java.util.Deque;
import java.util.Iterator;
import java.util.List;
import java.util.TreeMap;
import java.util.stream.Stream;
import javax.xml.bind.DatatypeConverter;
import javax.xml.parsers.DocumentBuilder;
@ -76,6 +77,7 @@ import org.jooq.DSLContext;
import org.jooq.DataType;
import org.jooq.EnumType;
import org.jooq.Field;
import org.jooq.Fields;
import org.jooq.Formattable;
import org.jooq.JSON;
import org.jooq.JSONB;
@ -106,17 +108,17 @@ import org.xml.sax.helpers.AttributesImpl;
/**
* @author Lukas Eder
*/
abstract class AbstractCursor<R extends Record> extends AbstractFormattable implements Iterable<R> {
abstract class AbstractCursor<R extends Record> extends AbstractFormattable implements Fields, Iterable<R> {
/**
* Generated UID
*/
private static final long serialVersionUID = -3412555195899758746L;
final Fields<R> fields;
final FieldsImpl<R> fields;
Configuration configuration;
AbstractCursor(Configuration configuration, Fields<R> fields) {
AbstractCursor(Configuration configuration, FieldsImpl<R> fields) {
this.configuration = configuration;
this.fields = fields;
}
@ -129,10 +131,21 @@ abstract class AbstractCursor<R extends Record> extends AbstractFormattable impl
return fields;
}
@Override
public final Row fieldsRow() {
return Tools.row0(fields);
}
@Override
public final Stream<Field<?>> fieldStream() {
return fields.fieldStream();
}
@Override
public final <T> Field<T> field(Field<T> field) {
return fields.field(field);
}
@ -140,6 +153,7 @@ abstract class AbstractCursor<R extends Record> extends AbstractFormattable impl
/**
* @deprecated This method hides static import {@link DSL#field(String)}.
*/
@Override
@Deprecated
public final Field<?> field(String name) {
return fields.field(name);
@ -148,6 +162,7 @@ abstract class AbstractCursor<R extends Record> extends AbstractFormattable impl
/**
* @deprecated This method hides static import {@link DSL#field(String, Class)}.
*/
@Override
@Deprecated
public final <T> Field<T> field(String name, Class<T> type) {
return fields.field(name, type);
@ -156,6 +171,7 @@ abstract class AbstractCursor<R extends Record> extends AbstractFormattable impl
/**
* @deprecated This method hides static import {@link DSL#field(String, DataType)}.
*/
@Override
@Deprecated
public final <T> Field<T> field(String name, DataType<T> dataType) {
return fields.field(name, dataType);
@ -164,6 +180,7 @@ abstract class AbstractCursor<R extends Record> extends AbstractFormattable impl
/**
* @deprecated This method hides static import {@link DSL#field(Name)}.
*/
@Override
@Deprecated
public final Field<?> field(Name name) {
return fields.field(name);
@ -172,6 +189,7 @@ abstract class AbstractCursor<R extends Record> extends AbstractFormattable impl
/**
* @deprecated This method hides static import {@link DSL#field(Name, Class)}.
*/
@Override
@Deprecated
public final <T> Field<T> field(Name name, Class<T> type) {
return fields.field(name, type);
@ -180,55 +198,107 @@ abstract class AbstractCursor<R extends Record> extends AbstractFormattable impl
/**
* @deprecated This method hides static import {@link DSL#field(Name, DataType)}.
*/
@Override
@Deprecated
public final <T> Field<T> field(Name name, DataType<T> dataType) {
return fields.field(name, dataType);
}
@Override
public final Field<?> field(int index) {
return fields.field(index);
}
@Override
public final <T> Field<T> field(int index, Class<T> type) {
return fields.field(index, type);
}
@Override
public final <T> Field<T> field(int index, DataType<T> dataType) {
return fields.field(index, dataType);
}
@Override
public final Field<?>[] fields() {
return fields.fields().clone();
}
@Override
public final Field<?>[] fields(Field<?>... f) {
return fields.fields(f);
}
@Override
public final Field<?>[] fields(int... indexes) {
return fields.fields(indexes);
}
@Override
public final Field<?>[] fields(String... names) {
return fields.fields(names);
}
@Override
public final Field<?>[] fields(Name... names) {
return fields.fields(names);
}
@Override
public final int indexOf(Field<?> field) {
return fields.indexOf(field);
}
@Override
public final int indexOf(String fieldName) {
return fields.indexOf(fieldName);
}
@Override
public final int indexOf(Name fieldName) {
return fields.indexOf(fieldName);
}
@Override
public final Class<?>[] types() {
return fields.types();
}
@Override
public final Class<?> type(int index) {
return fields.type(index);
}
@Override
public final Class<?> type(String name) {
return fields.type(name);
}
@Override
public final Class<?> type(Name name) {
return fields.type(name);
}
@Override
public final DataType<?>[] dataTypes() {
return fields.dataTypes();
}
@Override
public final DataType<?> dataType(int index) {
return fields.dataType(index);
}
@Override
public final DataType<?> dataType(String name) {
return fields.dataType(name);
}
@Override
public final DataType<?> dataType(Name name) {
return fields.dataType(name);
}
// -------------------------------------------------------------------------
// XXX: Formattable API
// -------------------------------------------------------------------------
@ -723,7 +793,7 @@ abstract class AbstractCursor<R extends Record> extends AbstractFormattable impl
}
}
static final void formatJSONMap0(Record record, Fields<?> fields, JSONFormat format, int recordLevel, Writer writer) throws java.io.IOException {
static final void formatJSONMap0(Record record, FieldsImpl<?> fields, JSONFormat format, int recordLevel, Writer writer) throws java.io.IOException {
String separator = "";
boolean wrapRecords = format.wrapSingleColumnRecords() || fields.fields.length > 1;
@ -758,7 +828,7 @@ abstract class AbstractCursor<R extends Record> extends AbstractFormattable impl
writer.append('}');
}
static final void formatJSONArray0(Record record, Fields<?> fields, JSONFormat format, int recordLevel, Writer writer) throws java.io.IOException {
static final void formatJSONArray0(Record record, FieldsImpl<?> fields, JSONFormat format, int recordLevel, Writer writer) throws java.io.IOException {
String separator = "";
if (format.wrapSingleColumnRecords() || fields.fields.length > 1)
@ -855,7 +925,7 @@ abstract class AbstractCursor<R extends Record> extends AbstractFormattable impl
XMLFormat format,
int recordLevel,
Record record,
Fields<?> fields
FieldsImpl<?> fields
)
throws java.io.IOException {
String newline = format.newline();

View File

@ -1254,7 +1254,7 @@ abstract class AbstractDMLQuery<R extends Record> extends AbstractRowCountQuery
// Only the IDENTITY value was requested. No need for an
// additional query
if (returningResolvedAsterisks.size() == 1 && new Fields<>(returningResolvedAsterisks).field(returnIdentity) != null) {
if (returningResolvedAsterisks.size() == 1 && new FieldsImpl<>(returningResolvedAsterisks).field(returnIdentity) != null) {
for (final Object id : ids) {
((Result) getResult()).add(
Tools.newRecord(

View File

@ -179,6 +179,20 @@ abstract class AbstractRecord extends AbstractStore implements Record {
// XXX: FieldProvider API
// ------------------------------------------------------------------------
@Override
public final Field<?>[] fields() {
return fields.fields();
}
@Override
public final Stream<Field<?>> fieldStream() {
return fields.fieldStream();
}
@Override
public final <T> Field<T> field(Field<T> field) {
return fieldsRow().field(field);
@ -189,19 +203,44 @@ abstract class AbstractRecord extends AbstractStore implements Record {
return fieldsRow().field(name);
}
@Override
public final <T> Field<T> field(String name, Class<T> type) {
return fields.field(name, type);
}
@Override
public final <T> Field<T> field(String name, DataType<T> dataType) {
return fields.field(name, dataType);
}
@Override
public final Field<?> field(Name name) {
return fieldsRow().field(name);
}
@Override
public final <T> Field<T> field(Name name, Class<T> type) {
return fields.field(name, type);
}
@Override
public final <T> Field<T> field(Name name, DataType<T> dataType) {
return fields.field(name, dataType);
}
@Override
public final Field<?> field(int index) {
return index >= 0 && index < fields.size() ? fields.field(index) : null;
}
@Override
public final Field<?>[] fields() {
return fields.fields();
public final <T> Field<T> field(int index, Class<T> type) {
return fields.field(index, type);
}
@Override
public final <T> Field<T> field(int index, DataType<T> dataType) {
return fields.field(index, dataType);
}
@Override
@ -239,6 +278,46 @@ abstract class AbstractRecord extends AbstractStore implements Record {
return fields.indexOf(fieldName);
}
@Override
public final Class<?>[] types() {
return fields.types();
}
@Override
public final Class<?> type(int fieldIndex) {
return fields.type(fieldIndex);
}
@Override
public final Class<?> type(String fieldName) {
return fields.type(fieldName);
}
@Override
public final Class<?> type(Name fieldName) {
return fields.type(fieldName);
}
@Override
public final DataType<?>[] dataTypes() {
return fields.dataTypes();
}
@Override
public final DataType<?> dataType(int fieldIndex) {
return fields.dataType(fieldIndex);
}
@Override
public final DataType<?> dataType(String fieldName) {
return fields.dataType(fieldName);
}
@Override
public final DataType<?> dataType(Name fieldName) {
return fields.dataType(fieldName);
}
// ------------------------------------------------------------------------
// XXX: Record API
// ------------------------------------------------------------------------
@ -740,7 +819,7 @@ abstract class AbstractRecord extends AbstractStore implements Record {
@Override
public final <E> E into(Class<? extends E> type) {
return (E) Tools.configuration(this).recordMapperProvider().provide((Fields) fields.fields, type).map(this);
return (E) Tools.configuration(this).recordMapperProvider().provide((FieldsImpl) fields.fields, type).map(this);
}
// [#10191] Java and Kotlin can produce overloads for this method despite
@ -754,7 +833,7 @@ abstract class AbstractRecord extends AbstractStore implements Record {
Class<E> type = (Class<E>) object.getClass();
try {
return new DefaultRecordMapper<Record, E>((Fields) fields.fields, type, object, configuration()).map(this);
return new DefaultRecordMapper<Record, E>((FieldsImpl) fields.fields, type, object, configuration()).map(this);
}
// Pass MappingExceptions on to client code
@ -844,7 +923,7 @@ abstract class AbstractRecord extends AbstractStore implements Record {
return mapper.map(this);
}
private final void from0(Object source, Fields f) {
private final void from0(Object source, FieldsImpl f) {
if (source == null) return;
// [#2520] TODO: Benchmark this from() method. There's probably a better implementation
@ -855,7 +934,7 @@ abstract class AbstractRecord extends AbstractStore implements Record {
resetChangedOnNotNull(this);
}
private final Object prepareArrayForUnmap(Object source, Fields f) {
private final Object prepareArrayForUnmap(Object source, FieldsImpl f) {
if (source instanceof Object[]) {
Object[] array = (Object[]) source;
@ -883,7 +962,7 @@ abstract class AbstractRecord extends AbstractStore implements Record {
@Override
public final void from(Object source, Field<?>... f) {
from0(source, new Fields(f));
from0(source, new FieldsImpl(f));
}
@Override
@ -908,7 +987,7 @@ abstract class AbstractRecord extends AbstractStore implements Record {
@Override
public final void fromMap(Map<String, ?> map, Field<?>... f) {
from0(map, new Fields(f));
from0(map, new FieldsImpl(f));
}
@Override
@ -933,7 +1012,7 @@ abstract class AbstractRecord extends AbstractStore implements Record {
@Override
public final void fromArray(Object[] array, Field<?>... f) {
from0(array, new Fields(f));
from0(array, new FieldsImpl(f));
}
@Override

View File

@ -55,6 +55,8 @@ import org.jooq.Row;
import org.jooq.Row1;
import org.jooq.Row2;
import org.jetbrains.annotations.NotNull;
/**
* A common base class for the various degrees of {@link Row1}, {@link Row2},
* etc.
@ -64,20 +66,20 @@ abstract class AbstractRow extends AbstractQueryPart implements Row {
/**
* Generated UID
*/
private static final long serialVersionUID = 2175082265665049629L;
private static final long serialVersionUID = 2175082265665049629L;
private static final Clause[] CLAUSES = { FIELD_ROW };
final Fields<?> fields;
final FieldsImpl<?> fields;
AbstractRow(Field<?>... fields) {
this(new Fields<>(fields));
this(new FieldsImpl<>(fields));
}
AbstractRow(Collection<? extends Field<?>> fields) {
this(new Fields<>(fields));
this(new FieldsImpl<>(fields));
}
AbstractRow(Fields<?> fields) {
AbstractRow(FieldsImpl<?> fields) {
super();
this.fields = fields;
@ -114,6 +116,12 @@ abstract class AbstractRow extends AbstractQueryPart implements Row {
return fields.size();
}
@Override
public final Row fieldsRow() {
return this;
}
@Override
public final Stream<Field<?>> fieldStream() {
@ -121,6 +129,7 @@ abstract class AbstractRow extends AbstractQueryPart implements Row {
}
@Override
public final <T> Field<T> field(Field<T> field) {
return fields.field(field);

View File

@ -189,7 +189,7 @@ abstract class AbstractTable<R extends Record> extends AbstractNamed implements
* <code>TableAlias</code> contains aliased fields of its
* <code>AliasProvider</code> table.
*/
abstract Fields<R> fields0();
abstract FieldsImpl<R> fields0();
@Override
public final DataType<R> getDataType() {
@ -218,12 +218,14 @@ abstract class AbstractTable<R extends Record> extends AbstractNamed implements
}
@Override
public final Stream<Field<?>> fieldStream() {
return Stream.of(fields());
}
@Override
public final <T> Field<T> field(Field<T> field) {
return fieldsRow().field(field);
@ -314,6 +316,46 @@ abstract class AbstractTable<R extends Record> extends AbstractNamed implements
return fieldsRow().indexOf(fieldName);
}
@Override
public final Class<?>[] types() {
return fieldsRow().types();
}
@Override
public final Class<?> type(int index) {
return fieldsRow().type(index);
}
@Override
public final Class<?> type(String name) {
return fieldsRow().type(name);
}
@Override
public final Class<?> type(Name name) {
return fieldsRow().type(name);
}
@Override
public final DataType<?>[] dataTypes() {
return fieldsRow().dataTypes();
}
@Override
public final DataType<?> dataType(int index) {
return fieldsRow().dataType(index);
}
@Override
public final DataType<?> dataType(String name) {
return fieldsRow().dataType(name);
}
@Override
public final DataType<?> dataType(Name name) {
return fieldsRow().dataType(name);
}
@Override
public final Table<R> asTable() {
return this;

View File

@ -97,8 +97,8 @@ final class AliasedSelect<R extends Record> extends AbstractTable<R> {
}
@Override
final Fields<R> fields0() {
return new Fields<>(query.asTable(DSL.name("t"), aliases).fields());
final FieldsImpl<R> fields0() {
return new FieldsImpl<>(query.asTable(DSL.name("t"), aliases).fields());
}
@Override

View File

@ -65,12 +65,12 @@ final class Array<T> extends AbstractField<T[]> {
private static final long serialVersionUID = -6629785423729163857L;
private static final Set<SQLDialect> REQUIRES_CAST = SQLDialect.supportedBy(POSTGRES);
private final Fields<Record> fields;
private final FieldsImpl<Record> fields;
Array(Collection<? extends Field<T>> fields) {
super(N_ARRAY, type(fields));
this.fields = new Fields<>(fields);
this.fields = new FieldsImpl<>(fields);
}
@SuppressWarnings({ "rawtypes", "unchecked" })

View File

@ -70,12 +70,12 @@ final class ArrayTable extends AbstractTable<Record> {
/**
* Generated UID
*/
private static final long serialVersionUID = 2380426377794577041L;
private static final long serialVersionUID = 2380426377794577041L;
private final Field<?> array;
private final Fields<Record> field;
private final Name alias;
private final Name[] fieldAliases;
private final Field<?> array;
private final FieldsImpl<Record> field;
private final Name alias;
private final Name[] fieldAliases;
ArrayTable(Field<?> array) {
this(array, N_ARRAY_TABLE);
@ -122,7 +122,7 @@ final class ArrayTable extends AbstractTable<Record> {
this.field = init(arrayType, alias);
}
private static final Fields<Record> init(Class<?> arrayType, Name alias) {
private static final FieldsImpl<Record> init(Class<?> arrayType, Name alias) {
List<Field<?>> result = new ArrayList<>();
// [#1114] VARRAY/TABLE of OBJECT have more than one field
@ -143,7 +143,7 @@ final class ArrayTable extends AbstractTable<Record> {
result.add(DSL.field(name(alias.last(), "COLUMN_VALUE"), DSL.getDataType(arrayType)));
}
return new Fields<>(result);
return new FieldsImpl<>(result);
}
@Override
@ -284,7 +284,7 @@ final class ArrayTable extends AbstractTable<Record> {
}
@Override
final Fields<Record> fields0() {
final FieldsImpl<Record> fields0() {
return ArrayTable.this.fields0();
}
}
@ -295,7 +295,7 @@ final class ArrayTable extends AbstractTable<Record> {
}
@Override
final Fields<Record> fields0() {
final FieldsImpl<Record> fields0() {
return field;
}
}

View File

@ -64,14 +64,14 @@ final class ArrayTableEmulation extends AbstractTable<Record> {
/**
* Generated UID
*/
private static final long serialVersionUID = 2392515064450536343L;
private static final long serialVersionUID = 2392515064450536343L;
private final Object[] array;
private final Fields<Record> field;
private final Name alias;
private final Name fieldAlias;
private final Object[] array;
private final FieldsImpl<Record> field;
private final Name alias;
private final Name fieldAlias;
private transient Table<Record> table;
private transient Table<Record> table;
ArrayTableEmulation(Object[] array) {
this(array, N_ARRAY_TABLE, null);
@ -87,7 +87,7 @@ final class ArrayTableEmulation extends AbstractTable<Record> {
this.array = array;
this.alias = alias;
this.fieldAlias = fieldAlias == null ? N_COLUMN_VALUE : fieldAlias;
this.field = new Fields<>(DSL.field(name(alias.last(), this.fieldAlias.last()), DSL.getDataType(array.getClass().getComponentType())));
this.field = new FieldsImpl<>(DSL.field(name(alias.last(), this.fieldAlias.last()), DSL.getDataType(array.getClass().getComponentType())));
}
@Override
@ -124,7 +124,7 @@ final class ArrayTableEmulation extends AbstractTable<Record> {
}
@Override
final Fields<Record> fields0() {
final FieldsImpl<Record> fields0() {
return field;
}

View File

@ -76,7 +76,7 @@ final class CommonTableExpressionImpl<R extends Record> extends AbstractTable<R>
private final DerivedColumnListImpl name;
private final Select<R> select;
private final Fields<R> fields;
private final FieldsImpl<R> fields;
private final Boolean materialized;
CommonTableExpressionImpl(DerivedColumnListImpl name, Select<R> select, Boolean materialized) {
@ -131,11 +131,11 @@ final class CommonTableExpressionImpl<R extends Record> extends AbstractTable<R>
}
@Override
final Fields<R> fields0() {
final FieldsImpl<R> fields0() {
return fields;
}
final Fields<R> fields1() {
final FieldsImpl<R> fields1() {
List<Field<?>> s = select.getSelect();
Field<?>[] f = new Field[Tools.degree(select)];
@ -152,6 +152,6 @@ final class CommonTableExpressionImpl<R extends Record> extends AbstractTable<R>
);
}
return new Fields<>(f);
return new FieldsImpl<>(f);
}
}

View File

@ -119,14 +119,13 @@ final class CursorImpl<R extends Record> extends AbstractCursor<R> implements Cu
private transient Iterator<R> iterator;
private transient int rows;
@SuppressWarnings("unchecked")
CursorImpl(ExecuteContext ctx, ExecuteListener listener, Field<?>[] fields, int[] internIndexes, boolean keepStatement, boolean keepResultSet) {
this(ctx, listener, fields, internIndexes, keepStatement, keepResultSet, (Class<? extends R>) RecordImplN.class, 0, true);
}
CursorImpl(ExecuteContext ctx, ExecuteListener listener, Field<?>[] fields, int[] internIndexes, boolean keepStatement, boolean keepResultSet, Class<? extends R> type, int maxRows, boolean autoclosing) {
super(ctx.configuration(), new Fields<>(fields));
super(ctx.configuration(), new FieldsImpl<>(fields));
this.ctx = ctx;
this.listener = (listener != null ? listener : ExecuteListeners.getAndStart(ctx));

View File

@ -24471,7 +24471,7 @@ public class DSL {
*/
@NotNull
public static <T1> RecordType<Record> recordType(Field<?>[] fields) {
return new Fields(fields);
return new FieldsImpl(fields);
}
/**
@ -24479,7 +24479,7 @@ public class DSL {
*/
@NotNull
public static <T1> RecordType<Record> recordType(Collection<? extends Field<?>> fields) {
return new Fields(fields);
return new FieldsImpl(fields);
}
@ -24489,7 +24489,7 @@ public class DSL {
*/
@NotNull
public static <T1> RecordType<Record1<T1>> recordType(Field<T1> field1) {
return new Fields(field1);
return new FieldsImpl(field1);
}
/**
@ -24497,7 +24497,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2> RecordType<Record2<T1, T2>> recordType(Field<T1> field1, Field<T2> field2) {
return new Fields(field1, field2);
return new FieldsImpl(field1, field2);
}
/**
@ -24505,7 +24505,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2, T3> RecordType<Record3<T1, T2, T3>> recordType(Field<T1> field1, Field<T2> field2, Field<T3> field3) {
return new Fields(field1, field2, field3);
return new FieldsImpl(field1, field2, field3);
}
/**
@ -24513,7 +24513,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2, T3, T4> RecordType<Record4<T1, T2, T3, T4>> recordType(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4) {
return new Fields(field1, field2, field3, field4);
return new FieldsImpl(field1, field2, field3, field4);
}
/**
@ -24521,7 +24521,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2, T3, T4, T5> RecordType<Record5<T1, T2, T3, T4, T5>> recordType(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5) {
return new Fields(field1, field2, field3, field4, field5);
return new FieldsImpl(field1, field2, field3, field4, field5);
}
/**
@ -24529,7 +24529,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2, T3, T4, T5, T6> RecordType<Record6<T1, T2, T3, T4, T5, T6>> recordType(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6) {
return new Fields(field1, field2, field3, field4, field5, field6);
return new FieldsImpl(field1, field2, field3, field4, field5, field6);
}
/**
@ -24537,7 +24537,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2, T3, T4, T5, T6, T7> RecordType<Record7<T1, T2, T3, T4, T5, T6, T7>> recordType(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7) {
return new Fields(field1, field2, field3, field4, field5, field6, field7);
return new FieldsImpl(field1, field2, field3, field4, field5, field6, field7);
}
/**
@ -24545,7 +24545,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2, T3, T4, T5, T6, T7, T8> RecordType<Record8<T1, T2, T3, T4, T5, T6, T7, T8>> recordType(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8) {
return new Fields(field1, field2, field3, field4, field5, field6, field7, field8);
return new FieldsImpl(field1, field2, field3, field4, field5, field6, field7, field8);
}
/**
@ -24553,7 +24553,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9> RecordType<Record9<T1, T2, T3, T4, T5, T6, T7, T8, T9>> recordType(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9) {
return new Fields(field1, field2, field3, field4, field5, field6, field7, field8, field9);
return new FieldsImpl(field1, field2, field3, field4, field5, field6, field7, field8, field9);
}
/**
@ -24561,7 +24561,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> RecordType<Record10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>> recordType(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10) {
return new Fields(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10);
return new FieldsImpl(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10);
}
/**
@ -24569,7 +24569,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> RecordType<Record11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>> recordType(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11) {
return new Fields(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11);
return new FieldsImpl(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11);
}
/**
@ -24577,7 +24577,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> RecordType<Record12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>> recordType(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12) {
return new Fields(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12);
return new FieldsImpl(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12);
}
/**
@ -24585,7 +24585,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> RecordType<Record13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>> recordType(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13) {
return new Fields(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13);
return new FieldsImpl(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13);
}
/**
@ -24593,7 +24593,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> RecordType<Record14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>> recordType(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14) {
return new Fields(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14);
return new FieldsImpl(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14);
}
/**
@ -24601,7 +24601,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> RecordType<Record15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>> recordType(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15) {
return new Fields(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15);
return new FieldsImpl(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15);
}
/**
@ -24609,7 +24609,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> RecordType<Record16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>> recordType(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16) {
return new Fields(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16);
return new FieldsImpl(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16);
}
/**
@ -24617,7 +24617,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> RecordType<Record17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>> recordType(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17) {
return new Fields(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17);
return new FieldsImpl(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17);
}
/**
@ -24625,7 +24625,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18> RecordType<Record18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18>> recordType(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17, Field<T18> field18) {
return new Fields(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18);
return new FieldsImpl(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18);
}
/**
@ -24633,7 +24633,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19> RecordType<Record19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>> recordType(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17, Field<T18> field18, Field<T19> field19) {
return new Fields(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19);
return new FieldsImpl(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19);
}
/**
@ -24641,7 +24641,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20> RecordType<Record20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>> recordType(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17, Field<T18> field18, Field<T19> field19, Field<T20> field20) {
return new Fields(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20);
return new FieldsImpl(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20);
}
/**
@ -24649,7 +24649,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21> RecordType<Record21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>> recordType(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17, Field<T18> field18, Field<T19> field19, Field<T20> field20, Field<T21> field21) {
return new Fields(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20, field21);
return new FieldsImpl(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20, field21);
}
/**
@ -24657,7 +24657,7 @@ public class DSL {
*/
@NotNull
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> RecordType<Record22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22>> recordType(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17, Field<T18> field18, Field<T19> field19, Field<T20> field20, Field<T21> field21, Field<T22> field22) {
return new Fields(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20, field21, field22);
return new FieldsImpl(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20, field21, field22);
}

View File

@ -53,9 +53,9 @@ import org.jooq.Result;
*/
class DefaultRecordContext extends AbstractScope implements RecordContext {
private final ExecuteType type;
private final Record[] records;
Exception exception;
private final ExecuteType type;
private final Record[] records;
Exception exception;
DefaultRecordContext(Configuration configuration, ExecuteType type, Record... records) {
super(configuration);
@ -82,7 +82,7 @@ class DefaultRecordContext extends AbstractScope implements RecordContext {
@Override
public final RecordType<?> recordType() {
Record record = record();
return record != null ? new Fields<>(record.fields()) : null;
return record != null ? new FieldsImpl<>(record.fields()) : null;
}
@Override

View File

@ -787,14 +787,14 @@ public class DefaultRecordMapper<R extends Record, E> implements RecordMapper<R,
for (java.lang.reflect.Field member : getMatchingMembers(configuration, type, prefix, true)) {
list.add(configuration
.recordMapperProvider()
.provide(new Fields<>(entry.getValue()), member.getType())
.provide(new FieldsImpl<>(entry.getValue()), member.getType())
);
}
for (Method method : getMatchingSetters(configuration, type, prefix, true)) {
list.add(configuration
.recordMapperProvider()
.provide(new Fields<>(entry.getValue()), method.getParameterTypes()[0])
.provide(new FieldsImpl<>(entry.getValue()), method.getParameterTypes()[0])
);
}
@ -1002,7 +1002,7 @@ public class DefaultRecordMapper<R extends Record, E> implements RecordMapper<R,
if (nestedMappedFields[i] != null) {
nestedMappers[i] = configuration
.recordMapperProvider()
.provide((RecordType) new Fields<>(nestedMappedFields[i]), parameterTypes[i]);
.provide((RecordType) new FieldsImpl<>(nestedMappedFields[i]), parameterTypes[i]);
}
}
}

View File

@ -79,8 +79,8 @@ class DerivedTable<R extends Record> extends AbstractTable<R> {
}
@Override
final Fields<R> fields0() {
return new Fields<>(query.getSelect());
final FieldsImpl<R> fields0() {
return new FieldsImpl<>(query.getSelect());
}
@Override

View File

@ -214,7 +214,7 @@ final class Dual extends AbstractTable<Record> {
}
@Override
final Fields<Record> fields0() {
return new Fields<>();
final FieldsImpl<Record> fields0() {
return new FieldsImpl<>();
}
}

View File

@ -47,6 +47,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Stream;
import org.jooq.Context;
import org.jooq.DataType;
@ -54,27 +55,30 @@ import org.jooq.Field;
import org.jooq.Name;
import org.jooq.Record;
import org.jooq.RecordType;
import org.jooq.Row;
import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.tools.JooqLogger;
import org.jetbrains.annotations.NotNull;
/**
* A simple wrapper for <code>Field[]</code>, providing some useful lookup
* methods
*
* @author Lukas Eder
*/
final class Fields<R extends Record> extends AbstractQueryPart implements RecordType<R> {
final class FieldsImpl<R extends Record> extends AbstractQueryPart implements RecordType<R> {
private static final long serialVersionUID = -6911012275707591576L;
private static final JooqLogger log = JooqLogger.getLogger(Fields.class);
private static final JooqLogger log = JooqLogger.getLogger(FieldsImpl.class);
Field<?>[] fields;
Fields(Field<?>... fields) {
FieldsImpl(Field<?>... fields) {
this.fields = fields;
}
Fields(Collection<? extends Field<?>> fields) {
FieldsImpl(Collection<? extends Field<?>> fields) {
this.fields = fields.toArray(EMPTY_FIELD);
}
@ -256,6 +260,20 @@ final class Fields<R extends Record> extends AbstractQueryPart implements Record
return fields;
}
@Override
public final Row fieldsRow() {
return new RowImplN(fields);
}
@Override
public final Stream<Field<?>> fieldStream() {
return Stream.of(fields);
}
@Override
public final Field<?>[] fields(Field<?>... f) {
Field<?>[] result = new Field[f.length];
@ -478,8 +496,8 @@ final class Fields<R extends Record> extends AbstractQueryPart implements Record
if (this == that)
return true;
if (that instanceof Fields)
return Arrays.equals(fields, ((Fields<?>) that).fields);
if (that instanceof FieldsImpl)
return Arrays.equals(fields, ((FieldsImpl<?>) that).fields);
return false;
}

View File

@ -108,7 +108,7 @@ final class FunctionTable<R extends Record> extends AbstractTable<R> {
}
@Override
final Fields<R> fields0() {
return new Fields<>();
final FieldsImpl<R> fields0() {
return new FieldsImpl<>();
}
}

View File

@ -162,8 +162,8 @@ final class GenerateSeries extends AbstractTable<Record1<Integer>> {
}
@Override
final Fields<Record1<Integer>> fields0() {
return new Fields<>(DSL.field(N_GENERATE_SERIES, Integer.class));
final FieldsImpl<Record1<Integer>> fields0() {
return new FieldsImpl<>(DSL.field(N_GENERATE_SERIES, Integer.class));
}
@Override // Avoid AbstractTable implementation

View File

@ -106,7 +106,7 @@ final class HintedTable<R extends Record> extends AbstractTable<R> {
}
@Override
final Fields<R> fields0() {
final FieldsImpl<R> fields0() {
return delegate.fields0();
}
}

View File

@ -355,7 +355,7 @@ final class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> impl
ctx.sql("[unknown primary key]");
else
ctx.qualify(false)
.visit(new Fields<>(table().getPrimaryKey().getFields()))
.visit(new FieldsImpl<>(table().getPrimaryKey().getFields()))
.qualify(qualify);
ctx.sql(')');

View File

@ -62,11 +62,11 @@ final class Intern implements Serializable {
if (internIndexes != null)
return internIndexes;
else if (internFields != null)
return new Fields<>(fields).indexesOf(internFields);
return new FieldsImpl<>(fields).indexesOf(internFields);
else if (internNameStrings != null)
return new Fields<>(fields).indexesOf(internNameStrings);
return new FieldsImpl<>(fields).indexesOf(internNameStrings);
else if (internNames != null)
return new Fields<>(fields).indexesOf(internNames);
return new FieldsImpl<>(fields).indexesOf(internNames);
return null;
}

View File

@ -100,7 +100,7 @@ implements
private final Field<?> json;
private final QueryPartList<JSONTableColumn> columns;
private final boolean hasOrdinality;
private transient Fields<Record> fields;
private transient FieldsImpl<Record> fields;
JSONTable(Field<?> json, Field<String> path) {
this(json, path, null, false);
@ -184,14 +184,14 @@ implements
}
@Override
final Fields<Record> fields0() {
final FieldsImpl<Record> fields0() {
if (fields == null) {
List<Field<?>> f = new ArrayList<>();
for (JSONTableColumn c : columns)
f.add(c.field.getDataType() == c.type ? c.field : DSL.field(c.field.getQualifiedName(), c.type));
fields = new Fields<>(f);
fields = new FieldsImpl<>(f);
}
return fields;

View File

@ -564,9 +564,9 @@ implements
}
@Override
final Fields<Record> fields0() {
final FieldsImpl<Record> fields0() {
if (type == LEFT_SEMI_JOIN || type == LEFT_ANTI_JOIN) {
return new Fields<>(lhs.asTable().fields());
return new FieldsImpl<>(lhs.asTable().fields());
}
else {
Field<?>[] l = lhs.asTable().fields();
@ -576,7 +576,7 @@ implements
System.arraycopy(l, 0, all, 0, l.length);
System.arraycopy(r, 0, all, l.length, r.length);
return new Fields<>(all);
return new FieldsImpl<>(all);
}
}

View File

@ -88,7 +88,7 @@ final class Lateral<R extends Record> extends AbstractTable<R> {
}
@Override
final Fields<R> fields0() {
return new Fields<>(table.fields());
final FieldsImpl<R> fields0() {
return new FieldsImpl<>(table.fields());
}
}

View File

@ -1396,7 +1396,7 @@ implements
}
private final void toSQLMySQLOnDuplicateKeyUpdate(Context<?> ctx) {
Fields<?> fields = new Fields<>(getUpsertFields());
FieldsImpl<?> fields = new FieldsImpl<>(getUpsertFields());
Map<Field<?>, Field<?>> map = new LinkedHashMap<>();
for (Field<?> field : fields.fields)
map.put(field, getUpsertValues().get(fields.indexOf(field)));
@ -1417,7 +1417,7 @@ implements
ctx.sql("[ merge with select is not supported in PostgreSQL ]");
}
else {
Fields<?> fields = new Fields<>(getUpsertFields());
FieldsImpl<?> fields = new FieldsImpl<>(getUpsertFields());
Map<Field<?>, Field<?>> map = new LinkedHashMap<>();
for (Field<?> field : fields.fields) {

View File

@ -72,16 +72,16 @@ final class MetaDataFieldProvider implements Serializable {
/**
* Generated UID
*/
private static final long serialVersionUID = -8482521025536063609L;
private static final JooqLogger log = JooqLogger.getLogger(MetaDataFieldProvider.class);
private static final long serialVersionUID = -8482521025536063609L;
private static final JooqLogger log = JooqLogger.getLogger(MetaDataFieldProvider.class);
private final Fields<Record> fields;
private final FieldsImpl<Record> fields;
MetaDataFieldProvider(Configuration configuration, ResultSetMetaData meta) {
this.fields = init(configuration, meta);
}
private static Fields<Record> init(Configuration configuration, ResultSetMetaData meta) {
private static FieldsImpl<Record> init(Configuration configuration, ResultSetMetaData meta) {
Field<?>[] fields;
int columnCount = 0;
@ -160,7 +160,7 @@ final class MetaDataFieldProvider implements Serializable {
throw Tools.translate(null, e);
}
return new Fields<>(fields);
return new FieldsImpl<>(fields);
}
final Field<?>[] getFields() {

View File

@ -110,14 +110,14 @@ final class ResultImpl<R extends Record> extends AbstractCursor<R> implements Re
private final List<R> records;
ResultImpl(Configuration configuration, Collection<? extends Field<?>> fields) {
this(configuration, new Fields<>(fields));
this(configuration, new FieldsImpl<>(fields));
}
ResultImpl(Configuration configuration, Field<?>... fields) {
this(configuration, new Fields<>(fields));
this(configuration, new FieldsImpl<>(fields));
}
ResultImpl(Configuration configuration, Fields<R> fields) {
ResultImpl(Configuration configuration, FieldsImpl<R> fields) {
super(configuration, fields);
this.records = new ArrayList<>();

View File

@ -71,7 +71,7 @@ final class RowImplN extends AbstractRow implements RowN {
super(fields);
}
RowImplN(Fields<?> fields) {
RowImplN(FieldsImpl<?> fields) {
super(fields);
}

View File

@ -60,7 +60,7 @@ final class RowsFrom extends AbstractTable<Record> {
*/
private static final long serialVersionUID = 693765524746506586L;
private final TableList tables;
private final TableList tables;
RowsFrom(Table<?>... tables) {
super(TableOptions.expression(), N_ROWSFROM);
@ -75,14 +75,14 @@ final class RowsFrom extends AbstractTable<Record> {
}
@Override
final Fields<Record> fields0() {
final FieldsImpl<Record> fields0() {
List<Field<?>> fields = new ArrayList<>();
for (Table<?> table : tables)
for (Field<?> field : table.fields())
fields.add(DSL.field(DSL.name(field.getName()), field.getDataType()));
return new Fields<>(fields);
return new FieldsImpl<>(fields);
}
@Override

View File

@ -72,7 +72,7 @@ final class SQLTable extends AbstractTable<Record> {
}
@Override
final Fields<Record> fields0() {
return new Fields<>();
final FieldsImpl<Record> fields0() {
return new FieldsImpl<>();
}
}

View File

@ -4045,12 +4045,14 @@ final class SelectImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
}
@Override
public final Stream<Field<?>> fieldStream() {
return Stream.of(fields());
}
@Override
public final <T> Field<T> field(Field<T> field) {
return getDelegate().field(field);
@ -4141,6 +4143,46 @@ final class SelectImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
return getDelegate().indexOf(fieldName);
}
@Override
public final Class<?>[] types() {
return getDelegate().types();
}
@Override
public final Class<?> type(int fieldIndex) {
return getDelegate().type(fieldIndex);
}
@Override
public final Class<?> type(String fieldName) {
return getDelegate().type(fieldName);
}
@Override
public final Class<?> type(Name fieldName) {
return getDelegate().type(fieldName);
}
@Override
public final DataType<?>[] dataTypes() {
return getDelegate().dataTypes();
}
@Override
public final DataType<?> dataType(int fieldIndex) {
return getDelegate().dataType(fieldIndex);
}
@Override
public final DataType<?> dataType(String fieldName) {
return getDelegate().dataType(fieldName);
}
@Override
public final DataType<?> dataType(Name fieldName) {
return getDelegate().dataType(fieldName);
}
@Override
public final <X extends Record> ResultQuery<X> coerce(Table<X> table) {
return getDelegate().coerce(table);

View File

@ -474,12 +474,14 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
}
@Override
public final Stream<Field<?>> fieldStream() {
return Stream.of(fields());
}
@Override
public final <T> Field<T> field(Field<T> field) {
return asTable().field(field);
@ -594,6 +596,46 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
return asTable().indexOf(fieldName);
}
@Override
public final Class<?>[] types() {
return asTable().types();
}
@Override
public final Class<?> type(int fieldIndex) {
return asTable().type(fieldIndex);
}
@Override
public final Class<?> type(String fieldName) {
return asTable().type(fieldName);
}
@Override
public final Class<?> type(Name fieldName) {
return asTable().type(fieldName);
}
@Override
public final DataType<?>[] dataTypes() {
return asTable().dataTypes();
}
@Override
public final DataType<?> dataType(int fieldIndex) {
return asTable().dataType(fieldIndex);
}
@Override
public final DataType<?> dataType(String fieldName) {
return asTable().dataType(fieldName);
}
@Override
public final DataType<?> dataType(Name fieldName) {
return asTable().dataType(fieldName);
}
@Override
public final Table<R> asTable() {
// Its usually better to alias nested selects that are used in
@ -3308,7 +3350,7 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
private final Collection<? extends Field<?>> subtract(List<Field<?>> left, List<Field<?>> right) {
// [#7921] TODO Make this functionality more generally reusable
Fields<?> e = new Fields<>(right);
FieldsImpl<?> e = new FieldsImpl<>(right);
List<Field<?>> result = new ArrayList<>();
for (Field<?> f : left)
@ -3413,7 +3455,7 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
}
private final <Q extends QueryPartList<? super Field<?>>> Q resolveAsterisk(Q result, QueryPartList<Field<?>> except) {
Fields<?> e = except == null ? null : new Fields<>(except);
FieldsImpl<?> e = except == null ? null : new FieldsImpl<>(except);
// [#109] [#489] [#7231]: SELECT * is only applied when at least one
// table from the table source is "unknown", i.e. not generated from a

View File

@ -60,7 +60,7 @@ final class TableAlias<R extends Record> extends AbstractTable<R> {
private static final long serialVersionUID = -8417114874567698325L;
final Alias<Table<R>> alias;
final Fields<R> aliasedFields;
final FieldsImpl<R> aliasedFields;
TableAlias(Table<R> table, Name alias) {
this(table, alias, null, false);
@ -85,7 +85,7 @@ final class TableAlias<R extends Record> extends AbstractTable<R> {
* Register fields for this table alias
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
private final Fields<R> init(Name[] fieldAliases) {
private final FieldsImpl<R> init(Name[] fieldAliases) {
Row row = this.alias.wrapped().fieldsRow();
int size = row.size();
List<Field<?>> result = new ArrayList<>(size);
@ -99,7 +99,7 @@ final class TableAlias<R extends Record> extends AbstractTable<R> {
result.add(new TableFieldImpl(name, field.getDataType(), this, field.getCommentPart(), field.getBinding()));
}
return new Fields<>(result);
return new FieldsImpl<>(result);
}
/**
@ -163,7 +163,7 @@ final class TableAlias<R extends Record> extends AbstractTable<R> {
}
@Override
final Fields<R> fields0() {
final FieldsImpl<R> fields0() {
return aliasedFields;
}

View File

@ -87,7 +87,7 @@ public class TableImpl<R extends Record> extends AbstractTable<R> {
private static final Set<SQLDialect> NO_SUPPORT_QUALIFIED_TVF_CALLS = SQLDialect.supportedBy(HSQLDB, POSTGRES);
private static final Set<SQLDialect> REQUIRES_TVF_TABLE_CONSTRUCTOR = SQLDialect.supportedBy(HSQLDB);
final Fields<R> fields;
final FieldsImpl<R> fields;
final Alias<Table<R>> alias;
protected final Field<?>[] parameters;
@ -183,7 +183,7 @@ public class TableImpl<R extends Record> extends AbstractTable<R> {
public TableImpl(Name name, Schema schema, Table<?> child, ForeignKey<?, R> path, Table<R> aliased, Field<?>[] parameters, Comment comment, TableOptions options) {
super(options, name, schema, comment);
this.fields = new Fields<>();
this.fields = new FieldsImpl<>();
this.child = child;
this.childPath = path == null ? null : Tools.aliasedKey((ForeignKey) path, child, this);
@ -226,7 +226,7 @@ public class TableImpl<R extends Record> extends AbstractTable<R> {
}
@Override
final Fields<R> fields0() {
final FieldsImpl<R> fields0() {
return fields;
}

View File

@ -309,7 +309,7 @@ public class TableRecordImpl<R extends TableRecord<R>> extends AbstractRecord im
* Set all changed values of this record to a store query.
*/
final void addChangedValues(Field<?>[] storeFields, StoreQuery<R> query, boolean forUpdate) {
Fields<Record> f = new Fields<>(storeFields);
FieldsImpl<Record> f = new FieldsImpl<>(storeFields);
for (Field<?> field : fields.fields.fields)
if (changed(field) && f.field(field) != null)

View File

@ -936,7 +936,7 @@ final class Tools {
}
}
static final AbstractRow row0(Fields<?> fields) {
static final AbstractRow row0(FieldsImpl<?> fields) {
return row0(fields.fields);
}

View File

@ -67,7 +67,7 @@ public class UDTImpl<R extends UDTRecord<R>> extends AbstractNamed implements UD
private static final long serialVersionUID = -2208672099190913126L;
private final Schema schema;
private final Fields<R> fields;
private final FieldsImpl<R> fields;
private final Package pkg;
private final boolean synthetic;
private transient DataType<R> type;
@ -83,7 +83,7 @@ public class UDTImpl<R extends UDTRecord<R>> extends AbstractNamed implements UD
public UDTImpl(String name, Schema schema, Package pkg, boolean synthetic) {
super(qualify(pkg != null ? pkg : schema, DSL.name(name)), CommentImpl.NO_COMMENT);
this.fields = new Fields<>();
this.fields = new FieldsImpl<>();
this.schema = schema;
this.pkg = pkg;
this.synthetic = synthetic;
@ -116,12 +116,14 @@ public class UDTImpl<R extends UDTRecord<R>> extends AbstractNamed implements UD
}
@Override
public final Stream<Field<?>> fieldStream() {
return Stream.of(fields());
}
@Override
public final <T> Field<T> field(Field<T> field) {
return fieldsRow().field(field);
@ -132,16 +134,46 @@ public class UDTImpl<R extends UDTRecord<R>> extends AbstractNamed implements UD
return fieldsRow().field(string);
}
@Override
public final <T> Field<T> field(String name, Class<T> t) {
return fieldsRow().field(name, t);
}
@Override
public final <T> Field<T> field(String name, DataType<T> t) {
return fieldsRow().field(name, t);
}
@Override
public final Field<?> field(Name fieldName) {
return fieldsRow().field(fieldName);
}
@Override
public final <T> Field<T> field(Name name, Class<T> t) {
return fieldsRow().field(name, t);
}
@Override
public final <T> Field<T> field(Name name, DataType<T> t) {
return fieldsRow().field(name, t);
}
@Override
public final Field<?> field(int index) {
return fieldsRow().field(index);
}
@Override
public final <T> Field<T> field(int index, Class<T> t) {
return fieldsRow().field(index, t);
}
@Override
public final <T> Field<T> field(int index, DataType<T> t) {
return fieldsRow().field(index, t);
}
@Override
public final Field<?>[] fields() {
return fieldsRow().fields();
@ -182,7 +214,47 @@ public class UDTImpl<R extends UDTRecord<R>> extends AbstractNamed implements UD
return fieldsRow().indexOf(fieldName);
}
final Fields<R> fields0() {
@Override
public final Class<?>[] types() {
return fieldsRow().types();
}
@Override
public final Class<?> type(int fieldIndex) {
return fieldsRow().type(fieldIndex);
}
@Override
public final Class<?> type(String fieldName) {
return fieldsRow().type(fieldName);
}
@Override
public final Class<?> type(Name fieldName) {
return fieldsRow().type(fieldName);
}
@Override
public final DataType<?>[] dataTypes() {
return fieldsRow().dataTypes();
}
@Override
public final DataType<?> dataType(int fieldIndex) {
return fieldsRow().dataType(fieldIndex);
}
@Override
public final DataType<?> dataType(String fieldName) {
return fieldsRow().dataType(fieldName);
}
@Override
public final DataType<?> dataType(Name fieldName) {
return fieldsRow().dataType(fieldName);
}
final FieldsImpl<R> fields0() {
return fields;
}

View File

@ -86,7 +86,7 @@ final class Values<R extends Record> extends AbstractTable<R> {
private static final long serialVersionUID = -637982217747670311L;
static final Set<SQLDialect> NO_SUPPORT_VALUES = SQLDialect.supportedUntil(FIREBIRD, MARIADB);
private final Row[] rows;
private final Row[] rows;
Values(Row[] rows) {
super(TableOptions.expression(), N_VALUES);
@ -178,7 +178,7 @@ final class Values<R extends Record> extends AbstractTable<R> {
}
@Override
final Fields<R> fields0() {
return new Fields<>(rows[0].fields());
final FieldsImpl<R> fields0() {
return new FieldsImpl<>(rows[0].fields());
}
}

View File

@ -94,7 +94,7 @@ implements
private final XMLPassingMechanism passingMechanism;
private final QueryPartList<XMLTableColumn> columns;
private final boolean hasOrdinality;
private transient Fields<Record> fields;
private transient FieldsImpl<Record> fields;
XMLTable(Field<String> xpath) {
this(xpath, null, null, null, false);
@ -210,14 +210,14 @@ implements
}
@Override
final Fields<Record> fields0() {
final FieldsImpl<Record> fields0() {
if (fields == null) {
List<Field<?>> f = new ArrayList<>();
for (XMLTableColumn c : columns)
f.add(c.field.getDataType() == c.type ? c.field : DSL.field(c.field.getQualifiedName(), c.type));
fields = new Fields<>(f);
fields = new FieldsImpl<>(f);
}
return fields;