This is an automated email from the ASF dual-hosted git repository.

doebele pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/empire-db.git


The following commit(s) were added to refs/heads/master by this push:
     new 8db71d9  EMPIREDB-354 added getAs(column, Class<T> type) method for 
convenience
8db71d9 is described below

commit 8db71d958f9c1c70a0ae002d294d8e5c4c7bbded
Author: Rainer Döbele <[email protected]>
AuthorDate: Fri May 21 10:22:52 2021 +0200

    EMPIREDB-354
    added getAs(column, Class<T> type) method for convenience
---
 .../main/java/org/apache/empire/db/DBRecordData.java | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

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 @@ public abstract class DBRecordData extends DBObject
         }
         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.

Reply via email to