details: https://code.openbravo.com/erp/devel/pi/rev/d9439b0b660b changeset: 34094:d9439b0b660b user: Carlos Aristu <carlos.aristu <at> openbravo.com> date: Tue May 29 12:59:42 2018 +0200 summary: related to bug 38489: Minor code improvements in convertToJsonObjects method
- Use diamond operator - Iterate over the entrySet instead of the keySet - Removed useless comment diffstat: modules/org.openbravo.service.json/src/org/openbravo/service/json/DataToJsonConverter.java | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diffs (39 lines): diff -r 71b2155a083e -r d9439b0b660b modules/org.openbravo.service.json/src/org/openbravo/service/json/DataToJsonConverter.java --- a/modules/org.openbravo.service.json/src/org/openbravo/service/json/DataToJsonConverter.java Tue May 29 12:36:13 2018 +0200 +++ b/modules/org.openbravo.service.json/src/org/openbravo/service/json/DataToJsonConverter.java Tue May 29 12:59:42 2018 +0200 @@ -27,6 +27,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import org.apache.commons.codec.binary.Base64; @@ -99,15 +100,16 @@ */ public List<JSONObject> convertToJsonObjects(List<Map<String, Object>> data) { try { - final List<JSONObject> jsonObjects = new ArrayList<JSONObject>(); + final List<JSONObject> jsonObjects = new ArrayList<>(); for (Map<String, Object> dataInstance : data) { final JSONObject jsonObject = new JSONObject(); - for (String key : dataInstance.keySet()) { + for (Entry<String, Object> entry : dataInstance.entrySet()) { + String key = entry.getKey(); Property property = null; if (this.entity != null) { property = entity.getProperty(key, false); } - final Object value = dataInstance.get(key); + final Object value = entry.getValue(); if (value instanceof BaseOBObject) { Property referencedProperty = property != null ? property.getReferencedProperty() : null; @@ -121,7 +123,6 @@ // server timezone offset to UTC, among other things convertedValue = convertPrimitiveValue(property, value); } else { - // TODO: format! convertedValue = convertPrimitiveValue(value); } jsonObject.put(key, convertedValue); ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits