summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src')
-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);
}