private static Matcher validateStackVersion(String version) {
    if (StringUtils.isEmpty(version)) {
      throw new IllegalArgumentException("Stack version can't be empty or null");
    }

    String stackVersion = StringUtils.trim(version);

    Matcher versionMatcher = PATTERN_LEGACY_STACK_VERSION.matcher(stackVersion);
    if (!versionMatcher.find()) {
      throw new IllegalArgumentException("Wrong format for stack version, should be N.N.N.N-N or N.N.N-hN-bN");
    }

    return versionMatcher;
  }
Method validate stack version not to be
empty or null. Also check if passed version
has valid format.
@param version string
@return Matcher for passed version
@throws IllegalArgumentException() if version empty/null/not valid
ambari-server/src/main/java/org/apache/ambari/server/utils/MpackVersion.java