[#2156] Add Row.type(int), type(String), dataType(int), dataType(String)

for convenience
This commit is contained in:
Lukas Eder 2013-02-04 15:55:37 +01:00
parent 54883e3b37
commit 27f8eca2c4
3 changed files with 76 additions and 4 deletions

View File

@ -1257,6 +1257,16 @@ class Rows extends Generators {
return result;
}
@Override
public final Class<?> type(int fieldIndex) {
return fieldIndex >= 0 && fieldIndex < size() ? fields.field(fieldIndex).getType() : null;
}
@Override
public final Class<?> type(String fieldName) {
return type(indexOf(fieldName));
}
@Override
public final DataType<?>[] dataTypes() {
int size = fields.size();
@ -1268,6 +1278,16 @@ class Rows extends Generators {
return result;
}
@Override
public final DataType<?> dataType(int fieldIndex) {
return fieldIndex >= 0 && fieldIndex < size() ? fields.field(fieldIndex).getDataType() : null;
}
@Override
public final DataType<?> dataType(String fieldName) {
return dataType(indexOf(fieldName));
}
«FOR degree : (1..Constants::MAX_ROW_DEGREE)»
@Override

View File

@ -66,18 +66,18 @@ public interface Row extends QueryPart, Iterable<Field<?>> {
/**
* Get a specific field from this row.
*
* @param name The field to fetch
* @param fieldName The field to fetch
* @return The field with the given name
*/
Field<?> field(String name);
Field<?> field(String fieldName);
/**
* Get a specific field from this row.
*
* @param index The field's index of the field to fetch
* @param fieldIndex The field's index of the field to fetch
* @return The field with the given name
*/
Field<?> field(int index);
Field<?> field(int fieldIndex);
/**
* Get all fields from this row.
@ -112,6 +112,22 @@ public interface Row extends QueryPart, Iterable<Field<?>> {
*/
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
*/
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
*/
Class<?> type(String fieldName);
/**
* Get an array of data types for this row.
* <p>
@ -120,6 +136,22 @@ public interface Row extends QueryPart, Iterable<Field<?>> {
*/
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
*/
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
*/
DataType<?> dataType(String fieldName);
// ------------------------------------------------------------------------
// [NOT] NULL predicates
// ------------------------------------------------------------------------

View File

@ -251,6 +251,16 @@ implements
return result;
}
@Override
public final Class<?> type(int fieldIndex) {
return fieldIndex >= 0 && fieldIndex < size() ? fields.field(fieldIndex).getType() : null;
}
@Override
public final Class<?> type(String fieldName) {
return type(indexOf(fieldName));
}
@Override
public final DataType<?>[] dataTypes() {
int size = fields.size();
@ -263,6 +273,16 @@ implements
return result;
}
@Override
public final DataType<?> dataType(int fieldIndex) {
return fieldIndex >= 0 && fieldIndex < size() ? fields.field(fieldIndex).getDataType() : null;
}
@Override
public final DataType<?> dataType(String fieldName) {
return dataType(indexOf(fieldName));
}
@Override
public final Field<T1> field1() {
return (Field<T1>) fields.field(0);