Skip to content

Commit 66887d9

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 66887d9

File tree

5 files changed

+274
-24
lines changed

5 files changed

+274
-24
lines changed

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

+212-16
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import java.util.function.IntPredicate;
3737
import java.util.stream.Collectors;
3838
import java.util.stream.IntStream;
39+
40+
import jakarta.validation.constraints.Null;
3941
import org.jspecify.annotations.Nullable;
4042

4143
/**
@@ -45,9 +47,9 @@
4547
* </pre>
4648
* <p>
4749
* 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,
50+
* A purl must NOT contain a URL Authority, i.e., there is no support for username,
4951
* password, host and port components. A namespace segment may sometimes look
50-
* like a host but its interpretation is specific to a type.
52+
* like a host, but its interpretation is specific to a type.
5153
* </p>
5254
* <p>SPEC: <a href="https://github.com/package-url/purl-spec">https://github.com/package-url/purl-spec</a></p>
5355
*
@@ -87,8 +89,8 @@ public PackageURL(final String type, final String name) throws MalformedPackageU
8789
/**
8890
* Constructs a new PackageURL object.
8991
*
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)
92+
* @param type the type of package (i.e., maven, npm, gem, etc.), not {@code null}
93+
* @param namespace the name prefix (i.e., group, owner, organization)
9294
* @param name the name of the package, not {@code null}
9395
* @param version the version of the package
9496
* @param qualifiers an array of key/value pair qualifiers
@@ -115,7 +117,7 @@ public PackageURL(final String type, final @Nullable String namespace, final Str
115117
* Constructs a new PackageURL object.
116118
*
117119
* @param type the type of package (i.e. maven, npm, gem, etc)
118-
* @param namespace the name prefix (i.e. group, owner, organization)
120+
* @param namespace the name prefix (i.e., group, owner, organization)
119121
* @param name the name of the package
120122
* @param version the version of the package
121123
* @param qualifiers an array of key/value pair qualifiers
@@ -124,14 +126,17 @@ public PackageURL(final String type, final @Nullable String namespace, final Str
124126
* @throws NullPointerException if {@code type} or {@code name} are {@code null}
125127
* @since 1.6.0
126128
*/
129+
@SuppressWarnings("deprecation")
127130
public PackageURL(final String type, final @Nullable String namespace, final String name, final @Nullable String version,
128131
final @Nullable Map<String, @Nullable String> qualifiers, final @Nullable String subpath)
129132
throws MalformedPackageURLException {
130133
this(type, namespace, name, version, (qualifiers != null) ? new TreeMap<>(qualifiers) : null, subpath);
131134
}
132135

133136
/**
134-
* The PackageURL scheme constant
137+
* The PackageURL scheme constant.
138+
*
139+
* @since 1.6.0
135140
*/
136141
public static final String SCHEME = "pkg";
137142

@@ -180,8 +185,10 @@ public PackageURL(final String type, final @Nullable String namespace, final Str
180185
* Converts this {@link PackageURL} to a {@link PackageURLBuilder}.
181186
*
182187
* @return the builder
183-
* @deprecated Use {@link PackageURLBuilder#aPackageURL(PackageURL)} or {@link PackageURLBuilder#aPackageURL(String)}
188+
* @since 1.5.0
189+
* @deprecated use {@link PackageURLBuilder#aPackageURL(PackageURL)} or {@link PackageURLBuilder#aPackageURL(String)}
184190
*/
191+
@Deprecated
185192
public PackageURLBuilder toBuilder() {
186193
return PackageURLBuilder.aPackageURL()
187194
.withType(getType())
@@ -592,7 +599,7 @@ private static byte percentDecode(final byte[] bytes, final int start) {
592599
return ((byte) ((c1 << 4) + c2));
593600
}
594601

595-
public static String percentDecode(final String source) {
602+
private static String percentDecode(final String source) {
596603
if (source.isEmpty()) {
597604
return source;
598605
}
@@ -634,8 +641,16 @@ public static String percentDecode(final String source) {
634641
return new String(buffer.array(), 0, buffer.position(), StandardCharsets.UTF_8);
635642
}
636643

644+
/**
645+
* URI decodes the given string.
646+
*
647+
* @param source the encoded string
648+
* @return the decoded string
649+
* @since 1.4.2
650+
* @deprecated this method was made public in error in version 1.4.2 and will be removed without a replacement
651+
*/
637652
@Deprecated
638-
public String uriDecode(final String source) {
653+
public @Nullable String uriDecode(final @Nullable String source) {
639654
return source != null ? percentDecode(source) : null;
640655
}
641656

@@ -649,7 +664,7 @@ private static byte[] percentEncode(byte b) {
649664
return new byte[] {(byte) PERCENT_CHAR, b1, b2};
650665
}
651666

652-
public static String percentEncode(final String source) {
667+
private static String percentEncode(final String source) {
653668
if (source.isEmpty()) {
654669
return source;
655670
}
@@ -841,10 +856,11 @@ private String encodePath(final String path) {
841856

842857
/**
843858
* 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.
859+
* the qualifier (querystring).
860+
* This includes equivalence of the scheme, type, namespace, name, and version, but excludes qualifier and subpath
861+
* from evaluation.
862+
*
863+
* @deprecated This method is no longer recommended and will be removed from a future release.
848864
* <p> Use {@link PackageURL#isCoordinatesEquals} instead.</p>
849865
*
850866
* @param purl the Package URL to evaluate
@@ -859,8 +875,9 @@ public boolean isBaseEquals(final PackageURL purl) {
859875

860876
/**
861877
* 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.
878+
* the qualifier (querystring).
879+
* This includes equivalence of the scheme, type, namespace, name, and version, but excludes qualifier and subpath
880+
* from evaluation.
864881
*
865882
* @param purl the Package URL to evaluate, not {@code null}
866883
* @return true if equivalence passes, false if not
@@ -925,41 +942,220 @@ public int hashCode() {
925942
* @since 1.0.0
926943
*/
927944
public static final class StandardTypes {
945+
/**
946+
* Arch Linux and other users of the libalpm/pacman package manager.
947+
*
948+
* @since 1.6.0
949+
*/
928950
public static final String ALPM = "alpm";
951+
/**
952+
* APK-based packages.
953+
*
954+
* @since 1.6.0
955+
*/
929956
public static final String APK = "apk";
957+
/**
958+
* Bitbucket-based packages.
959+
*
960+
* @since 1.0.0
961+
*/
930962
public static final String BITBUCKET = "bitbucket";
963+
/**
964+
* Bitnami-based packages.
965+
*
966+
* @since 1.6.0
967+
*/
931968
public static final String BITNAMI = "bitnami";
969+
/**
970+
* Rust.
971+
*
972+
* @since 1.2.0
973+
*/
932974
public static final String CARGO = "cargo";
975+
/**
976+
* CocoaPods.
977+
*
978+
* @since 1.6.0
979+
*/
933980
public static final String COCOAPODS = "cocoapods";
981+
/**
982+
* Composer PHP packages.
983+
*
984+
* @since 1.0.0
985+
*/
934986
public static final String COMPOSER = "composer";
987+
/**
988+
* Conan C/C++ packages.
989+
*
990+
* @since 1.6.0
991+
*/
935992
public static final String CONAN = "conan";
993+
/**
994+
* Conda packages.
995+
*
996+
* @since 1.6.0
997+
*/
936998
public static final String CONDA = "conda";
999+
/**
1000+
* CPAN Perl packages.
1001+
*
1002+
* @since 1.6.0
1003+
*/
9371004
public static final String CPAN = "cpan";
1005+
/**
1006+
* CRAN R packages.
1007+
*
1008+
* @since 1.6.0
1009+
*/
9381010
public static final String CRAN = "cran";
1011+
/**
1012+
* Debian, Debian derivatives, and Ubuntu packages.
1013+
*
1014+
* @since 1.6.0
1015+
*/
9391016
public static final String DEB = "deb";
1017+
/**
1018+
* Docker images.
1019+
*
1020+
* @since 1.0.0
1021+
*/
9401022
public static final String DOCKER = "docker";
1023+
/**
1024+
* RubyGems.
1025+
*
1026+
* @since 1.0.0
1027+
*/
9411028
public static final String GEM = "gem";
1029+
/**
1030+
* Plain, generic packages that do not fit anywhere else, such as for "upstream-from-distro" packages.
1031+
*
1032+
* @since 1.0.0
1033+
*/
9421034
public static final String GENERIC = "generic";
1035+
/**
1036+
* GitHub-based packages.
1037+
*
1038+
* @since 1.0.0
1039+
*/
9431040
public static final String GITHUB = "github";
1041+
/**
1042+
* Go packages.
1043+
*
1044+
* @since 1.0.0
1045+
*/
9441046
public static final String GOLANG = "golang";
1047+
/**
1048+
* Haskell packages.
1049+
*
1050+
* @since 1.0.0
1051+
*/
9451052
public static final String HACKAGE = "hackage";
1053+
/**
1054+
* Hex packages.
1055+
*
1056+
* @since 1.6.0
1057+
*/
9461058
public static final String HEX = "hex";
1059+
/**
1060+
* Hugging Face ML models.
1061+
*
1062+
* @since 1.6.0
1063+
*/
9471064
public static final String HUGGINGFACE = "huggingface";
1065+
/**
1066+
* Lua packages installed with LuaRocks.
1067+
*
1068+
* @since 1.6.0
1069+
*/
9481070
public static final String LUAROCKS = "luarocks";
1071+
/**
1072+
* Maven JARs and related artifacts.
1073+
*
1074+
* @since 1.0.0
1075+
*/
9491076
public static final String MAVEN = "maven";
1077+
/**
1078+
* MLflow ML models (Azure ML, Databricks, etc.).
1079+
*
1080+
* @since 1.6.0
1081+
*/
9501082
public static final String MLFLOW = "mlflow";
1083+
/**
1084+
* Nixos packages
1085+
*
1086+
* @since 1.6.0
1087+
*/
9511088
public static final String NIX = "nix";
1089+
/**
1090+
* Node NPM packages.
1091+
*
1092+
* @since 1.0.0
1093+
*/
9521094
public static final String NPM = "npm";
1095+
/**
1096+
* NuGet .NET packages.
1097+
*
1098+
* @since 1.0.0
1099+
*/
9531100
public static final String NUGET = "nuget";
1101+
/**
1102+
* All artifacts stored in registries that conform to the
1103+
* <a href="https://github.com/opencontainers/distribution-spec">OCI Distribution Specification</a>, including
1104+
* container images built by Docker and others.
1105+
*
1106+
* @since 1.6.0
1107+
*/
9541108
public static final String OCI = "oci";
1109+
/**
1110+
* Dart and Flutter packages.
1111+
*
1112+
* @since 1.6.0
1113+
*/
9551114
public static final String PUB = "pub";
1115+
/**
1116+
* Python packages.
1117+
*
1118+
* @since 1.0.0
1119+
*/
9561120
public static final String PYPI = "pypi";
1121+
/**
1122+
* QNX packages.
1123+
*
1124+
* @since 1.6.0
1125+
*/
9571126
public static final String QPKG = "qpkg";
1127+
/**
1128+
* RPMs.
1129+
*
1130+
* @since 1.0.0
1131+
*/
9581132
public static final String RPM = "rpm";
1133+
/**
1134+
* ISO-IEC 19770-2 Software Identification (SWID) tags.
1135+
*
1136+
* @since 1.6.0
1137+
*/
9591138
public static final String SWID = "swid";
1139+
/**
1140+
* Swift packages.
1141+
*
1142+
* @since 1.6.0
1143+
*/
9601144
public static final String SWIFT = "swift";
1145+
/**
1146+
* Debian, Debian derivatives, and Ubuntu packages.
1147+
*
1148+
* @since 1.0.0
1149+
* @deprecated use {@link #DEB} instead
1150+
*/
9611151
@Deprecated
9621152
public static final String DEBIAN = "deb";
1153+
/**
1154+
* Nixos packages.
1155+
*
1156+
* @since 1.1.0
1157+
* @deprecated use {@link #NIX} instead
1158+
*/
9631159
@Deprecated
9641160
public static final String NIXPKGS = "nix";
9651161

0 commit comments

Comments
 (0)