added `DatabaseVersion#getCanonicalVersion`

This commit is contained in:
Steve Ebersole 2021-12-03 13:27:18 -06:00
parent 43206b02fc
commit d354d49ab1
1 changed files with 13 additions and 0 deletions

View File

@ -38,6 +38,19 @@ public interface DatabaseVersion {
*/
int getDatabaseMinorVersion();
/**
* Get a simple int representing the version based on the formula
* {@code ({major) * 10000}) + (minor * 1000)} where minor == {@link #NO_VERSION}
* is normalized to zero
*/
default int getCanonicalVersion() {
final int major = getDatabaseMajorVersion();
final int minor = getDatabaseMinorVersion() == NO_VERSION
? 0
: getDatabaseMinorVersion();
return ( major * 10000 ) + ( minor * 1000 );
}
default boolean isAfter(DatabaseVersion other) {
return isAfter( other.getDatabaseMajorVersion(), other.getDatabaseMinorVersion() );
}