From 09d48d1daf3243907dd74fd5d8078d96c1ee5597 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 5 Jul 2021 18:44:48 +0200 Subject: [virtualizer] Get rid of --- src/main/java/org/openslx/virtualization/Version.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/main/java/org/openslx/virtualization/Version.java') diff --git a/src/main/java/org/openslx/virtualization/Version.java b/src/main/java/org/openslx/virtualization/Version.java index 51dc98b..c823324 100644 --- a/src/main/java/org/openslx/virtualization/Version.java +++ b/src/main/java/org/openslx/virtualization/Version.java @@ -5,6 +5,8 @@ import java.util.function.Predicate; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.openslx.util.Util; + /** * Represents a version information. * @@ -28,7 +30,7 @@ public class Version implements Comparable * 5.10.13 * */ - private static final String VERSION_NUMBER_REGEX = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+))?)?$"; + private static final Pattern VERSION_NUMBER_REGEX = Pattern.compile( "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+))?)?$" ); /** * Major number of the version. @@ -236,11 +238,10 @@ public class Version implements Comparable { final Version parsedVersion; - if ( version == null || version.isEmpty() ) { + if ( Util.isEmptyString( version ) ) { parsedVersion = null; } else { - final Pattern versionPattern = Pattern.compile( Version.VERSION_NUMBER_REGEX ); - final Matcher versionMatcher = versionPattern.matcher( version ); + final Matcher versionMatcher = VERSION_NUMBER_REGEX.matcher( version ); if ( versionMatcher.find() ) { final String majorStr = versionMatcher.group( 1 ); @@ -262,7 +263,7 @@ public class Version implements Comparable @Override public String toString() { - if ( this.getName() == null || this.getName().isEmpty() ) { + if ( Util.isEmptyString( this.getName() ) ) { return String.format( "%d.%d", this.getMajor(), this.getMinor() ); } else { return String.format( "%d.%d %s", this.getMajor(), this.getMinor(), this.getName() ); -- cgit v1.2.3-55-g7522