diff options
author | Munir Ahmad <munir.ahmad@bell.ca> | 2018-02-24 13:12:56 -0500 |
---|---|---|
committer | Munir Ahmad <munir.ahmad@bell.ca> | 2018-02-27 00:40:10 +0000 |
commit | 40bb7adfbbe26be4e459e269bfd277436deb21cf (patch) | |
tree | dda603845f2ffac80079e5b1c9aa8451edbb2db0 /adapters | |
parent | 250de788c5cf40cc8a73c7aad4dc2f482f821768 (diff) |
Make use of append instead of string concatenation
Change-Id: I94ad658026f165ba8b5a74352095188a27ee50e5
Issue-ID: SO-437
Signed-off-by: Munir Ahmad <munir.ahmad@bell.ca>
Diffstat (limited to 'adapters')
10 files changed, 92 insertions, 91 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java index 8da3b212d9..2d6d0271f8 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java @@ -185,12 +185,12 @@ public class CloudConfigFactory implements Serializable { StringBuffer response = new StringBuffer (); response.append ("Cloud Sites:\n"); for (CloudSite site : cloudConfig.getCloudSites ().values ()) { - response.append (site.toString () + "\n"); + response.append(site.toString()).append("\n"); } response.append ("\n\nCloud Identity Services:\n"); for (CloudIdentity identity : cloudConfig.getIdentityServices ().values ()) { - response.append (identity.toString () + "\n"); + response.append(identity.toString()).append("\n"); } return Response.status (200).entity (response).build (); diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java index 20535e93c8..9fe2d4c786 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java @@ -1217,18 +1217,18 @@ public class MsoHeatUtils extends MsoCommonUtils { } else { for (String key : params.keySet()) { if (params.get(key) instanceof String) { - sb.append("\n" + key + "=" + (String) params.get(key)); + sb.append("\n").append(key).append("=").append((String) params.get(key)); } else if (params.get(key) instanceof JsonNode) { String jsonStringOut = this.convertNode((JsonNode)params.get(key)); - sb.append("\n" + key + "=" + jsonStringOut); + sb.append("\n").append(key).append("=").append(jsonStringOut); } else if (params.get(key) instanceof Integer) { String integerOut = "" + params.get(key); - sb.append("\n" + key + "=" + integerOut); + sb.append("\n").append(key).append("=").append(integerOut); } else { try { String str = params.get(key).toString(); - sb.append("\n" + key + "=" + str); + sb.append("\n").append(key).append("=").append(str); } catch (Exception e) { LOGGER.debug("Exception :",e); } @@ -1272,16 +1272,16 @@ public class MsoHeatUtils extends MsoCommonUtils { int counter = 0; sb.append("OUTPUTS:\n"); for (String key : outputs.keySet()) { - sb.append("outputs[" + counter++ + "]: " + key + "="); + sb.append("outputs[").append(counter++).append("]: ").append(key).append("="); Object obj = outputs.get(key); if (obj instanceof String) { - sb.append((String)obj +" (a string)"); + sb.append((String) obj).append(" (a string)"); } else if (obj instanceof JsonNode) { - sb.append(this.convertNode((JsonNode)obj) + " (a JsonNode)"); + sb.append(this.convertNode((JsonNode) obj)).append(" (a JsonNode)"); } else if (obj instanceof java.util.LinkedHashMap) { try { String str = JSON_MAPPER.writeValueAsString(obj); - sb.append(str + " (a java.util.LinkedHashMap)"); + sb.append(str).append(" (a java.util.LinkedHashMap)"); } catch (Exception e) { LOGGER.debug("Exception :",e); sb.append("(a LinkedHashMap value that would not convert nicely)"); diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java index 2465b30eca..0e0b9cb70d 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java @@ -365,16 +365,16 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils { int counter = 0; sb.append("OUTPUTS:\n"); for (String key : outputs.keySet()) { - sb.append("outputs[" + counter++ + "]: " + key + "="); + sb.append("outputs[").append(counter++).append("]: ").append(key).append("="); Object obj = outputs.get(key); if (obj instanceof String) { - sb.append((String)obj +" (a string)"); + sb.append((String) obj).append(" (a string)"); } else if (obj instanceof JsonNode) { - sb.append(this.convertNode((JsonNode)obj) + " (a JsonNode)"); + sb.append(this.convertNode((JsonNode) obj)).append(" (a JsonNode)"); } else if (obj instanceof java.util.LinkedHashMap) { try { String str = JSON_MAPPER.writeValueAsString(obj); - sb.append(str + " (a java.util.LinkedHashMap)"); + sb.append(str).append(" (a java.util.LinkedHashMap)"); } catch (Exception e) { LOGGER.debug("Exception :", e); sb.append("(a LinkedHashMap value that would not convert nicely)"); diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java index 9a82ed2c6e..f7758c315c 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java @@ -62,30 +62,30 @@ public class QueryAllottedResourceCustomization extends CatalogQuery { @Override public String toString () { - StringBuilder buf = new StringBuilder(); + StringBuilder sb = new StringBuilder(); boolean first = true; int i = 1; for (AllottedResourceCustomization o : allottedResourceCustomization) { - buf.append(i+"\t"); - if (!first) buf.append("\n"); first = false; - buf.append(o); + sb.append(i).append("\t"); + if (!first) sb.append("\n"); first = false; + sb.append(o); } - return buf.toString(); + return sb.toString(); } @Override public String JSON2(boolean isArray, boolean isEmbed) { - StringBuilder buf = new StringBuilder(); - if (!isEmbed && isArray) buf.append("{ "); - if (isArray) buf.append("\"serviceAllottedResources\": ["); + StringBuilder sb = new StringBuilder(); + if (!isEmbed && isArray) sb.append("{ "); + if (isArray) sb.append("\"serviceAllottedResources\": ["); Map<String, String> valueMap = new HashMap<>(); String sep = ""; boolean first = true; if (this.allottedResourceCustomization != null) { for (AllottedResourceCustomization o : allottedResourceCustomization) { - if (first) buf.append("\n"); first = false; + if (first) sb.append("\n"); first = false; boolean arNull = o.getAllottedResource() == null ? true : false; @@ -104,14 +104,14 @@ public class QueryAllottedResourceCustomization extends CatalogQuery { put(valueMap, "NF_NAMING_CODE", o.getNfNamingCode()); put(valueMap, "PROVIDING_SERVICE_MODEL_INVARIANT_UUID", o.getProvidingServiceModelInvariantUuid()); - buf.append(sep+ this.setTemplate(template, valueMap)); + sb.append(sep).append(this.setTemplate(template, valueMap)); sep = ",\n"; } } - if (!first) buf.append("\n"); - if (isArray) buf.append("]"); - if (!isEmbed && isArray) buf.append("}"); - return buf.toString(); + if (!first) sb.append("\n"); + if (isArray) sb.append("]"); + if (!isEmbed && isArray) sb.append("}"); + return sb.toString(); } } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java index 59c601ef19..c04068d680 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java @@ -67,30 +67,30 @@ public class QueryServiceNetworks extends CatalogQuery { @Override public String toString () { - StringBuilder buf = new StringBuilder(); + StringBuilder sb = new StringBuilder(); boolean first = true; int i = 1; for (NetworkResourceCustomization o : serviceNetworks) { - buf.append(i+"\t"); - if (!first) buf.append("\n"); first = false; - buf.append(o); + sb.append(i).append("\t"); + if (!first) sb.append("\n"); first = false; + sb.append(o); } - return buf.toString(); + return sb.toString(); } @Override public String JSON2(boolean isArray, boolean isEmbed) { - StringBuilder buf = new StringBuilder(); - if (!isEmbed && isArray) buf.append("{ "); - if (isArray) buf.append("\"serviceNetworks\": ["); - //if (isArray) buf.append("["); + StringBuilder sb = new StringBuilder(); + if (!isEmbed && isArray) sb.append("{ "); + if (isArray) sb.append("\"serviceNetworks\": ["); + Map<String, String> valueMap = new HashMap<>(); String sep = ""; boolean first = true; for (NetworkResourceCustomization o : serviceNetworks) { - if (first) buf.append("\n"); first = false; + if (first) sb.append("\n"); first = false; boolean nrNull = o.getNetworkResource() == null ? true : false; put(valueMap, "MODEL_NAME", nrNull ? null : o.getNetworkResource().getModelName()); put(valueMap, "MODEL_UUID", nrNull ? null : o.getNetworkResource().getModelUUID()); @@ -104,12 +104,12 @@ public class QueryServiceNetworks extends CatalogQuery { put(valueMap, "NETWORK_SCOPE", o.getNetworkScope()); put(valueMap, "NETWORK_TECHNOLOGY", o.getNetworkTechnology()); - buf.append(sep+ this.setTemplate(template, valueMap)); + sb.append(sep).append(this.setTemplate(template, valueMap)); sep = ",\n"; } - if (!first) buf.append("\n"); - if (isArray) buf.append("]"); - if (!isEmbed && isArray) buf.append("}"); - return buf.toString(); + if (!first) sb.append("\n"); + if (isArray) sb.append("]"); + if (!isEmbed && isArray) sb.append("}"); + return sb.toString(); } } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java index cfbb781ae8..f0d4327950 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java @@ -72,29 +72,29 @@ public class QueryServiceVnfs extends CatalogQuery { @Override public String toString () { - StringBuilder buf = new StringBuilder(); + StringBuilder sb = new StringBuilder(); boolean first = true; int i = 1; for (VnfResourceCustomization o : serviceVnfs) { - buf.append(i+"\t"); - if (!first) buf.append("\n"); first = false; - buf.append(o); + sb.append(i).append("\t"); + if (!first) sb.append("\n"); first = false; + sb.append(o); } - return buf.toString(); + return sb.toString(); } @Override public String JSON2(boolean isArray, boolean isEmbed) { - StringBuilder buf = new StringBuilder(); - if (!isEmbed && isArray) buf.append("{ "); - if (isArray) buf.append("\"serviceVnfs\": ["); + StringBuilder sb = new StringBuilder(); + if (!isEmbed && isArray) sb.append("{ "); + if (isArray) sb.append("\"serviceVnfs\": ["); Map<String, String> valueMap = new HashMap<>(); String sep = ""; boolean first = true; for (VnfResourceCustomization o : serviceVnfs) { - if (first) buf.append("\n"); first = false; + if (first) sb.append("\n"); first = false; boolean vrNull = o.getVnfResource() == null ? true : false; @@ -113,12 +113,12 @@ public class QueryServiceVnfs extends CatalogQuery { String subitem = new QueryVfModule(vrNull ? null : o.getVfModuleCustomizations()).JSON2(true, true); valueMap.put("_VFMODULES_", subitem.replaceAll("(?m)^", "\t\t")); - buf.append(sep+ this.setTemplate(template, valueMap)); + sb.append(sep).append(this.setTemplate(template, valueMap)); sep = ",\n"; } - if (!first) buf.append("\n"); - if (isArray) buf.append("]"); - if (!isEmbed && isArray) buf.append("}"); - return buf.toString(); + if (!first) sb.append("\n"); + if (isArray) sb.append("]"); + if (!isEmbed && isArray) sb.append("}"); + return sb.toString(); } } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java index b2caa99a39..fe0f0cbc17 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java @@ -69,28 +69,28 @@ public class QueryVfModule extends CatalogQuery { @Override public String toString () { - StringBuilder buf = new StringBuilder(); + StringBuilder sb = new StringBuilder(); boolean first = true; int i = 1; for (VfModuleCustomization o : vfModules) { - buf.append(i+"\t"); - if (!first) buf.append("\n"); first = false; - buf.append(o); + sb.append(i).append("\t"); + if (!first) sb.append("\n"); first = false; + sb.append(o); } - return buf.toString(); + return sb.toString(); } @Override public String JSON2(boolean isArray, boolean x) { - StringBuilder buf = new StringBuilder(); - if (isArray) buf.append("\"vfModules\": ["); + StringBuilder sb = new StringBuilder(); + if (isArray) sb.append("\"vfModules\": ["); Map<String, String> valueMap = new HashMap<>(); String sep = ""; boolean first = true; for (VfModuleCustomization o : vfModules) { - if (first) buf.append("\n"); first = false; + if (first) sb.append("\n"); first = false; boolean vfNull = o.getVfModule() == null ? true : false; boolean hasVolumeGroup = false; @@ -109,11 +109,11 @@ public class QueryVfModule extends CatalogQuery { put(valueMap, "INITIAL_COUNT", o.getInitialCount()); put(valueMap, "HAS_VOLUME_GROUP", hasVolumeGroup); - buf.append(sep+ this.setTemplate(template, valueMap)); + sb.append(sep).append(this.setTemplate(template, valueMap)); sep = ",\n"; } - if (!first) buf.append("\n"); - if (isArray) buf.append("]"); - return buf.toString(); + if (!first) sb.append("\n"); + if (isArray) sb.append("]"); + return sb.toString(); } } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java index ff713991f9..00a5cafb29 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java @@ -58,17 +58,17 @@ public class QueryVfModules { @Override public String toString () { - StringBuilder buf = new StringBuilder(); + StringBuilder sb = new StringBuilder(); boolean first = true; int i = 1; for (VfModule o : vfModules) { - buf.append(i+"\t"); - if (!first) buf.append("\n"); + sb.append(i).append("\t"); + if (!first) sb.append("\n"); first = false; - buf.append(o); + sb.append(o); } - return buf.toString(); + return sb.toString(); } public String toJsonString() { diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java index f050882586..82684bd43e 100644 --- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java @@ -1747,20 +1747,20 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { stackParams.put (VLANS, csl); } if (routeTargets != null && !routeTargets.isEmpty()) { - StringBuilder buf = new StringBuilder (); + StringBuilder sb = new StringBuilder (); String sep = ""; for (String rt : routeTargets) { if (!isNullOrEmpty(rt)) { if (aic3template) - buf.append (sep).append ("target:" + rt); + sb.append(sep).append("target:").append(rt); else - buf.append (sep).append (rt); + sb.append (sep).append (rt); sep = ","; } } - String csl = buf.toString (); + String csl = sb.toString (); stackParams.put ("route_targets", csl); } diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java index b8a5d9b117..95e62a0e2d 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java @@ -508,7 +508,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.debug("Exception :",e); outputString = "Unable to call toString() on the value for " + str; } - sb.append("\t\nitem " + i++ + ": '" + str + "'='" + outputString + "'"); + sb.append("\t\nitem ").append(i++).append(": '").append(str).append("'='").append(outputString) + .append("'"); } } LOGGER.debug(sb.toString()); @@ -524,7 +525,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { sb.append("\tEMPTY"); } else { for (String str : inputs.keySet()) { - sb.append("\titem " + i++ + ": " + str + "=" + inputs.get(str)); + sb.append("\titem ").append(i++).append(": ").append(str).append("=").append(inputs.get(str)); } } LOGGER.debug(sb.toString()); @@ -1224,7 +1225,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { int cntr = 0; try { for (HeatTemplateParam htp : heatTemplate.getParameters()) { - sb.append("param[" + cntr++ + "]=" + htp.getParamName()); + sb.append("param[").append(cntr++).append("]=").append(htp.getParamName()); parameterNames.add(htp.getParamName()); if (htp.getParamAlias() != null && !"".equals(htp.getParamAlias())) { aliasToParam.put(htp.getParamAlias(), htp.getParamName()); @@ -1443,16 +1444,16 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { StringBuilder sbInit = new StringBuilder(); sbInit.append("updateVfModule: \n"); - sbInit.append("cloudSiteId=" + cloudSiteId + "\n"); - sbInit.append("tenantId=" + tenantId + "\n"); - sbInit.append("vnfType=" + vnfType + "\n"); - sbInit.append("vnfVersion=" + vnfVersion + "\n"); - sbInit.append("vnfName=" + vnfName + "\n"); - sbInit.append("requestType=" + requestType + "\n"); - sbInit.append("volumeGroupHeatStackId=" + volumeGroupHeatStackId + "\n"); - sbInit.append("baseVfHeatStackId=" + baseVfHeatStackId + "\n"); - sbInit.append("vfModuleStackId=" + vfModuleStackId + "\n"); - sbInit.append("modelCustomizationUuid=" + modelCustomizationUuid + "\n"); + sbInit.append("cloudSiteId=").append(cloudSiteId).append("\n"); + sbInit.append("tenantId=").append(tenantId).append("\n"); + sbInit.append("vnfType=").append(vnfType).append("\n"); + sbInit.append("vnfVersion=").append(vnfVersion).append("\n"); + sbInit.append("vnfName=").append(vnfName).append("\n"); + sbInit.append("requestType=").append(requestType).append("\n"); + sbInit.append("volumeGroupHeatStackId=").append(volumeGroupHeatStackId).append("\n"); + sbInit.append("baseVfHeatStackId=").append(baseVfHeatStackId).append("\n"); + sbInit.append("vfModuleStackId=").append(vfModuleStackId).append("\n"); + sbInit.append("modelCustomizationUuid=").append(modelCustomizationUuid).append("\n"); LOGGER.debug(sbInit.toString()); String mcu = modelCustomizationUuid; |