X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Frserv%2FVersion.java;h=c2ffea6b25e0fcf895dc6048b4fe5db5b03fd77b;hb=82755753f41112e1cdd91b2994620ad074dfbf20;hp=ce0981fe6cfd1dbba9d70e387df83f0580a0442b;hpb=71037c39a37d3549dcfe31926832a657744fbe05;p=aaf%2Fauthz.git diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Version.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Version.java index ce0981fe..c2ffea6b 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Version.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Version.java @@ -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. @@ -24,70 +24,70 @@ package org.onap.aaf.auth.rserv; /** * Analyze and hold Version information for Code - * + * * @author Jonathan * */ public class Version { - private Object[] parts; + private Object[] parts; + + public Version(String v) { + String[] sparts = v.split("\\."); + parts = new Object[sparts.length]; + System.arraycopy(sparts, 0, parts, 0, sparts.length); + if (parts.length>1) { // has at least a minor + try { + parts[1]=Integer.decode(sparts[1]); // minor elements need to be converted to Integer for comparison + } catch (NumberFormatException e) { + // it's ok, leave it as a string + parts[1]=sparts[1]; // This useless piece of code forced by Sonar which calls empty Exceptions "Blockers". + } + } + } + + public boolean equals(Object obj) { + if (obj instanceof Version) { + Version ver = (Version)obj; + int length = Math.min(parts.length, ver.parts.length); + for (int i=0;i1) { // has at least a minor - try { - parts[1]=Integer.decode(sparts[1]); // minor elements need to be converted to Integer for comparison - } catch (NumberFormatException e) { - // it's ok, leave it as a string - parts[1]=sparts[1]; // This useless piece of code forced by Sonar which calls empty Exceptions "Blockers". - } - } - } - public boolean equals(Object obj) { - if(obj instanceof Version) { - Version ver = (Version)obj; - int length = Math.min(parts.length, ver.parts.length); - for(int i=0;i