class KubernetesVersion extends Version {

    public static final VersionFactory<KubernetesVersion> FACTORY = new VersionFactory<KubernetesVersion>() {

      private final Pattern versionPattern = Pattern.compile("v([0-9]+)((alpha|beta)([0-9]+)?)*");

      @Override
      public KubernetesVersion create(String version) {
        if (version == null) {
          return null;
        }
        Matcher matcher = versionPattern.matcher(version);
        if (!matcher.matches()) {
          return null;
        }
        Integer majorValue = getInt(matcher.group(1));
        String qualifierValue = matcher.group(3);
        Integer minorValue = getInt(matcher.group(4));
        return new KubernetesVersion(majorValue, qualifierValue, minorValue, version);
      }

      private Integer getInt(String value) {
        if (value == null) {
          return null;
        }
        try {
          return Integer.parseInt(value);
        } catch (NumberFormatException e) {
          return null;
        }
      }
    };

    private final Integer major;
    private final Optional<String> qualifier;
    private final Optional<Integer> minor;

    private KubernetesVersion(Integer major, String qualifier, Integer minor, String version) {
      super(version);
      this.major = major;
      this.qualifier = Optional.ofNullable(qualifier);
      this.minor = Optional.ofNullable(minor);
    }

    public Integer getMajor() {
      return major;
    }

    public Optional<String> getQualifier() {
      return qualifier;
    }

    public Optional<Integer> getMinor() {
      return minor;
    }

    public boolean isStable() {
      return qualifier.orElse(null) == null;
    }

    @Override
    public boolean isKubernetes() {
      return true;
    }

    /**
     * Compares this version to another version and returns whether this version has a
     * higher, equal or lower priority than the version that it is being compared to.
     * <p>
     * The Kubernetes specs at <a href=
     * "https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning/#version-priority">
     * Version Priority</a> state the following:
     * </p>
     * <ul>
     * <li>Entries that follow Kubernetes version patterns are sorted before those that do not.</li>
     * <li>For entries that follow Kubernetes version patterns, the numeric portions of the version string is sorted largest to
     * smallest.</li>
     * <li>If the strings beta or alpha follow the first numeric portion, they sorted in that order, after the equivalent string
     * without the beta
     * or alpha suffix (which is presumed to be the GA version).</li>
     * <li>If another number follows the beta, or alpha, those numbers are also sorted from largest to smallest.</li>
     * <li>Strings that don’t fit the above format are sorted alphabetically and the numeric portions are not treated specially.
     * Notice that in the example below, foo1 is sorted above foo10.
     * This is different from the sorting of the numeric portion of entries that do follow the Kubernetes version patterns.</li>
     * </ul>
     *
     * @param other the version to compare this version to
     * @return -1 if this version has a lower, 1 if it has a higher or 0 if the priorities are equal
     *
     */
    @Override
    public int compareTo(Version other) {<FILL_FUNCTION_BODY>}

    private int compareMajor(KubernetesVersion other) {
      return major.compareTo(other.major);
    }

    private int compareMinor(KubernetesVersion other) {
      if (minor.isPresent()) {
        if (!other.minor.isPresent()) {
          return 1;
        }
        return minor.get().compareTo(other.minor.orElse(null));
      } else {
        if (!other.minor.isPresent()) {
          return 0;
        }
        return -1;
      }
    }
  }

      if (other == this) {
        return 0;
      }
      if (other instanceof NonKubernetesVersion) {
        return 1;
      }
      if (!(other instanceof KubernetesVersion)) {
        return 1;
      }
      KubernetesVersion otherKube = (KubernetesVersion) other;
      if (qualifier.isPresent()) {
        if (!otherKube.qualifier.isPresent()) {
          return -1;
        }
        int qualifierComparison = qualifier.get().compareTo(otherKube.qualifier.orElse(null));
        if (qualifierComparison != 0) {
          return qualifierComparison;
        }
        int majorComparison = compareMajor(otherKube);
        if (majorComparison != 0) {
          return majorComparison;
        }
        return compareMinor(otherKube);
      } else {
        if (!otherKube.qualifier.isPresent()) {
          return compareMajor(otherKube);
        } else {
          return 1;
        }
      }
    
<no_super_class>