Skip to content

Commit 9c4cf57

Browse files
committed
fix: Add missing @deprecated and @since to javadoc
Add some missing javadoc. Fix some method visibility issues and remove use of deprecated methods from code.
1 parent 8925c06 commit 9c4cf57

File tree

6 files changed

+248
-35
lines changed

6 files changed

+248
-35
lines changed

src/main/java/com/github/packageurl/PackageURL.java

+192-24
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.util.function.IntPredicate;
3737
import java.util.stream.Collectors;
3838
import java.util.stream.IntStream;
39+
3940
import org.jspecify.annotations.Nullable;
4041

4142
/**
@@ -45,9 +46,9 @@
4546
* </pre>
4647
* <p>
4748
* Components are separated by a specific character for unambiguous parsing.
48-
* A purl must NOT contain a URL Authority i.e. there is no support for username,
49+
* A purl must NOT contain a URL Authority, i.e., there is no support for username,
4950
* password, host and port components. A namespace segment may sometimes look
50-
* like a host but its interpretation is specific to a type.
51+
* like a host, but its interpretation is specific to a type.
5152
* </p>
5253
* <p>SPEC: <a href="https://github.com/package-url/purl-spec">https://github.com/package-url/purl-spec</a></p>
5354
*
@@ -87,8 +88,8 @@ public PackageURL(final String type, final String name) throws MalformedPackageU
8788
/**
8889
* Constructs a new PackageURL object.
8990
*
90-
* @param type the type of package (i.e. maven, npm, gem, etc), not {@code null}
91-
* @param namespace the name prefix (i.e. group, owner, organization)
91+
* @param type the type of package (i.e., maven, npm, gem, etc.), not {@code null}
92+
* @param namespace the name prefix (i.e., group, owner, organization)
9293
* @param name the name of the package, not {@code null}
9394
* @param version the version of the package
9495
* @param qualifiers an array of key/value pair qualifiers
@@ -115,7 +116,7 @@ public PackageURL(final String type, final @Nullable String namespace, final Str
115116
* Constructs a new PackageURL object.
116117
*
117118
* @param type the type of package (i.e. maven, npm, gem, etc)
118-
* @param namespace the name prefix (i.e. group, owner, organization)
119+
* @param namespace the name prefix (i.e., group, owner, organization)
119120
* @param name the name of the package
120121
* @param version the version of the package
121122
* @param qualifiers an array of key/value pair qualifiers
@@ -124,14 +125,17 @@ public PackageURL(final String type, final @Nullable String namespace, final Str
124125
* @throws NullPointerException if {@code type} or {@code name} are {@code null}
125126
* @since 1.6.0
126127
*/
128+
@SuppressWarnings("deprecation")
127129
public PackageURL(final String type, final @Nullable String namespace, final String name, final @Nullable String version,
128-
final @Nullable Map<String, @Nullable String> qualifiers, final @Nullable String subpath)
130+
final @Nullable Map<String, String> qualifiers, final @Nullable String subpath)
129131
throws MalformedPackageURLException {
130132
this(type, namespace, name, version, (qualifiers != null) ? new TreeMap<>(qualifiers) : null, subpath);
131133
}
132134

133135
/**
134-
* The PackageURL scheme constant
136+
* The PackageURL scheme constant.
137+
*
138+
* @since 1.6.0
135139
*/
136140
public static final String SCHEME = "pkg";
137141

@@ -180,16 +184,12 @@ public PackageURL(final String type, final @Nullable String namespace, final Str
180184
* Converts this {@link PackageURL} to a {@link PackageURLBuilder}.
181185
*
182186
* @return the builder
183-
* @deprecated Use {@link PackageURLBuilder#aPackageURL(PackageURL)} or {@link PackageURLBuilder#aPackageURL(String)}
187+
* @since 1.5.0
188+
* @deprecated use {@link PackageURLBuilder#aPackageURL(PackageURL)} or {@link PackageURLBuilder#aPackageURL(String)}
184189
*/
190+
@Deprecated
185191
public PackageURLBuilder toBuilder() {
186-
return PackageURLBuilder.aPackageURL()
187-
.withType(getType())
188-
.withNamespace(getNamespace())
189-
.withName(getName())
190-
.withVersion(getVersion())
191-
.withQualifiers(getQualifiers())
192-
.withSubpath(getSubpath());
192+
return PackageURLBuilder.aPackageURL(this);
193193
}
194194

195195
/**
@@ -592,7 +592,7 @@ private static byte percentDecode(final byte[] bytes, final int start) {
592592
return ((byte) ((c1 << 4) + c2));
593593
}
594594

595-
public static String percentDecode(final String source) {
595+
private static String percentDecode(final String source) {
596596
if (source.isEmpty()) {
597597
return source;
598598
}
@@ -634,8 +634,16 @@ public static String percentDecode(final String source) {
634634
return new String(buffer.array(), 0, buffer.position(), StandardCharsets.UTF_8);
635635
}
636636

637+
/**
638+
* URI decodes the given string.
639+
*
640+
* @param source the encoded string
641+
* @return the decoded string
642+
* @since 1.4.2
643+
* @deprecated this method was made public in error in version 1.4.2 and will be removed without a replacement
644+
*/
637645
@Deprecated
638-
public String uriDecode(final String source) {
646+
public @Nullable String uriDecode(final @Nullable String source) {
639647
return source != null ? percentDecode(source) : null;
640648
}
641649

@@ -649,7 +657,7 @@ private static byte[] percentEncode(byte b) {
649657
return new byte[] {(byte) PERCENT_CHAR, b1, b2};
650658
}
651659

652-
public static String percentEncode(final String source) {
660+
private static String percentEncode(final String source) {
653661
if (source.isEmpty()) {
654662
return source;
655663
}
@@ -841,10 +849,11 @@ private String encodePath(final String path) {
841849

842850
/**
843851
* Evaluates if the specified Package URL has the same values up to, but excluding
844-
* the qualifier (querystring). This includes equivalence of: scheme, type, namespace,
845-
* name, and version, but excludes qualifier and subpath from evaluation.
846-
* @deprecated
847-
* This method is no longer recommended and will be removed from a future release.
852+
* the qualifier (querystring).
853+
* This includes equivalence of the scheme, type, namespace, name, and version, but excludes qualifier and subpath
854+
* from evaluation.
855+
*
856+
* @deprecated This method is no longer recommended and will be removed from a future release.
848857
* <p> Use {@link PackageURL#isCoordinatesEquals} instead.</p>
849858
*
850859
* @param purl the Package URL to evaluate
@@ -859,8 +868,9 @@ public boolean isBaseEquals(final PackageURL purl) {
859868

860869
/**
861870
* Evaluates if the specified Package URL has the same values up to, but excluding
862-
* the qualifier (querystring). This includes equivalence of: scheme, type, namespace,
863-
* name, and version, but excludes qualifier and subpath from evaluation.
871+
* the qualifier (querystring).
872+
* This includes equivalence of the scheme, type, namespace, name, and version, but excludes qualifier and subpath
873+
* from evaluation.
864874
*
865875
* @param purl the Package URL to evaluate, not {@code null}
866876
* @return true if equivalence passes, false if not
@@ -925,41 +935,199 @@ public int hashCode() {
925935
* @since 1.0.0
926936
*/
927937
public static final class StandardTypes {
938+
/**
939+
* Arch Linux and other users of the libalpm/pacman package manager.
940+
*
941+
* @since 1.6.0
942+
*/
928943
public static final String ALPM = "alpm";
944+
/**
945+
* APK-based packages.
946+
*
947+
* @since 1.6.0
948+
*/
929949
public static final String APK = "apk";
950+
/**
951+
* Bitbucket-based packages.
952+
*/
930953
public static final String BITBUCKET = "bitbucket";
954+
/**
955+
* Bitnami-based packages.
956+
*
957+
* @since 1.6.0
958+
*/
931959
public static final String BITNAMI = "bitnami";
960+
/**
961+
* Rust.
962+
*
963+
* @since 1.2.0
964+
*/
932965
public static final String CARGO = "cargo";
966+
/**
967+
* CocoaPods.
968+
*
969+
* @since 1.6.0
970+
*/
933971
public static final String COCOAPODS = "cocoapods";
972+
/**
973+
* Composer PHP packages.
974+
*/
934975
public static final String COMPOSER = "composer";
976+
/**
977+
* Conan C/C++ packages.
978+
*
979+
* @since 1.6.0
980+
*/
935981
public static final String CONAN = "conan";
982+
/**
983+
* Conda packages.
984+
*
985+
* @since 1.6.0
986+
*/
936987
public static final String CONDA = "conda";
988+
/**
989+
* CPAN Perl packages.
990+
*
991+
* @since 1.6.0
992+
*/
937993
public static final String CPAN = "cpan";
994+
/**
995+
* CRAN R packages.
996+
*
997+
* @since 1.6.0
998+
*/
938999
public static final String CRAN = "cran";
1000+
/**
1001+
* Debian, Debian derivatives, and Ubuntu packages.
1002+
*
1003+
* @since 1.6.0
1004+
*/
9391005
public static final String DEB = "deb";
1006+
/**
1007+
* Docker images.
1008+
*/
9401009
public static final String DOCKER = "docker";
1010+
/**
1011+
* RubyGems.
1012+
*/
9411013
public static final String GEM = "gem";
1014+
/**
1015+
* Plain, generic packages that do not fit anywhere else, such as for "upstream-from-distro" packages.
1016+
*/
9421017
public static final String GENERIC = "generic";
1018+
/**
1019+
* GitHub-based packages.
1020+
*/
9431021
public static final String GITHUB = "github";
1022+
/**
1023+
* Go packages.
1024+
*/
9441025
public static final String GOLANG = "golang";
1026+
/**
1027+
* Haskell packages.
1028+
*/
9451029
public static final String HACKAGE = "hackage";
1030+
/**
1031+
* Hex packages.
1032+
*
1033+
* @since 1.6.0
1034+
*/
9461035
public static final String HEX = "hex";
1036+
/**
1037+
* Hugging Face ML models.
1038+
*
1039+
* @since 1.6.0
1040+
*/
9471041
public static final String HUGGINGFACE = "huggingface";
1042+
/**
1043+
* Lua packages installed with LuaRocks.
1044+
*
1045+
* @since 1.6.0
1046+
*/
9481047
public static final String LUAROCKS = "luarocks";
1048+
/**
1049+
* Maven JARs and related artifacts.
1050+
*
1051+
* @since 1.0.0
1052+
*/
9491053
public static final String MAVEN = "maven";
1054+
/**
1055+
* MLflow ML models (Azure ML, Databricks, etc.).
1056+
*
1057+
* @since 1.6.0
1058+
*/
9501059
public static final String MLFLOW = "mlflow";
1060+
/**
1061+
* Nixos packages
1062+
*
1063+
* @since 1.6.0
1064+
*/
9511065
public static final String NIX = "nix";
1066+
/**
1067+
* Node NPM packages.
1068+
*
1069+
* @since 1.0.0
1070+
*/
9521071
public static final String NPM = "npm";
1072+
/**
1073+
* NuGet .NET packages.
1074+
*
1075+
* @since 1.0.0
1076+
*/
9531077
public static final String NUGET = "nuget";
1078+
/**
1079+
* All artifacts stored in registries that conform to the
1080+
* <a href="https://github.com/opencontainers/distribution-spec">OCI Distribution Specification</a>, including
1081+
* container images built by Docker and others.
1082+
*
1083+
* @since 1.6.0
1084+
*/
9541085
public static final String OCI = "oci";
1086+
/**
1087+
* Dart and Flutter packages.
1088+
*
1089+
* @since 1.6.0
1090+
*/
9551091
public static final String PUB = "pub";
1092+
/**
1093+
* Python packages.
1094+
*/
9561095
public static final String PYPI = "pypi";
1096+
/**
1097+
* QNX packages.
1098+
*
1099+
* @since 1.6.0
1100+
*/
9571101
public static final String QPKG = "qpkg";
1102+
/**
1103+
* RPMs.
1104+
*/
9581105
public static final String RPM = "rpm";
1106+
/**
1107+
* ISO-IEC 19770-2 Software Identification (SWID) tags.
1108+
*
1109+
* @since 1.6.0
1110+
*/
9591111
public static final String SWID = "swid";
1112+
/**
1113+
* Swift packages.
1114+
*
1115+
* @since 1.6.0
1116+
*/
9601117
public static final String SWIFT = "swift";
1118+
/**
1119+
* Debian, Debian derivatives, and Ubuntu packages.
1120+
*
1121+
* @deprecated use {@link #DEB} instead
1122+
*/
9611123
@Deprecated
9621124
public static final String DEBIAN = "deb";
1125+
/**
1126+
* Nixos packages.
1127+
*
1128+
* @since 1.1.0
1129+
* @deprecated use {@link #NIX} instead
1130+
*/
9631131
@Deprecated
9641132
public static final String NIXPKGS = "nix";
9651133

0 commit comments

Comments
 (0)