Repository: apple/pkl
File: pkl-core/src/main/java/org/pkl/core/project/CanonicalPackageUri.java (Java)

Code before:
              null,
              uri.getHost(),
              uri.getPort(),
              packageUri.getPathWithoutVersion(),
              // query params aren't considered part of the package identifier.
              null,
              null);
    } catch (URISyntaxException e) {
      throw PklBugException.unreachableCode();
    }
    return new CanonicalPackageUri(baseUri, packageUri.getVersion().getMajor());
  }

  public static CanonicalPackageUri of(String uriStr) throws URISyntaxException {
    var versionIdx = uriStr.lastIndexOf('@');
    if (versionIdx == -1) {
      throw new URISyntaxException(
          uriStr, ErrorMessages.create("missingVersionInPackageUri", uriStr));
    }
    int majorVersion;
    try {
      majorVersion = Integer.parseInt(uriStr.substring(versionIdx + 1));
    } catch (NumberFormatException e) {
      throw new URISyntaxException(uriStr, ErrorMessages.create(""));
    }
    var baseUri = new URI(uriStr.substring(0, versionIdx));
    return new CanonicalPackageUri(baseUri, majorVersion);
  }

  public CanonicalPackageUri(URI baseUri, int majorVersion) {
    this.baseUri = baseUri;
    this.majorVersion = majorVersion;
  }

  @SuppressWarnings("unused")
  public int getMajorVersion() {
    return majorVersion;
  }

  @SuppressWarnings("unused")
  public URI getBaseUri() {
    return baseUri;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;

Review comment (suggestion):
For each of these: add `forRemoval = true`, and add a doc comment about what to replace with

```suggestion
  /**
   * @deprecated As of 0.28.0, replaced by {@link #majorVersion()}.
   */
  @Deprecated(forRemoval = true)
```

Code after:
              // query params aren't considered part of the package identifier.
              null,
              null);
    } catch (URISyntaxException e) {
      throw PklBugException.unreachableCode();
    }
    return new CanonicalPackageUri(baseUri, packageUri.getVersion().getMajor());
  }

  public static CanonicalPackageUri of(String uriStr) throws URISyntaxException {
    var versionIdx = uriStr.lastIndexOf('@');
    if (versionIdx == -1) {
      throw new URISyntaxException(
          uriStr, ErrorMessages.create("missingVersionInPackageUri", uriStr));
    }
    int majorVersion;
    try {
      majorVersion = Integer.parseInt(uriStr.substring(versionIdx + 1));
    } catch (NumberFormatException e) {
      throw new URISyntaxException(uriStr, ErrorMessages.create(""));
    }
    var baseUri = new URI(uriStr.substring(0, versionIdx));
    return new CanonicalPackageUri(baseUri, majorVersion);
  }

  /**
   * @deprecated As of 0.28.0, replaced by {@link #majorVersion()}.
   */
  @Deprecated(forRemoval = true)
  public int getMajorVersion() {
    return majorVersion;
  }

  /**
   * @deprecated As of 0.28.0, replaced by {@link #baseUri()}.
   */
  @Deprecated(forRemoval = true)
  public URI getBaseUri() {
    return baseUri;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    CanonicalPackageUri that = (CanonicalPackageUri) o;
    return majorVersion == that.majorVersion && baseUri.equals(that.baseUri);