From 611f63a4bb71d677cf2665b1794e91148ba42a51 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Wed, 17 Jun 2020 08:37:15 -0400 Subject: Cleanup various sonar issues in policy-common Addressed the following issues: - unused imports - unused method parameters - use assertEquals, assertSame instead of assertTrue - provide the parametrized type for this generic Also fixed some checkstyle issues: - removed blank lines between "import" groups Issue-ID: POLICY-2650 Change-Id: I004bb650ac10c49ccd0fc405f6959896fec39f9b Signed-off-by: Jim Hahn --- .../onap/policy/common/gson/internal/Adapter.java | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'gson') diff --git a/gson/src/main/java/org/onap/policy/common/gson/internal/Adapter.java b/gson/src/main/java/org/onap/policy/common/gson/internal/Adapter.java index 39ec6bd0..64a51d0b 100644 --- a/gson/src/main/java/org/onap/policy/common/gson/internal/Adapter.java +++ b/gson/src/main/java/org/onap/policy/common/gson/internal/Adapter.java @@ -127,8 +127,8 @@ public class Adapter { ConvInfo wtr = writer; - @SuppressWarnings("rawtypes") - TypeAdapter conv = (wtr.clazz == clazz ? wtr.getConverter() : gson.getAdapter(clazz)); + TypeAdapter conv = + (wtr.clazz == clazz ? wtr.getConverter() : (TypeAdapter) gson.getAdapter(clazz)); return conv.toJsonTree(object); } @@ -316,36 +316,33 @@ public class Adapter { /** * Type on which the converter works. */ - @SuppressWarnings("rawtypes") - private TypeToken type; + private TypeToken type; /** * Class of object on which the converter works. */ - @SuppressWarnings("rawtypes") - private Class clazz; + private Class clazz; /** * Converter to use, initialized lazily. */ - @SuppressWarnings("rawtypes") - private TypeAdapter conv = null; + private TypeAdapter conv = null; /** * Constructs the object. * * @param type type of object to be converted */ - public ConvInfo(@SuppressWarnings("rawtypes") TypeToken type) { + public ConvInfo(TypeToken type) { this.type = type; this.clazz = type.getRawType(); } - @SuppressWarnings({"rawtypes", "unchecked"}) - public final TypeAdapter getConverter() { + @SuppressWarnings("unchecked") + public final TypeAdapter getConverter() { if (conv == null) { // race condition here, but it's ok to overwrite a previous value - this.conv = gson.getAdapter(type); + this.conv = (TypeAdapter) gson.getAdapter(type); } return conv; -- cgit 1.2.3-korg