details:   https://code.openbravo.com/erp/devel/pi/rev/0f7bd818ce07
changeset: 35562:0f7bd818ce07
user:      Carlos Aristu <carlos.aristu <at> openbravo.com>
date:      Wed Mar 27 11:11:53 2019 +0100
summary:   related to bug 40381: minor code improvements

  - Use instanceof to check the type of the obSelected field
  - Use constant instead of using "Only fetch is supported" literal 3 times

diffstat:

 
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ReadOnlyDataSourceService.java
 |  11 +++++----
 1 files changed, 6 insertions(+), 5 deletions(-)

diffs (50 lines):

diff -r e7e49fefcf93 -r 0f7bd818ce07 
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ReadOnlyDataSourceService.java
--- 
a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ReadOnlyDataSourceService.java
      Thu Mar 07 19:03:09 2019 +0530
+++ 
b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ReadOnlyDataSourceService.java
      Wed Mar 27 11:11:53 2019 +0100
@@ -47,6 +47,7 @@
   private static final Logger log = LogManager.getLogger();
   private static final int MAX_PAGE_SIZE_INCREASE = 3;
   private static final String NEW_END_ROW = "_newEndRow";
+  private static final String UNSUPPORTED_OPERATION_MSG = "Only fetch is 
supported";
 
   /*
    * (non-Javadoc)
@@ -194,9 +195,9 @@
     Map<String, Object> lastRecord = data.get(data.size() - 1);
     Object obSelected = lastRecord.get("obSelected");
     if (obSelected != null) {
-      if (obSelected.getClass().equals(Boolean.class)) {
+      if (obSelected instanceof Boolean) {
         isLastRecordSelected = (Boolean) obSelected;
-      } else if (obSelected.getClass().equals(String.class)) {
+      } else if (obSelected instanceof String) {
         isLastRecordSelected = ((String) obSelected).equalsIgnoreCase("Y");
       }
     }
@@ -234,7 +235,7 @@
    */
   @Override
   public String remove(Map<String, String> parameters) {
-    throw new UnsupportedOperationException("Only fetch is supported");
+    throw new UnsupportedOperationException(UNSUPPORTED_OPERATION_MSG);
   }
 
   /*
@@ -244,7 +245,7 @@
    */
   @Override
   public String add(Map<String, String> parameters, String content) {
-    throw new UnsupportedOperationException("Only fetch is supported");
+    throw new UnsupportedOperationException(UNSUPPORTED_OPERATION_MSG);
   }
 
   /*
@@ -254,7 +255,7 @@
    */
   @Override
   public String update(Map<String, String> parameters, String content) {
-    throw new UnsupportedOperationException("Only fetch is supported");
+    throw new UnsupportedOperationException(UNSUPPORTED_OPERATION_MSG);
   }
 
   /**


_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to