Created
September 20, 2012 14:17
-
-
Save gastaldi/3756211 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| /** | |
| * This method only returns true if: | |
| * | |
| * The major version of pluginApiVersion is equal to the major version of runtimeVersion AND | |
| * | |
| * The minor version of pluginApiVersion is less or equal to the minor version of runtimeVersion | |
| * | |
| * @param runtimeVersion a version in the format x.x.x | |
| * @param pluginApiVersion a version in the format x.x.x | |
| * @return | |
| */ | |
| public static boolean isApiCompatible(CharSequence runtimeVersion, String pluginApiVersion) | |
| { | |
| Matcher runtimeMatcher = VERSION_PATTERN.matcher(runtimeVersion); | |
| if (runtimeMatcher.matches()) | |
| { | |
| int runtimeMajorVersion = Integer.parseInt(runtimeMatcher.group(1)); | |
| int runtimeMinorVersion = Integer.parseInt(runtimeMatcher.group(2)); | |
| Matcher pluginApiMatcher = VERSION_PATTERN.matcher(pluginApiVersion); | |
| if (pluginApiMatcher.matches()) | |
| { | |
| int pluginApiMajorVersion = Integer.parseInt(pluginApiMatcher.group(1)); | |
| int pluginApiMinorVersion = Integer.parseInt(pluginApiMatcher.group(2)); | |
| if (pluginApiMajorVersion == runtimeMajorVersion && pluginApiMinorVersion <= runtimeMinorVersion) | |
| { | |
| return true; | |
| } | |
| } | |
| } | |
| return false; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment