aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-09-22 21:07:43 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-09-22 21:15:22 +0100
commit6973ec9109fd2651e2284663b6c8039bd830a677 (patch)
treef1f02ef9e5400805e6c2179dc539ad15c3ce5334 /plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main
parenta02548ec2e98a8a13cd76ecc83379b13cd26030b (diff)
Fix sonar problems in Apex
Fixed some easy to resolve Sonar issues. Issue-ID: POLICY-1034 Change-Id: Ia8e4606bd4307daca499b4a74c96135211e572fd Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main')
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelper.java40
1 files changed, 25 insertions, 15 deletions
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelper.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelper.java
index ed2b521c4..015d9ea30 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelper.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelper.java
@@ -166,21 +166,7 @@ public class AvroSchemaHelper extends AbstractSchemaHelper {
private String getStringObject(final Object object) {
try {
if (isObjectString(object)) {
- String objectString = object.toString().trim();
- if (objectString.length() == 0) {
- return "\"\"";
- } else if (objectString.length() == 1) {
- return "\"" + objectString + "\"";
- } else {
- // All strings must be quoted for decoding
- if (objectString.charAt(0) != '"') {
- objectString = '"' + objectString;
- }
- if (objectString.charAt(objectString.length() - 1) != '"') {
- objectString += '"';
- }
- }
- return objectString;
+ return getObjectString(object);
} else {
return (String) object;
}
@@ -194,6 +180,30 @@ public class AvroSchemaHelper extends AbstractSchemaHelper {
}
}
+ /**
+ * Get a string object.
+ *
+ * @param object the string object
+ * @return the string
+ */
+ private String getObjectString(final Object object) {
+ String objectString = object.toString().trim();
+ if (objectString.length() == 0) {
+ return "\"\"";
+ } else if (objectString.length() == 1) {
+ return "\"" + objectString + "\"";
+ } else {
+ // All strings must be quoted for decoding
+ if (objectString.charAt(0) != '"') {
+ objectString = '"' + objectString;
+ }
+ if (objectString.charAt(objectString.length() - 1) != '"') {
+ objectString += '"';
+ }
+ }
+ return objectString;
+ }
+
private boolean isObjectString(final Object object) {
return object != null && avroSchema.getType().equals(Schema.Type.STRING);
}