public static GatewayVersion parseGatewayVersion ( String version ) throws Exception { if ( "develop-SNAPSHOT" . equals ( version ) ) { return new GatewayVersion ( 0 , 0 , 0 ) ; } else { String regex = "(?<major>[0-9]+)\\.(?<minor>[0-9]+)\\.(?<patch>[0-9]+)-?(?<rc>[RC0-9{3}]*)" ; Pattern pattern = Pattern . compile ( regex ) ; Matcher matcher = pattern . matcher ( version ) ; if ( matcher . matches ( ) ) { int major = Integer . parseInt ( matcher . group ( "major" ) ) ; int minor = Integer . parseInt ( matcher . group ( "minor" ) ) ; int patch = Integer . parseInt ( matcher . group ( "patch" ) ) ; String rc = matcher . group ( "rc" ) ; return new GatewayVersion ( major , minor , patch , rc ) ; } else { throw new IllegalArgumentException ( String . format ( "version String is not of form %s" , regex ) ) ; } } }
Parses a GatewayVersion from a String