aboutsummaryrefslogtreecommitdiffstats
path: root/utils/src/main/java/org/onap/policy/common/utils/coder/Coder.java
AgeCommit message (Collapse)AuthorFilesLines
2020-02-17Add convert() to CoderJim Hahn1-1/+33
This addresses Liam's review comment about moving the "translate" method from the actor Util class into policy-common. Added a method to Coder to convert from one object type to another (e.g., from a Map to a POJO, or vice versa). Issue-ID: POLICY-2363 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I2a0b5ab4ce4b0eeda216a57cbe23a8bb64f64940
2020-01-31Add pretty() method to CoderJim Hahn1-2/+12
"Pretty" JSON is often needed, so added Coder.pretty() to facilitate that. Incorporated review comment(s): - changed pretty() to encode(object, pretty) Issue-ID: POLICY-1625 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I180fa6de416836008bf1c410132ae30f4dde9271
2019-03-01Add StandardCoderObject to hide GSON internalsJim Hahn1-0/+18
Added StandardCoderObject to hide GSON's JsonElement so that classes are not dependent on the use of JsonElement, making it easier to switch out serialization mechanisms in the future. Added a test for field-not-found. Converted tabs to spaces in json test file. Simplified StandardCoderObject and added methods to Coder for translating to and from StandardCoderObject. Removed a test for a method that no longer exists. Added more tests to a test case. Change-Id: I5123dc3f17c940ded431ef7f9ccd8c4bff6b1c5f Issue-ID: POLICY-1444 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-27Add additional encode and decode methods to CoderJim Hahn1-1/+64
Also: Updated some comments and renamed a few parameters. Removed a "throws" for a RuntimeException. Short-circuit some calls. Typo in comment. Let gson create the JsonWriter. Renamed a few more parameters. Change-Id: I22e48c2191820c2a3d0743200edca79bd74353e7 Issue-ID: POLICY-1444 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-27Add common coder classesJim Hahn1-0/+46
Added coder classes as a common utility that can be used to encode and decode json data. Currently, it uses gson, but that can be changed. Separated the Coder interface from implementation. Used assertSame to compare references. Used numbers instead of strings so don't have to deal with escaping quotes in the test cases. Change-Id: Iea9001d2adc5a3150b3367619b5f43e96b5f8b41 Issue-ID: POLICY-1444 Signed-off-by: Jim Hahn <jrh3@att.com>