* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.setup;
-import org.onap.aai.validation.AAISchemaValidationException;
+package org.onap.aai.setup;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.onap.aai.validation.AAISchemaValidationException;
+
public class SchemaVersion implements Comparable<SchemaVersion> {
public static final Pattern VERSION_PATTERN = Pattern.compile("v([1-9][0-9]*)");
private final Integer value;
- public SchemaVersion(String value){
+ public SchemaVersion(String value) {
Matcher matcher = VERSION_PATTERN.matcher(value);
- if(!matcher.find()){
- throw new AAISchemaValidationException("Invalid Schema Version " + value + ", value doesn't match the expected regex: " + VERSION_PATTERN);
+ if (!matcher.find()) {
+ throw new AAISchemaValidationException(
+ "Invalid Schema Version " + value + ", value doesn't match the expected regex: " + VERSION_PATTERN);
} else {
this.value = Integer.parseInt(matcher.group(1));
}
}
@Override
- public int hashCode(){
+ public int hashCode() {
return value.hashCode();
}
@Override
- public boolean equals(Object other){
+ public boolean equals(Object other) {
- if(this == other){
+ if (this == other) {
return true;
}
- if(other == null){
+ if (other == null) {
return false;
}
- if(!(other instanceof SchemaVersion)){
+ if (!(other instanceof SchemaVersion)) {
return false;
}
- SchemaVersion obj = (SchemaVersion)other;
+ SchemaVersion obj = (SchemaVersion) other;
return this.value.equals(obj.value);
}
@Override
- public String toString(){
+ public String toString() {
return String.valueOf("v" + value);
}
@Override
public int compareTo(SchemaVersion o) {
- if(o == null){
+ if (o == null) {
return -1;
}