aboutsummaryrefslogtreecommitdiffstats
path: root/gson/src/main/java/org/onap/policy/common/gson/MapDoubleAdapterFactory.java
AgeCommit message (Collapse)AuthorFilesLines
2021-05-06Fix sonars in policy-commonJim Hahn1-2/+2
Fixed sonars: - use "var" instead of actual type name - re-interrupt threads - use rej2 split() instead of String split() Issue-ID: POLICY-3285 Change-Id: I82261e0b8a53ee5c5264556fbf5cec37454f014e Signed-off-by: Jim Hahn <jrh3@att.com>
2020-04-13Fix handling of number fields YamlJim Hahn1-4/+16
This fix also impacts StandardCoder, allowing Map.class to be used as the target type instead of requiring LinkedHashMap.class. Note: still doesn't do any translation if Object.class is used, as there is no way to override GSON's handler for the Object type. Issue-ID: POLICY-2488 Change-Id: Ia7cd0c85dc5a2a9e93360fa1c8397531b8503f2d Signed-off-by: Jim Hahn <jrh3@att.com>
2019-07-17Convert double to int when decoding via gsonJim Hahn1-66/+24
Refactored MapDoubleAdapterFactory, extracting DoubleConverter to be used by code needing to convert Double to Integer/Long after being decoded by GSON. Enhanced StandardCoder to automatically use the above converter if the desired class is a generic Object. Change-Id: I1d4e83910de41ceda383f257bfea706db2b8fbbe Issue-ID: POLICY-1919 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-29Fix sonar issue with double compare4.0.0-ONAP1.4.0Jim Hahn1-2/+2
The gson code to convert Double to Long/Integer use a direct comparison of the original double with a long. However, sonar does not like that so changed the code to use the Double.compare() method instead. Also fixed sonar issue with diamond operator. Addressed some sonar issues in ServiceManager. Addressed some sonar issues in Version. Change-Id: I0959603918d251db671e87e12c295c6ec911f427 Issue-ID: POLICY-1707 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-11Don't map JSON values to DoubleJim Hahn1-0/+152
By default, gson treats all numbers as Double when placed into a generic Map. This is not backward compatible with existing policy APIs. Added a type adapter that walks Map objects and converts the Double values to Integer or Long, where possible. Made this the default behavior in the GsonMessageBodyHandler, the JacksonHandler, and the StandardCoder. Also fixed a couple of checkstyle errors in the gson project. Change-Id: I9ac0c77e6592d1c039646f0662c077b77a1e9aaf Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>