11package eu .europa .ted .eforms .sdk ;
22
33import java .util .ArrayList ;
4+ import java .util .Arrays ;
45import java .util .List ;
56import java .util .Objects ;
67import org .apache .commons .lang3 .StringUtils ;
@@ -24,27 +25,43 @@ public SdkVersion(final String version) {
2425 }
2526
2627 public String getMajor () {
27- return version .getMajor ().toString ();
28+ return this . version .getMajor ().toString ();
2829 }
2930
3031 public String getMinor () {
31- return version .getMinor ().toString ();
32+ return this . version .getMinor ().toString ();
3233 }
3334
3435 public String getPatch () {
35- return version .getPatch () == null ? "0" : version .getPatch ().toString ();
36+ return this . version .getPatch () == null ? "0" : this . version .getPatch ().toString ();
3637 }
3738
3839 public String getNextMajor () {
39- return version .withIncMajor ().toString ();
40+ return this . version .withIncMajor ().toString ();
4041 }
4142
4243 public String getNextMinor () {
43- return version .withIncMinor ().toString ();
44+ return this .version .withIncMinor ().toString ();
45+ }
46+
47+ public boolean isMajor () {
48+ return !this .isMinor () && this .version .getMajor () != null ;
49+ }
50+
51+ public boolean isMinor () {
52+ return !this .isPatch () && this .version .getMinor () != null ;
4453 }
4554
4655 public boolean isPatch () {
47- return version .getPatch () != null ;
56+ return this .version .getPatch () != null ;
57+ }
58+
59+ public boolean isPreRelease () {
60+ return this .version .getSuffixTokens ().length > 0 ;
61+ }
62+
63+ public boolean isSnapshot () {
64+ return Arrays .asList (this .version .getSuffixTokens ()).contains ("SNAPSHOT" );
4865 }
4966
5067 public String toNormalisedString (boolean withPatch ) {
@@ -66,7 +83,7 @@ public String toStringWithoutPatch() {
6683
6784 @ Override
6885 public String toString () {
69- return version .toString ();
86+ return this . version .toString ();
7087 }
7188
7289 @ Override
@@ -79,12 +96,12 @@ public int compareTo(SdkVersion that) {
7996 return 0 ;
8097 }
8198
82- return version .compareTo (that .version );
99+ return this . version .compareTo (that .version );
83100 }
84101
85102 @ Override
86103 public int hashCode () {
87- return Objects .hash (version );
104+ return Objects .hash (this . version );
88105 }
89106
90107 @ Override
@@ -96,6 +113,6 @@ public boolean equals(Object obj) {
96113 if (getClass () != obj .getClass ())
97114 return false ;
98115 SdkVersion other = (SdkVersion ) obj ;
99- return Objects .equals (version , other .version );
116+ return Objects .equals (this . version , other .version );
100117 }
101118}
0 commit comments