garydgregory commented on code in PR #220:
URL: https://github.com/apache/commons-dbutils/pull/220#discussion_r1402070369


##########
src/test/java/org/apache/commons/dbutils/MockResultSet.java:
##########
@@ -265,64 +266,86 @@ protected String getString(final int columnIndex) throws 
SQLException {
     }
 
     @Override
-    public Object invoke(final Object proxy, final Method method, final 
Object[] args) throws Throwable {
+    public Object invoke(final Object proxy, final Method method, final 
Object[] args)
+        throws Throwable {
 
         final String methodName = method.getName();
-
         if (methodName.equals("getMetaData")) {
-            return this.getMetaData();
-
+            return handleGetMetaData();
         }
         if (methodName.equals("next")) {
-            return this.next();
-
+            return handleNext();
         }
-        if (methodName.equals("previous") || methodName.equals("close")) {
-
-        } else if (methodName.equals("getBoolean")) {
-            return this.getBoolean(columnIndex(args));
-
-        } else if (methodName.equals("getByte")) {
-            return this.getByte(columnIndex(args));
-
-        } else if (methodName.equals("getDouble")) {
-            return this.getDouble(columnIndex(args));
-
-        } else if (methodName.equals("getFloat")) {
-            return this.getFloat(columnIndex(args));
-
-        } else if (methodName.equals("getInt")) {
-            return this.getInt(columnIndex(args));
-
-        } else if (methodName.equals("getLong")) {
-            return this.getLong(columnIndex(args));
-
-        } else if (methodName.equals("getObject")) {
-            return this.getObject(columnIndex(args));
-
-        } else if (methodName.equals("getShort")) {
-            return this.getShort(columnIndex(args));
+        if (methodName.equals("previous")) {
+            // Handle previous method
+        } else if (methodName.equals("close")) {
+            // Handle close method
+        } else if (isColumnMethod(methodName)) {
+            return handleColumnMethod(methodName, args);
+        } else if (isNonColumnMethod(methodName)) {
+            return handleNonColumnMethod(methodName, proxy, args);
+        }
+        throw new UnsupportedOperationException("Unsupported method: " + 
methodName);
+    }
 
-        } else if (methodName.equals("getString")) {
-            return this.getString(columnIndex(args));
+    // Define methods for handling specific cases
+    private Object handleGetMetaData() throws SQLException {

Review Comment:
   This is superfluous IMO; just leave the implementation inlined as it was.



##########
src/test/java/org/apache/commons/dbutils/MockResultSet.java:
##########
@@ -265,64 +266,86 @@ protected String getString(final int columnIndex) throws 
SQLException {
     }
 
     @Override
-    public Object invoke(final Object proxy, final Method method, final 
Object[] args) throws Throwable {
+    public Object invoke(final Object proxy, final Method method, final 
Object[] args)
+        throws Throwable {
 
         final String methodName = method.getName();
-
         if (methodName.equals("getMetaData")) {
-            return this.getMetaData();
-
+            return handleGetMetaData();
         }
         if (methodName.equals("next")) {
-            return this.next();
-
+            return handleNext();
         }
-        if (methodName.equals("previous") || methodName.equals("close")) {
-
-        } else if (methodName.equals("getBoolean")) {
-            return this.getBoolean(columnIndex(args));
-
-        } else if (methodName.equals("getByte")) {
-            return this.getByte(columnIndex(args));
-
-        } else if (methodName.equals("getDouble")) {
-            return this.getDouble(columnIndex(args));
-
-        } else if (methodName.equals("getFloat")) {
-            return this.getFloat(columnIndex(args));
-
-        } else if (methodName.equals("getInt")) {
-            return this.getInt(columnIndex(args));
-
-        } else if (methodName.equals("getLong")) {
-            return this.getLong(columnIndex(args));
-
-        } else if (methodName.equals("getObject")) {
-            return this.getObject(columnIndex(args));
-
-        } else if (methodName.equals("getShort")) {
-            return this.getShort(columnIndex(args));
+        if (methodName.equals("previous")) {
+            // Handle previous method
+        } else if (methodName.equals("close")) {
+            // Handle close method
+        } else if (isColumnMethod(methodName)) {
+            return handleColumnMethod(methodName, args);
+        } else if (isNonColumnMethod(methodName)) {
+            return handleNonColumnMethod(methodName, proxy, args);
+        }
+        throw new UnsupportedOperationException("Unsupported method: " + 
methodName);
+    }
 
-        } else if (methodName.equals("getString")) {
-            return this.getString(columnIndex(args));
+    // Define methods for handling specific cases
+    private Object handleGetMetaData() throws SQLException {
+        return this.getMetaData();
+    }
 
-        } else if (methodName.equals("wasNull")) {
-            return this.wasNull();
+    private Object handleNext() throws SQLException {

Review Comment:
   This is superfluous IMO; just leave the implementation inlined as it was.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to