aboutsummaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/main/java/org
diff options
context:
space:
mode:
authorMunir Ahmad <munir.ahmad@bell.ca>2018-02-24 12:44:49 -0500
committerMunir Ahmad <munir.ahmad@bell.ca>2018-02-26 19:15:52 -0500
commit76455ea6b8dfcae239c2929e02c3eba0cca4cbe9 (patch)
treedec68785264efce1917bd9c58b0f0d7326348ec7 /mso-catalog-db/src/main/java/org
parente35347d6521133807e92f397820fa18a5412aee7 (diff)
Simplify if statements where it makes sense
Change-Id: Id04ede6b8aa8fa3ca8c02b8c32ad5f4745ef47f4 Issue-ID: SO-437 Signed-off-by: Munir Ahmad <munir.ahmad@bell.ca>
Diffstat (limited to 'mso-catalog-db/src/main/java/org')
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java29
1 files changed, 16 insertions, 13 deletions
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 564fd5a019..e42f734a64 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
@@ -51,29 +51,32 @@ public class MavenLikeVersioning implements Serializable {
*
*/
public boolean isMoreRecentThan (String versionToCompare) {
- if (versionToCompare == null || versionToCompare.trim().equals("") || this.version == null || this.version.trim().equals("")) {
+ if (versionToCompare == null || versionToCompare.trim().isEmpty() || this.version == null || this.version.trim().isEmpty()) {
return false;
}
- String [] currentVersionArray = this.version.split("\\.");
- String [] specifiedVersionArray = versionToCompare.split("\\.");
+ String[] currentVersionArray = this.version.split("\\.");
+ String[] specifiedVersionArray = versionToCompare.split("\\.");
- int smalestStringLength = Math.min(currentVersionArray.length, specifiedVersionArray.length);
+ int smalestStringLength = Math.min(currentVersionArray.length, specifiedVersionArray.length);
- for (int currentVersionIndex=0;currentVersionIndex < smalestStringLength;++currentVersionIndex) {
+ for (int currentVersionIndex = 0; currentVersionIndex < smalestStringLength; ++currentVersionIndex) {
- if (Integer.parseInt(currentVersionArray[currentVersionIndex]) < Integer.parseInt(specifiedVersionArray[currentVersionIndex])) {
+ if (Integer.parseInt(currentVersionArray[currentVersionIndex]) < Integer
+ .parseInt(specifiedVersionArray[currentVersionIndex])) {
return false;
- } else if (Integer.parseInt(currentVersionArray[currentVersionIndex]) > Integer.parseInt(specifiedVersionArray[currentVersionIndex])) {
+ } 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.parseInt(currentVersionArray[smalestStringLength-1]) == Integer.parseInt(specifiedVersionArray[smalestStringLength-1])) {
- return currentVersionArray.length > specifiedVersionArray.length;
+ try {
+ // Even if versionToCompare has more digits, it means versionToCompare is more recent
+ return Integer.parseInt(currentVersionArray[smalestStringLength - 1]) != Integer
+ .parseInt(specifiedVersionArray[smalestStringLength - 1])
+ || currentVersionArray.length > specifiedVersionArray.length;
+ } catch (NumberFormatException e) {
+ return false;
}
-
- return true;
}
/**