public static int compareVersions(String version1, String version2, boolean allowEmptyVersions) {
    if (allowEmptyVersions) {
      if (version1 != null && version1.equals(DEV_VERSION)) {
        return 0;
      }
      if (version1 == null && version2 == null) {
        return 0;
      } else {
        if (version1 == null) {
          return -1;
        }
        if (version2 == null) {
          return 1;
        }
      }

      if (version1.isEmpty() && version2.isEmpty()) {
        return 0;
      } else {
        if (version1.isEmpty()) {
          return -1;
        }
        if (version2.isEmpty()) {
          return 1;
        }
      }
    }

    return compareVersions(version1, version2, 0);
  }
Compares two versions strings of the form N.N.N.N

@param version1
         the first operand. If set to {@value #DEV_VERSION}
         then this will always return {@code 0)}
@param version2
         the second operand.
@param allowEmptyVersions
         Allow one or both version values to be null or empty string
@return 0 if both are equal up to the length compared, -1 if first one is
        lower, +1 otherwise
ambari-server-spi/src/main/java/org/apache/ambari/server/utils/VersionUtils.java