Reformat catalog-model
[sdc.git] / catalog-model / src / main / java / org / openecomp / sdc / be / model / tosca / version / Version.java
index 0b71f03..e6bf32e 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,9 +17,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-
 package org.openecomp.sdc.be.model.tosca.version;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -44,26 +42,30 @@ import java.util.regex.Pattern;
 
 /**
  * Default implementation of artifact versioning.
- * 
+ *
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  */
 public class Version implements Comparable<Version> {
-    private Integer majorVersion;
 
+    private Integer majorVersion;
     private Integer minorVersion;
-
     private Integer incrementalVersion;
-
     private Integer buildNumber;
-
     private String qualifier;
-
     private ComparableVersion comparable;
 
     public Version(String version) {
         parseVersion(version);
     }
 
+    private static Integer getNextIntegerToken(StringTokenizer tok) {
+        String s = tok.nextToken();
+        if ((s.length() > 1) && s.startsWith("0")) {
+            throw new NumberFormatException("Number part has a leading 0: '" + s + "'");
+        }
+        return Integer.valueOf(s);
+    }
+
     @Override
     public int hashCode() {
         return 11 + comparable.hashCode();
@@ -74,11 +76,9 @@ public class Version implements Comparable<Version> {
         if (this == other) {
             return true;
         }
-
         if (!(other instanceof Version)) {
             return false;
         }
-
         return compareTo((Version) other) == 0;
     }
 
@@ -108,19 +108,15 @@ public class Version implements Comparable<Version> {
 
     public final void parseVersion(String version) {
         comparable = new ComparableVersion(version);
-
         int index = version.indexOf("-");
-
         String part1;
         String part2 = null;
-
         if (index < 0) {
             part1 = version;
         } else {
             part1 = version.substring(0, index);
             part2 = version.substring(index + 1);
         }
-
         if (part2 != null) {
             try {
                 if ((part2.length() == 1) || !part2.startsWith("0")) {
@@ -132,7 +128,6 @@ public class Version implements Comparable<Version> {
                 qualifier = part2;
             }
         }
-
         if ((!part1.contains(".")) && !part1.startsWith("0")) {
             try {
                 majorVersion = Integer.valueOf(part1);
@@ -143,7 +138,6 @@ public class Version implements Comparable<Version> {
             }
         } else {
             boolean fallback = false;
-
             StringTokenizer tok = new StringTokenizer(part1, ".");
             try {
                 majorVersion = getNextIntegerToken(tok);
@@ -157,7 +151,6 @@ public class Version implements Comparable<Version> {
                     qualifier = tok.nextToken();
                     fallback = Pattern.compile("\\d+").matcher(qualifier).matches();
                 }
-
                 // string tokenzier won't detect these and ignores them
                 if (part1.contains("..") || part1.startsWith(".") || part1.endsWith(".")) {
                     fallback = true;
@@ -165,7 +158,6 @@ public class Version implements Comparable<Version> {
             } catch (NumberFormatException e) {
                 fallback = true;
             }
-
             if (fallback) {
                 // qualifier is the whole version, including "-"
                 qualifier = version;
@@ -177,14 +169,6 @@ public class Version implements Comparable<Version> {
         }
     }
 
-    private static Integer getNextIntegerToken(StringTokenizer tok) {
-        String s = tok.nextToken();
-        if ((s.length() > 1) && s.startsWith("0")) {
-            throw new NumberFormatException("Number part has a leading 0: '" + s + "'");
-        }
-        return Integer.valueOf(s);
-    }
-
     @Override
     public String toString() {
         return comparable.toString();