-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Versions to org.verapdf.version (#1281)
- Loading branch information
1 parent
5135e13
commit 2eb8d16
Showing
4 changed files
with
75 additions
and
20 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...va/org/verapdf/SemanticVersionNumber.java → ...erapdf/version/SemanticVersionNumber.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...n/java/org/verapdf/VersionNumberImpl.java → ...rg/verapdf/version/VersionNumberImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/** | ||
* | ||
*/ | ||
package org.verapdf; | ||
package org.verapdf.version; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Carl Wilson</a> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* | ||
*/ | ||
package org.verapdf.version; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Carl Wilson</a> | ||
* <a href="https://github.com/carlwilson">carlwilson AT github</a> | ||
* | ||
* @version 0.1 | ||
* | ||
* Created 26 May 2017:01:48:14 | ||
*/ | ||
|
||
public final class Versions { | ||
public static final String PDFBOX_BUILD_INFO = "PDFBOX"; //$NON-NLS-1$ | ||
private static final String pdfBoxBuildInfo = "-" + PDFBOX_BUILD_INFO; //$NON-NLS-1$ | ||
private static final String snapshotBuildInfo = "-SNAPSHOT"; //$NON-NLS-1$ | ||
private static final String versionPrefix = "v"; //$NON-NLS-1$ | ||
|
||
/** | ||
* | ||
*/ | ||
private Versions() { | ||
throw new AssertionError("Should never be here"); //$NON-NLS-1$ | ||
} | ||
|
||
public static SemanticVersionNumber fromString(final String versionString) { | ||
if (versionString == null) | ||
throw new IllegalArgumentException("Argument versionString can not be null"); //$NON-NLS-1$ | ||
if (versionString.isEmpty()) | ||
throw new IllegalArgumentException("Argument versionString can not be empty"); //$NON-NLS-1$ | ||
String strippedVersion = (versionString.endsWith(pdfBoxBuildInfo)) ? versionString.replace(pdfBoxBuildInfo, "") //$NON-NLS-1$ | ||
: versionString; | ||
strippedVersion = (strippedVersion.endsWith(snapshotBuildInfo)) ? strippedVersion.replace(snapshotBuildInfo, "") //$NON-NLS-1$ | ||
: strippedVersion; | ||
strippedVersion = strippedVersion.startsWith(versionPrefix) ? strippedVersion.replaceFirst(versionPrefix, "") //$NON-NLS-1$ | ||
: strippedVersion; | ||
return VersionNumberImpl.fromString(strippedVersion); | ||
} | ||
|
||
public static SemanticVersionNumber fromStrings(final String[] parts) { | ||
return VersionNumberImpl.fromStrings(parts); | ||
} | ||
|
||
public static SemanticVersionNumber fromInts(final int[] parts) { | ||
return VersionNumberImpl.fromInts(parts); | ||
} | ||
|
||
public static SemanticVersionNumber fromInts(final int major, final int minor, final int revision) { | ||
return VersionNumberImpl.fromInts(major, minor, revision); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters