public static Version parse ( String version ) { if ( version == null ) { throw new NullPointerException ( "version is null" ) ; } Version result = new Version ( ) ; String [ ] numbers = version . split ( "." ) ; for ( int i = 0 ; i < numbers . length ; i ++ ) { String parts [ ] = numbers [ i ] . split ( "-" ) ; int number = Integer . parseInt ( parts [ 0 ] ) ; StringBuilder label = new StringBuilder ( ) ; for ( int j = 1 ; j < parts . length ; j ++ ) { if ( ( i < numbers . length - 1 ) && ( j < parts . length - 1 ) ) { label . append ( ' ' ) . append ( parts [ j ] ) ; } else { result . setSnapshot ( parts [ j ] . equalsIgnoreCase ( "SNAPSHOT" ) ) ; } } result . append ( number , label . toString ( ) ) ; } return result ; }
Creates a new version descriptor based on its string presentation .