org.jooq.Record Maven / Gradle / Ivy
Show all versions of payment-retries-plugin Show documentation
/*
* Copyright (c) 2009-2016, Data Geekery GmbH (http://www.datageekery.com)
* All rights reserved.
*
* 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.lang.reflect.Constructor;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLData;
import java.sql.Statement;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import javax.annotation.Generated;
import javax.persistence.Column;
import org.jooq.exception.DataTypeException;
import org.jooq.exception.MappingException;
import org.jooq.impl.DefaultRecordMapper;
import org.jooq.impl.DefaultRecordMapperProvider;
import org.jooq.tools.Convert;
/**
* A database result record.
*
* A record essentially combines a list of columns ({@link Field}) with a
* corresponding list of values, each value being of the respective field's
* type.
*
* While records can be seen as generic column / value mappings, their concrete
* implementations often specialise the above description in any of the
* following ways:
*
*
Table records
*
* Records originating from a concrete database table (or view) are modelled by
* jOOQ as {@link TableRecord} or {@link UpdatableRecord}, if they contain a
* primary key. If you're using jOOQ's code generator, you can generate even
* more concrete types of table records, i.e. one table record per table.
*
*
UDT records
*
* {@link SQLDialect#ORACLE} and {@link SQLDialect#POSTGRES} formally support
* user defined types (UDT), which are modelled by jOOQ as {@link UDTRecord}. In
* addition to being regular records (column / value mappings), they also
* implement the JDBC {@link SQLData} API in order to be streamed to a JDBC
* {@link PreparedStatement} or from a JDBC {@link ResultSet}
*
*
Records of well-defined degree
*
* When projecting custom record types in SQL, new ad-hoc types of a certain
* degree are formed on the fly. Records with degree <= 22 are reflected by
* jOOQ through the {@link Record1}, {@link Record2}, ... {@link Record22}
* classes, which cover the respective row value expressions {@link Row1},
* {@link Row2}, ... {@link Row22}
*
* Note that generated TableRecords
and UDTRecords
* also implement a Record[N]
interface, if N <= 22
*
*
Record implements Comparable
*
* jOOQ records have a natural ordering implemented in the same way as this is
* defined in the SQL standard. For more details, see the
* {@link #compareTo(Record)} method
*
* @author Lukas Eder
* @see Result
*/
public interface Record extends Attachable, Comparable {
/**
* Get this record's fields as a {@link Row}.
*/
Row fieldsRow();
/**
* Get a specific field from this Record.
*
* Usually, this will return the field itself. However, if this is a row
* from an aliased table, the field will be aliased accordingly.
*
* @see Row#field(Field)
*/
Field field(Field field);
/**
* Get a specific field from this Record.
*
* @see Row#field(String)
*/
Field> field(String name);
/**
* Get a specific qualified field from this Record.
*
* @see Row#field(Name)
*/
Field> field(Name name);
/**
* Get a specific field from this Record.
*
* @see Row#field(int)
*/
Field> field(int index);
/**
* Get all fields from this Record.
*
* @see Row#fields()
*/
Field>[] fields();
/**
* Get all fields from this Record, providing some fields.
*
* @return All available fields
* @see Row#fields(Field...)
*/
Field>[] fields(Field>... fields);
/**
* Get all fields from this Record, providing some field names.
*
* @return All available fields
* @see Row#fields(String...)
*/
Field>[] fields(String... fieldNames);
/**
* Get all fields from this Record, providing some field names.
*
* @return All available fields
* @see Row#fields(Name...)
*/
Field>[] fields(Name... fieldNames);
/**
* Get all fields from this Record, providing some field indexes.
*
* @return All available fields
* @see Row#fields(int...)
*/
Field>[] fields(int... fieldIndexes);
/**
* Get this record's values as a {@link Row}.
*/
Row valuesRow();
/**
* Get a value from this Record, providing a field.
*
* If this record contains a field with the same {@link Field#getName()} as
* the argument field, that value is retrieved.
*
* @param The generic field parameter
* @param field The field
* @return The value of a field contained in this record
* @throws IllegalArgumentException If the argument field is not contained
* in {@link #fieldsRow()}
*/
T get(Field field) throws IllegalArgumentException;
/**
* Get a converted value from this Record, providing a field.
*
* If this record contains a field with the same {@link Field#getName()} as
* the argument field, that value is retrieved.
*
* @param The conversion type parameter
* @param field The field
* @param type The conversion type
* @return The value of a field contained in this record
* @throws IllegalArgumentException If the argument field is not contained
* in {@link #fieldsRow()}
* @throws DataTypeException wrapping any data type conversion exception
* that might have occurred
* @throws DataTypeException wrapping any data type conversion exception
* that might have occurred
* @see Convert#convert(Object, Class)
*/
T get(Field> field, Class extends T> type) throws IllegalArgumentException, DataTypeException;
/**
* Get a converted value from this Record, providing a field.
*
* If this record contains a field with the same {@link Field#getName()} as
* the argument field, that value is retrieved.
*
* @param The database type parameter
* @param The conversion type parameter
* @param field The field
* @param converter The data type converter
* @return The value of a field contained in this record
* @throws IllegalArgumentException If the argument field is not contained
* in {@link #fieldsRow()}
* @throws DataTypeException wrapping any data type conversion exception
* that might have occurred
* @see Convert#convert(Object, Converter)
*/
U get(Field field, Converter super T, ? extends U> converter) throws IllegalArgumentException,
DataTypeException;
/**
* Get a value from this Record, providing a field name.
*
* @param fieldName The field's name
* @return The value of a field's name contained in this record
* @throws IllegalArgumentException If the argument fieldName is not
* contained in the record
*/
Object get(String fieldName) throws IllegalArgumentException;
/**
* Get a converted value from this Record, providing a field name.
*
* @param The conversion type parameter
* @param fieldName The field's name
* @param type The conversion type
* @return The value of a field's name contained in this record
* @throws IllegalArgumentException If the argument fieldName is not
* contained in the record
* @throws DataTypeException wrapping any data type conversion exception
* that might have occurred
* @see Convert#convert(Object, Class)
*/
T get(String fieldName, Class extends T> type) throws IllegalArgumentException, DataTypeException;
/**
* Get a converted value from this Record, providing a field name.
*
* @param The conversion type parameter
* @param fieldName The field's name
* @param converter The data type converter
* @return The value of a field's name contained in this record
* @throws IllegalArgumentException If the argument fieldName is not
* contained in the record
* @throws DataTypeException wrapping any data type conversion exception
* that might have occurred
* @see Convert#convert(Object, Converter)
*/
U get(String fieldName, Converter, ? extends U> converter) throws IllegalArgumentException, DataTypeException;
/**
* Get a value from this Record, providing a field name.
*
* @param fieldName The field's name
* @return The value of a field's name contained in this record
* @throws IllegalArgumentException If the argument fieldName is not
* contained in the record
*/
Object get(Name fieldName) throws IllegalArgumentException;
/**
* Get a converted value from this Record, providing a field name.
*
* @param The conversion type parameter
* @param fieldName The field's name
* @param type The conversion type
* @return The value of a field's name contained in this record
* @throws IllegalArgumentException If the argument fieldName is not
* contained in the record
* @throws DataTypeException wrapping any data type conversion exception
* that might have occurred
* @see Convert#convert(Object, Class)
*/
T get(Name fieldName, Class extends T> type) throws IllegalArgumentException, DataTypeException;
/**
* Get a converted value from this Record, providing a field name.
*
* @param The conversion type parameter
* @param fieldName The field's name
* @param converter The data type converter
* @return The value of a field's name contained in this record
* @throws IllegalArgumentException If the argument fieldName is not
* contained in the record
* @throws DataTypeException wrapping any data type conversion exception
* that might have occurred
* @see Convert#convert(Object, Converter)
*/
U get(Name fieldName, Converter, ? extends U> converter) throws IllegalArgumentException, DataTypeException;
/**
* Get a value from this record, providing a field index.
*
* @param index The field's index
* @return The value of a field's index contained in this record
* @throws IllegalArgumentException If the argument index is not contained
* in the record
*/
Object get(int index) throws IllegalArgumentException;
/**
* Get a converted value from this record, providing a field index.
*
* @param The conversion type parameter
* @param index The field's index
* @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
* in the record
* @throws DataTypeException wrapping data type conversion exception that
* might have occurred
* @see Convert#convert(Object, Class)
*/
T get(int index, Class extends T> type) throws IllegalArgumentException, DataTypeException;
/**
* Get a converted value from this record, providing a field index.
*
* @param The conversion type parameter
* @param index The field's index
* @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
* in the record
* @throws DataTypeException wrapping data type conversion exception that
* might have occurred
* @see Convert#convert(Object, Converter)
*/
U get(int index, Converter, ? extends U> converter) throws IllegalArgumentException, DataTypeException;
/**
* Set a value into this record.
*
* This will always set the {@link #changed(Field)} flag for the given
* field
, no matter if setting the value actually changes the
* value.
*
* Changing {@link Table#getPrimaryKey()} values will set all
* {@link #changed()} flags to true, in order to produce complete
* INSERT
statements on subsequent
* {@link UpdatableRecord#store()} operations.
*
* @param The generic field parameter
* @param field The field
* @param value The value
*/
void set(Field field, T value);
/**
* Set a value into this record.
*
* This will always set the {@link #changed(Field)} flag for the given
* field
, no matter if setting the value actually changes the
* value.
*
* Changing {@link Table#getPrimaryKey()} values will set all
* {@link #changed()} flags to true, in order to produce complete
* INSERT
statements on subsequent
* {@link UpdatableRecord#store()} operations.
*
* @param The generic field parameter
* @param The conversion type parameter
* @param field The field
* @param value The value
* @param converter The converter used to convert value
into an
* appropriate type
*/
void set(Field field, U value, Converter extends T, ? super U> converter);
/**
* Set a value into this record.
*
* Like {@link #set(Field, Object)} but returning this
for
* fluent setting of multiple values.
*/
Record with(Field field, T value);
/**
* Set a value into this record.
*
* Like {@link #set(Field, Object, Converter)} but returning
* this
for fluent setting of multiple values.
*/
Record with(Field field, U value, Converter extends T, ? super U> converter);
/**
* Get the number of fields of this record.
*/
int size();
/**
* Get this record containing the original values as fetched from the
* database.
*
* Record values can be freely modified after having fetched a record from
* the database. Every record also references the originally fetched values.
* This method returns a new record containing those original values.
*
* @see #original(Field)
* @see #original(int)
* @see #original(String)
*/
Record original();
/**
* Get an original value from this record as fetched from the database.
*
* Record values can be freely modified after having fetched a record from
* the database. Every record also references the originally fetched values.
* This method returns such an original value for a field.
*
* @see #original()
*/
T original(Field field);
/**
* Get an original value from this record as fetched from the database.
*
* Record values can be freely modified after having fetched a record from
* the database. Every record also references the originally fetched values.
* This method returns such an original value for a field.
*
* @see #original()
*/
Object original(int fieldIndex);
/**
* Get an original value from this record as fetched from the database.
*
* Record values can be freely modified after having fetched a record from
* the database. Every record also references the originally fetched values.
* This method returns such an original value for a field.
*
* @see #original()
*/
Object original(String fieldName);
/**
* Get an original value from this record as fetched from the database.
*
* Record values can be freely modified after having fetched a record from
* the database. Every record also references the originally fetched values.
* This method returns such an original value for a field.
*
* @see #original()
*/
Object original(Name fieldName);
/**
* Check if this record has been changed from its original as fetched from
* the database.
*
* If this returns false
, then it can be said that
* record.equals(record.original())
is true.
*
* @see #original()
* @see #changed(Field)
* @see #changed(int)
* @see #changed(String)
*/
boolean changed();
/**
* Check if a field's value has been changed from its original as fetched
* from the database.
*
* @see #changed()
* @see #original(Field)
*/
boolean changed(Field> field);
/**
* Check if a field's value has been changed from its original as fetched
* from the database.
*
* @see #changed()
* @see #original(int)
*/
boolean changed(int fieldIndex);
/**
* Check if a field's value has been changed from its original as fetched
* from the database.
*
* @see #changed()
* @see #original(String)
*/
boolean changed(String fieldName);
/**
* Check if a field's value has been changed from its original as fetched
* from the database.
*
* @see #changed()
* @see #original(Name)
*/
boolean changed(Name fieldName);
/**
* Set all of this record's internal changed flags to the supplied value.
*
* If the changed
argument is false
, the
* {@link #original()} values will be reset to the corresponding "current"
* values as well
*
* @see #changed()
* @see #changed(Field, boolean)
* @see #changed(int, boolean)
* @see #changed(String, boolean)
*/
void changed(boolean changed);
/**
* Set this record's internal changed flag to the supplied value for a given
* field.
*
* If the changed
argument is false
, the
* {@link #original(Field)} value will be reset to the corresponding
* "current" value as well
*
* @see #changed()
* @see #changed(Field)
*/
void changed(Field> field, boolean changed);
/**
* Set this record's internal changed flag to the supplied value for a given
* field.
*
* If the changed
argument is false
, the
* {@link #original(int)} value will be reset to the corresponding "current"
* value as well
*
* @see #changed()
* @see #changed(int)
*/
void changed(int fieldIndex, boolean changed);
/**
* Set this record's internal changed flag to the supplied value for a given
* field.
*
* If the changed
argument is false
, the
* {@link #original(String)} value will be reset to the corresponding
* "current" value as well
*
* @see #changed()
* @see #changed(String)
*/
void changed(String fieldName, boolean changed);
/**
* Set this record's internal changed flag to the supplied value for a given
* field.
*
* If the changed
argument is false
, the
* {@link #original(Name)} value will be reset to the corresponding
* "current" value as well
*
* @see #changed()
* @see #changed(Name)
*/
void changed(Name fieldName, boolean changed);
/**
* Reset all values to their {@link #original()} values and all
* {@link #changed()} flags to false
.
*/
void reset();
/**
* Reset a given value to its {@link #original(Field)} value and its
* {@link #changed(Field)} flag to false
.
*/
void reset(Field> field);
/**
* Reset a given value to its {@link #original(int)} value and its
* {@link #changed(int)} flag to false
.
*/
void reset(int fieldIndex);
/**
* Reset a given value to its {@link #original(String)} value and its
* {@link #changed(String)} flag to false
.
*/
void reset(String fieldName);
/**
* Reset a given value to its {@link #original(Name)} value and its
* {@link #changed(Name)} flag to false
.
*/
void reset(Name fieldName);
/**
* Convert this record into an array.
*
* The resulting array has the same number of elements as this record has
* fields. The resulting array contains data as such:
*
*
* // For arbitrary values of i
* record.getValue(i) == record.intoArray()[i]
*
*
* This is the same as calling into(Object[].class)
*
* @return This record as an array
* @see #fromArray(Object...)
*/
Object[] intoArray();
/**
* Convert this record into a list.
*
* The resulting list has the same number of elements as this record has
* fields. The resulting array contains data as such:
*
*
* // For arbitrary values of i
* record.getValue(i) == record.intoList().get(i)
*
*
* This is the same as calling Arrays.asList(intoArray())
*/
List