From 3c89e8669fb479622a285247cf81358dbdfb4359 Mon Sep 17 00:00:00 2001 From: Gary Wu Date: Mon, 10 Apr 2017 13:28:02 -0700 Subject: Remove boxed types in MavenLikeVersioning Remove the unnecessary use of boxed types in MavenLikeVersioning. Change-Id: I8b96db9e753f80860b95b84473bb8d2b61e2328e Signed-off-by: Gary Wu --- .../mso/db/catalog/utils/MavenLikeVersioning.java | 44 +++++++++------------- 1 file changed, 17 insertions(+), 27 deletions(-) (limited to 'mso-catalog-db/src/main/java/org/openecomp/mso') diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java index 73a9f8eb00..df1a1cb758 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java @@ -50,40 +50,30 @@ public class MavenLikeVersioning implements Serializable { * @return True if the current object is more recent than the specified version, False otherwise * */ - public Boolean isMoreRecentThan (String versionToCompare) { + public boolean isMoreRecentThan (String versionToCompare) { if (versionToCompare == null || this.version == null) { - return Boolean.FALSE; + return false; } String [] currentVersionArray = this.version.split("\\."); String [] specifiedVersionArray = versionToCompare.split("\\."); - int smalestStringLength = 0; - - if (currentVersionArray.length > specifiedVersionArray.length) { - smalestStringLength = specifiedVersionArray.length; - } else { - smalestStringLength = currentVersionArray.length; - } + int smalestStringLength = Math.min(currentVersionArray.length, specifiedVersionArray.length); for (int currentVersionIndex=0;currentVersionIndex < smalestStringLength;++currentVersionIndex) { - if (Integer.valueOf(currentVersionArray[currentVersionIndex]) < Integer.valueOf(specifiedVersionArray[currentVersionIndex])) { - return Boolean.FALSE; - } else if (Integer.valueOf(currentVersionArray[currentVersionIndex]) > Integer.valueOf(specifiedVersionArray[currentVersionIndex])) { - return Boolean.TRUE; + if (Integer.parseInt(currentVersionArray[currentVersionIndex]) < Integer.parseInt(specifiedVersionArray[currentVersionIndex])) { + return false; + } else if (Integer.parseInt(currentVersionArray[currentVersionIndex]) > Integer.parseInt(specifiedVersionArray[currentVersionIndex])) { + return true; } } // Even if versionToCompare has more digits, it means versionToCompare is more recent - if (Integer.valueOf(currentVersionArray[smalestStringLength-1]).intValue () == Integer.valueOf(specifiedVersionArray[smalestStringLength-1]).intValue ()) { - if (currentVersionArray.length > specifiedVersionArray.length) { - return Boolean.TRUE; - } else { - return Boolean.FALSE; - } + if (Integer.parseInt(currentVersionArray[smalestStringLength-1]) == Integer.parseInt(specifiedVersionArray[smalestStringLength-1])) { + return currentVersionArray.length > specifiedVersionArray.length; } - return Boolean.TRUE; + return true; } /** @@ -94,26 +84,26 @@ public class MavenLikeVersioning implements Serializable { * @return True if the current object is equal to the specified version, False otherwise * */ - public Boolean isTheSameVersion (String versionToCompare) { + public boolean isTheSameVersion (String versionToCompare) { if (versionToCompare == null && this.version == null) { - return Boolean.TRUE; + return true; } else if (versionToCompare == null || this.version == null) { - return Boolean.FALSE; + return false; } String [] currentVersionArray = this.version.split("\\."); String [] specifiedVersionArray = versionToCompare.split("\\."); if (currentVersionArray.length != specifiedVersionArray.length) { - return Boolean.FALSE; + return false; } for (int currentVersionIndex=0;currentVersionIndex < currentVersionArray.length;++currentVersionIndex) { - if (Integer.valueOf(currentVersionArray[currentVersionIndex]).intValue () != Integer.valueOf(specifiedVersionArray[currentVersionIndex]).intValue ()) { - return Boolean.FALSE; + if (Integer.parseInt(currentVersionArray[currentVersionIndex]) != Integer.parseInt(specifiedVersionArray[currentVersionIndex])) { + return false; } } - return Boolean.TRUE; + return true; } } -- cgit 1.2.3-korg