[#1184] Add DataType.isArray()

This commit is contained in:
Lukas Eder 2012-02-26 11:59:00 +00:00
parent 6ab797d87b
commit 2da4878ff5
3 changed files with 19 additions and 0 deletions

View File

@ -881,6 +881,10 @@ extends BaseTest<A, B, S, B2S, BS, L, X, DATE, D, T, U, I, IPK, T658, T725, T639
if (TArrays_NUMBER_R() != null) {
Result<Record> result;
// [#1184] Test data type
assertTrue(TArrays_NUMBER_R().getDataType().isArray());
assertFalse(TBook_ID().getDataType().isArray());
// An empty array
// --------------
ArrayRecord<Integer> array = newNUMBER_R();
@ -990,6 +994,10 @@ extends BaseTest<A, B, S, B2S, BS, L, X, DATE, D, T, U, I, IPK, T658, T725, T639
Table<?> table;
Integer[] array;
// [#1184] Test data type
assertTrue(TArrays_NUMBER().getDataType().isArray());
assertFalse(TBook_ID().getDataType().isArray());
// Cross join the array table with the unnested string array value
// ---------------------------------------------------------------

View File

@ -210,4 +210,9 @@ public interface DataType<T> extends Serializable {
* </ul>
*/
boolean isBinary();
/**
* Whether this data type is an array type.
*/
boolean isArray();
}

View File

@ -454,6 +454,12 @@ public abstract class AbstractDataType<T> implements DataType<T> {
return type == byte[].class;
}
@Override
public final boolean isArray() {
return ArrayRecord.class.isAssignableFrom(type)
|| (!isBinary() && type.isArray());
}
// ------------------------------------------------------------------------
// The Object API
// ------------------------------------------------------------------------