EMPIREDB-354
added getAs(column, Class<T> type) method for convenience
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java b/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java
index 61e08b1..1ec4623 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java
@@ -349,6 +349,26 @@
}
return getEnum(getFieldIndex(column), (Class<T>)enumType);
}
+
+ /**
+ * Returns the value of a field as an object of a given (wrapper)type
+ * @param index index of the field
+ * @return the value
+ */
+ public final <T> T getAs(int index, Class<T> wrapperType)
+ {
+ return ObjectUtils.convert(wrapperType, getValue(index));
+ }
+
+ /**
+ * Returns the value of a field as an object of a given (wrapper)type
+ * @param column the column for which to retrieve the value
+ * @return the value
+ */
+ public final <T> T getAs(Column column, Class<T> wrapperType)
+ {
+ return ObjectUtils.convert(wrapperType, getValue(column));
+ }
/**
* Checks whether or not the value for the given column is null.