diff options
author | Jim Hahn <jrh3@att.com> | 2019-02-28 21:59:33 -0500 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2019-03-01 01:08:42 -0500 |
commit | ddb5911efe46953200be8965ac65ae9bbc8a36ee (patch) | |
tree | 5e328e8205d2076b262943b65ade74584893430d /utils/src/main/java/org/onap/policy/common/utils/coder/Coder.java | |
parent | 3849ce18d51e308bbd58b71219472c23b5f3e814 (diff) |
Add StandardCoderObject to hide GSON internals
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>
Diffstat (limited to 'utils/src/main/java/org/onap/policy/common/utils/coder/Coder.java')
-rw-r--r-- | utils/src/main/java/org/onap/policy/common/utils/coder/Coder.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/utils/src/main/java/org/onap/policy/common/utils/coder/Coder.java b/utils/src/main/java/org/onap/policy/common/utils/coder/Coder.java index 66a308f7..bb51f2b9 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/coder/Coder.java +++ b/utils/src/main/java/org/onap/policy/common/utils/coder/Coder.java @@ -106,4 +106,22 @@ public interface Coder { * @throws CoderException if an error occurs */ <T> T decode(File source, Class<T> clazz) throws CoderException; + + /** + * Converts an object/POJO to a standard object. + * + * @param object object to be converted + * @return a new standard object representing the original object + * @throws CoderException if an error occurs + */ + StandardCoderObject toStandard(Object object) throws CoderException; + + /** + * Converts a standard object to an object/POJO. + * + * @param sco the standard object to be converted + * @return a new object represented by the standard object + * @throws CoderException if an error occurs + */ + <T> T fromStandard(StandardCoderObject sco, Class<T> clazz) throws CoderException; } |