@Test public void testAppendQualifierSuffix() { assertThat( Version.appendQualifierSuffix( "1.0", "foo" ), equalTo( "1.0.foo") ); assertThat( Version.appendQualifierSuffix( "1.0.0.Beta1", "foo" ), equalTo( "1.0.0.Beta1-foo") ); assertThat( Version.appendQualifierSuffix( "1.0_Betafoo", "foo" ), equalTo( "1.0_Betafoo") ); assertThat( Version.appendQualifierSuffix( "1.0_fooBeta", "foo" ), equalTo( "1.0_fooBeta-foo") ); assertThat( Version.appendQualifierSuffix( "1.0", "-foo" ), equalTo( "1.0-foo") ); assertThat( Version.appendQualifierSuffix( "1.0.0.Beta1", "_foo" ), equalTo( "1.0.0.Beta1_foo") ); assertThat( Version.appendQualifierSuffix( "1.0_Betafoo", "-foo" ), equalTo( "1.0_Beta-foo") ); assertThat( Version.appendQualifierSuffix( "1.0_Beta.foo", "-foo" ), equalTo( "1.0_Beta-foo") ); assertThat( Version.appendQualifierSuffix( "jboss-1-GA", "jboss" ), equalTo( "jboss-1-GA-jboss") ); assertThat( Version.appendQualifierSuffix( "1.2", "jboss-1-SNAPSHOT" ), equalTo( "1.2.jboss-1-SNAPSHOT") ); assertThat( Version.appendQualifierSuffix( "1.2-SNAPSHOT", "jboss1" ), equalTo( "1.2.jboss1-SNAPSHOT") ); assertThat( Version.appendQualifierSuffix( "1.2-jboss-1", "jboss-2" ), equalTo( "1.2-jboss-2") ); assertThat( Version.appendQualifierSuffix( "1.2-jboss-1", ".jboss-2" ), equalTo( "1.2.jboss-2") ); assertThat( Version.appendQualifierSuffix( "1.1-SNAPSHOT", ".test_jdk7-SNAPSHOT" ), equalTo( "1.1.test_jdk7-SNAPSHOT") ); assertThat( Version.appendQualifierSuffix( "1.1.beta-2", "-beta-1" ), equalTo( "1.1-beta-1") ); assertThat( Version.appendQualifierSuffix( "1.1.beta-2", "-foo-1" ), equalTo( "1.1.beta-2-foo-1") ); }
public static String appendQualifierSuffix( final String version, final String suffix ) { logger.debug( "Applying suffix: " + suffix + " to version " + version ); if ( isEmpty( suffix ) ) { return version; } if ( isEmpty( getQualifier( version ) ) ) { return version + prependDelimiter( suffix, DEFAULT_DELIMITER); } Matcher suffixMatcher = createSuffixMatcher( version, suffix ); if ( suffixMatcher.matches() ) { return version; } final String suffixWoSnapshot = removeSnapshot( suffix ); final String suffixBuildNumber = getBuildNumber( suffix ); final String suffixWoBuildNumber = removeBuildNumber( suffixWoSnapshot ); final String suffixWoBuildNumDelim = removeLeadingDelimiter( suffixWoBuildNumber ); Matcher suffixWoDelimMatcher = createSuffixMatcher( version, suffixWoBuildNumDelim ); if (suffixWoDelimMatcher.matches()) { String newVersion = suffixWoDelimMatcher.replaceFirst("$1$2" + suffixWoBuildNumber + "$4$7"); if ( hasLeadingDelimiter( suffix ) ) { newVersion = suffixWoDelimMatcher.replaceFirst("$1" + suffixWoBuildNumber + "$4$7"); } if ( !isEmpty( suffixBuildNumber ) ) { newVersion = setBuildNumber( newVersion, suffixBuildNumber ); } if ( isSnapshot( suffix ) ) { newVersion = setSnapshot( newVersion, true ); } return newVersion; } Matcher qualifierMatcher = qualifierPattern.matcher( version ); if ( qualifierMatcher.matches() ) { if ( hasLeadingDelimiter( suffixWoSnapshot ) ) { String newVersion = qualifierMatcher.replaceFirst( "$1$3$4" + suffixWoSnapshot + "$5"); if ( isSnapshot( suffix ) ) { newVersion = Version.setSnapshot( newVersion, true ); } return newVersion; } String delimiter = DEFAULT_QUALIFIER_DELIMITER; if ( isEmpty( getQualifierBase( version ) ) ) { delimiter = DEFAULT_DELIMITER; } String newVersion = qualifierMatcher.replaceFirst( "$1$3$4" + delimiter + suffixWoSnapshot + "$5"); if ( isSnapshot( suffix ) ) { newVersion = Version.setSnapshot( newVersion, true ); } return newVersion; } return version; }
Version { public static String appendQualifierSuffix( final String version, final String suffix ) { logger.debug( "Applying suffix: " + suffix + " to version " + version ); if ( isEmpty( suffix ) ) { return version; } if ( isEmpty( getQualifier( version ) ) ) { return version + prependDelimiter( suffix, DEFAULT_DELIMITER); } Matcher suffixMatcher = createSuffixMatcher( version, suffix ); if ( suffixMatcher.matches() ) { return version; } final String suffixWoSnapshot = removeSnapshot( suffix ); final String suffixBuildNumber = getBuildNumber( suffix ); final String suffixWoBuildNumber = removeBuildNumber( suffixWoSnapshot ); final String suffixWoBuildNumDelim = removeLeadingDelimiter( suffixWoBuildNumber ); Matcher suffixWoDelimMatcher = createSuffixMatcher( version, suffixWoBuildNumDelim ); if (suffixWoDelimMatcher.matches()) { String newVersion = suffixWoDelimMatcher.replaceFirst("$1$2" + suffixWoBuildNumber + "$4$7"); if ( hasLeadingDelimiter( suffix ) ) { newVersion = suffixWoDelimMatcher.replaceFirst("$1" + suffixWoBuildNumber + "$4$7"); } if ( !isEmpty( suffixBuildNumber ) ) { newVersion = setBuildNumber( newVersion, suffixBuildNumber ); } if ( isSnapshot( suffix ) ) { newVersion = setSnapshot( newVersion, true ); } return newVersion; } Matcher qualifierMatcher = qualifierPattern.matcher( version ); if ( qualifierMatcher.matches() ) { if ( hasLeadingDelimiter( suffixWoSnapshot ) ) { String newVersion = qualifierMatcher.replaceFirst( "$1$3$4" + suffixWoSnapshot + "$5"); if ( isSnapshot( suffix ) ) { newVersion = Version.setSnapshot( newVersion, true ); } return newVersion; } String delimiter = DEFAULT_QUALIFIER_DELIMITER; if ( isEmpty( getQualifierBase( version ) ) ) { delimiter = DEFAULT_DELIMITER; } String newVersion = qualifierMatcher.replaceFirst( "$1$3$4" + delimiter + suffixWoSnapshot + "$5"); if ( isSnapshot( suffix ) ) { newVersion = Version.setSnapshot( newVersion, true ); } return newVersion; } return version; } }
Version { public static String appendQualifierSuffix( final String version, final String suffix ) { logger.debug( "Applying suffix: " + suffix + " to version " + version ); if ( isEmpty( suffix ) ) { return version; } if ( isEmpty( getQualifier( version ) ) ) { return version + prependDelimiter( suffix, DEFAULT_DELIMITER); } Matcher suffixMatcher = createSuffixMatcher( version, suffix ); if ( suffixMatcher.matches() ) { return version; } final String suffixWoSnapshot = removeSnapshot( suffix ); final String suffixBuildNumber = getBuildNumber( suffix ); final String suffixWoBuildNumber = removeBuildNumber( suffixWoSnapshot ); final String suffixWoBuildNumDelim = removeLeadingDelimiter( suffixWoBuildNumber ); Matcher suffixWoDelimMatcher = createSuffixMatcher( version, suffixWoBuildNumDelim ); if (suffixWoDelimMatcher.matches()) { String newVersion = suffixWoDelimMatcher.replaceFirst("$1$2" + suffixWoBuildNumber + "$4$7"); if ( hasLeadingDelimiter( suffix ) ) { newVersion = suffixWoDelimMatcher.replaceFirst("$1" + suffixWoBuildNumber + "$4$7"); } if ( !isEmpty( suffixBuildNumber ) ) { newVersion = setBuildNumber( newVersion, suffixBuildNumber ); } if ( isSnapshot( suffix ) ) { newVersion = setSnapshot( newVersion, true ); } return newVersion; } Matcher qualifierMatcher = qualifierPattern.matcher( version ); if ( qualifierMatcher.matches() ) { if ( hasLeadingDelimiter( suffixWoSnapshot ) ) { String newVersion = qualifierMatcher.replaceFirst( "$1$3$4" + suffixWoSnapshot + "$5"); if ( isSnapshot( suffix ) ) { newVersion = Version.setSnapshot( newVersion, true ); } return newVersion; } String delimiter = DEFAULT_QUALIFIER_DELIMITER; if ( isEmpty( getQualifierBase( version ) ) ) { delimiter = DEFAULT_DELIMITER; } String newVersion = qualifierMatcher.replaceFirst( "$1$3$4" + delimiter + suffixWoSnapshot + "$5"); if ( isSnapshot( suffix ) ) { newVersion = Version.setSnapshot( newVersion, true ); } return newVersion; } return version; } private  Version(); }
Version { public static String appendQualifierSuffix( final String version, final String suffix ) { logger.debug( "Applying suffix: " + suffix + " to version " + version ); if ( isEmpty( suffix ) ) { return version; } if ( isEmpty( getQualifier( version ) ) ) { return version + prependDelimiter( suffix, DEFAULT_DELIMITER); } Matcher suffixMatcher = createSuffixMatcher( version, suffix ); if ( suffixMatcher.matches() ) { return version; } final String suffixWoSnapshot = removeSnapshot( suffix ); final String suffixBuildNumber = getBuildNumber( suffix ); final String suffixWoBuildNumber = removeBuildNumber( suffixWoSnapshot ); final String suffixWoBuildNumDelim = removeLeadingDelimiter( suffixWoBuildNumber ); Matcher suffixWoDelimMatcher = createSuffixMatcher( version, suffixWoBuildNumDelim ); if (suffixWoDelimMatcher.matches()) { String newVersion = suffixWoDelimMatcher.replaceFirst("$1$2" + suffixWoBuildNumber + "$4$7"); if ( hasLeadingDelimiter( suffix ) ) { newVersion = suffixWoDelimMatcher.replaceFirst("$1" + suffixWoBuildNumber + "$4$7"); } if ( !isEmpty( suffixBuildNumber ) ) { newVersion = setBuildNumber( newVersion, suffixBuildNumber ); } if ( isSnapshot( suffix ) ) { newVersion = setSnapshot( newVersion, true ); } return newVersion; } Matcher qualifierMatcher = qualifierPattern.matcher( version ); if ( qualifierMatcher.matches() ) { if ( hasLeadingDelimiter( suffixWoSnapshot ) ) { String newVersion = qualifierMatcher.replaceFirst( "$1$3$4" + suffixWoSnapshot + "$5"); if ( isSnapshot( suffix ) ) { newVersion = Version.setSnapshot( newVersion, true ); } return newVersion; } String delimiter = DEFAULT_QUALIFIER_DELIMITER; if ( isEmpty( getQualifierBase( version ) ) ) { delimiter = DEFAULT_DELIMITER; } String newVersion = qualifierMatcher.replaceFirst( "$1$3$4" + delimiter + suffixWoSnapshot + "$5"); if ( isSnapshot( suffix ) ) { newVersion = Version.setSnapshot( newVersion, true ); } return newVersion; } return version; } private  Version(); static String getBuildNumber(String version); static int getBuildNumberPadding( int incrementalSerialSuffixPadding, Set<String> versions ); static String getMMM(String version); static String getOsgiVersion(String version); static String getQualifier(String version); static String getQualifierBase(String version); static String getQualifierWithDelim(String version); static String getSnapshot( String version ); static String getSnapshotWithDelim( String version ); static boolean hasBuildNumber( String version ); static boolean hasQualifier( String version ); static boolean isEmpty( String string ); static boolean isSnapshot( String version ); static boolean isValidOSGi(String version); static String removeBuildNumber( String version ); static String removeSnapshot( String version ); static String appendQualifierSuffix( final String version, final String suffix ); static String setBuildNumber( String version, String buildNumber ); static String setSnapshot( String version, boolean snapshot ); static int findHighestMatchingBuildNumber(String version, Set<String> versionSet ); static int getIntegerBuildNumber( String version ); }
Version { public static String appendQualifierSuffix( final String version, final String suffix ) { logger.debug( "Applying suffix: " + suffix + " to version " + version ); if ( isEmpty( suffix ) ) { return version; } if ( isEmpty( getQualifier( version ) ) ) { return version + prependDelimiter( suffix, DEFAULT_DELIMITER); } Matcher suffixMatcher = createSuffixMatcher( version, suffix ); if ( suffixMatcher.matches() ) { return version; } final String suffixWoSnapshot = removeSnapshot( suffix ); final String suffixBuildNumber = getBuildNumber( suffix ); final String suffixWoBuildNumber = removeBuildNumber( suffixWoSnapshot ); final String suffixWoBuildNumDelim = removeLeadingDelimiter( suffixWoBuildNumber ); Matcher suffixWoDelimMatcher = createSuffixMatcher( version, suffixWoBuildNumDelim ); if (suffixWoDelimMatcher.matches()) { String newVersion = suffixWoDelimMatcher.replaceFirst("$1$2" + suffixWoBuildNumber + "$4$7"); if ( hasLeadingDelimiter( suffix ) ) { newVersion = suffixWoDelimMatcher.replaceFirst("$1" + suffixWoBuildNumber + "$4$7"); } if ( !isEmpty( suffixBuildNumber ) ) { newVersion = setBuildNumber( newVersion, suffixBuildNumber ); } if ( isSnapshot( suffix ) ) { newVersion = setSnapshot( newVersion, true ); } return newVersion; } Matcher qualifierMatcher = qualifierPattern.matcher( version ); if ( qualifierMatcher.matches() ) { if ( hasLeadingDelimiter( suffixWoSnapshot ) ) { String newVersion = qualifierMatcher.replaceFirst( "$1$3$4" + suffixWoSnapshot + "$5"); if ( isSnapshot( suffix ) ) { newVersion = Version.setSnapshot( newVersion, true ); } return newVersion; } String delimiter = DEFAULT_QUALIFIER_DELIMITER; if ( isEmpty( getQualifierBase( version ) ) ) { delimiter = DEFAULT_DELIMITER; } String newVersion = qualifierMatcher.replaceFirst( "$1$3$4" + delimiter + suffixWoSnapshot + "$5"); if ( isSnapshot( suffix ) ) { newVersion = Version.setSnapshot( newVersion, true ); } return newVersion; } return version; } private  Version(); static String getBuildNumber(String version); static int getBuildNumberPadding( int incrementalSerialSuffixPadding, Set<String> versions ); static String getMMM(String version); static String getOsgiVersion(String version); static String getQualifier(String version); static String getQualifierBase(String version); static String getQualifierWithDelim(String version); static String getSnapshot( String version ); static String getSnapshotWithDelim( String version ); static boolean hasBuildNumber( String version ); static boolean hasQualifier( String version ); static boolean isEmpty( String string ); static boolean isSnapshot( String version ); static boolean isValidOSGi(String version); static String removeBuildNumber( String version ); static String removeSnapshot( String version ); static String appendQualifierSuffix( final String version, final String suffix ); static String setBuildNumber( String version, String buildNumber ); static String setSnapshot( String version, boolean snapshot ); static int findHighestMatchingBuildNumber(String version, Set<String> versionSet ); static int getIntegerBuildNumber( String version ); static final String PROJECT_VERSION; }