public static MpackVersion parse(String mpackVersion, boolean strict) {

    if(!strict) {
      mpackVersion = format(mpackVersion);
    }
    Matcher versionMatcher = validateMpackVersion(mpackVersion);
    if (versionMatcher.pattern().pattern().equals(VERSION_WITH_BUILD_PATTERN)) {
      return new MpackVersion(Integer.parseInt(versionMatcher.group(1)), Integer.parseInt(versionMatcher.group(2)),
              Integer.parseInt(versionMatcher.group(3)), 0, Integer.parseInt(versionMatcher.group(4)));
    } else if (versionMatcher.pattern().pattern().equals(VERSION_WITH_HOTFIX_AND_BUILD_PATTERN)) {
      return new MpackVersion(Integer.parseInt(versionMatcher.group(1)), Integer.parseInt(versionMatcher.group(2)),
              Integer.parseInt(versionMatcher.group(3)), Integer.parseInt(versionMatcher.group(4)), Integer.parseInt(versionMatcher.group(5)));
    } else {
      throw new IllegalArgumentException("Wrong format for mpack version");
    }
  }
Method which will parse mpack version
which user passed as parameter. Also
in this method version will be validated.
@param mpackVersion string
@return MpackVersion instance which contains parsed version
ambari-server/src/main/java/org/apache/ambari/server/utils/MpackVersion.java