Skip to content

Commit f5f06c9

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 f5f06c9

File tree

5 files changed

+274
-25
lines changed

5 files changed

+274
-25
lines changed

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

+212-17
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,8 +184,10 @@ 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() {
186192
return PackageURLBuilder.aPackageURL()
187193
.withType(getType())
@@ -592,7 +598,7 @@ private static byte percentDecode(final byte[] bytes, final int start) {
592598
return ((byte) ((c1 << 4) + c2));
593599
}
594600

595-
public static String percentDecode(final String source) {
601+
private static String percentDecode(final String source) {
596602
if (source.isEmpty()) {
597603
return source;
598604
}
@@ -634,8 +640,16 @@ public static String percentDecode(final String source) {
634640
return new String(buffer.array(), 0, buffer.position(), StandardCharsets.UTF_8);
635641
}
636642

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

@@ -649,7 +663,7 @@ private static byte[] percentEncode(byte b) {
649663
return new byte[] {(byte) PERCENT_CHAR, b1, b2};
650664
}
651665

652-
public static String percentEncode(final String source) {
666+
private static String percentEncode(final String source) {
653667
if (source.isEmpty()) {
654668
return source;
655669
}
@@ -841,10 +855,11 @@ private String encodePath(final String path) {
841855

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

860875
/**
861876
* 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.
877+
* the qualifier (querystring).
878+
* This includes equivalence of the scheme, type, namespace, name, and version, but excludes qualifier and subpath
879+
* from evaluation.
864880
*
865881
* @param purl the Package URL to evaluate, not {@code null}
866882
* @return true if equivalence passes, false if not
@@ -925,41 +941,220 @@ public int hashCode() {
925941
* @since 1.0.0
926942
*/
927943
public static final class StandardTypes {
944+
/**
945+
* Arch Linux and other users of the libalpm/pacman package manager.
946+
*
947+
* @since 1.6.0
948+
*/
928949
public static final String ALPM = "alpm";
950+
/**
951+
* APK-based packages.
952+
*
953+
* @since 1.6.0
954+
*/
929955
public static final String APK = "apk";
956+
/**
957+
* Bitbucket-based packages.
958+
*
959+
* @since 1.0.0
960+
*/
930961
public static final String BITBUCKET = "bitbucket";
962+
/**
963+
* Bitnami-based packages.
964+
*
965+
* @since 1.6.0
966+
*/
931967
public static final String BITNAMI = "bitnami";
968+
/**
969+
* Rust.
970+
*
971+
* @since 1.2.0
972+
*/
932973
public static final String CARGO = "cargo";
974+
/**
975+
* CocoaPods.
976+
*
977+
* @since 1.6.0
978+
*/
933979
public static final String COCOAPODS = "cocoapods";
980+
/**
981+
* Composer PHP packages.
982+
*
983+
* @since 1.0.0
984+
*/
934985
public static final String COMPOSER = "composer";
986+
/**
987+
* Conan C/C++ packages.
988+
*
989+
* @since 1.6.0
990+
*/
935991
public static final String CONAN = "conan";
992+
/**
993+
* Conda packages.
994+
*
995+
* @since 1.6.0
996+
*/
936997
public static final String CONDA = "conda";
998+
/**
999+
* CPAN Perl packages.
1000+
*
1001+
* @since 1.6.0
1002+
*/
9371003
public static final String CPAN = "cpan";
1004+
/**
1005+
* CRAN R packages.
1006+
*
1007+
* @since 1.6.0
1008+
*/
9381009
public static final String CRAN = "cran";
1010+
/**
1011+
* Debian, Debian derivatives, and Ubuntu packages.
1012+
*
1013+
* @since 1.6.0
1014+
*/
9391015
public static final String DEB = "deb";
1016+
/**
1017+
* Docker images.
1018+
*
1019+
* @since 1.0.0
1020+
*/
9401021
public static final String DOCKER = "docker";
1022+
/**
1023+
* RubyGems.
1024+
*
1025+
* @since 1.0.0
1026+
*/
9411027
public static final String GEM = "gem";
1028+
/**
1029+
* Plain, generic packages that do not fit anywhere else, such as for "upstream-from-distro" packages.
1030+
*
1031+
* @since 1.0.0
1032+
*/
9421033
public static final String GENERIC = "generic";
1034+
/**
1035+
* GitHub-based packages.
1036+
*
1037+
* @since 1.0.0
1038+
*/
9431039
public static final String GITHUB = "github";
1040+
/**
1041+
* Go packages.
1042+
*
1043+
* @since 1.0.0
1044+
*/
9441045
public static final String GOLANG = "golang";
1046+
/**
1047+
* Haskell packages.
1048+
*
1049+
* @since 1.0.0
1050+
*/
9451051
public static final String HACKAGE = "hackage";
1052+
/**
1053+
* Hex packages.
1054+
*
1055+
* @since 1.6.0
1056+
*/
9461057
public static final String HEX = "hex";
1058+
/**
1059+
* Hugging Face ML models.
1060+
*
1061+
* @since 1.6.0
1062+
*/
9471063
public static final String HUGGINGFACE = "huggingface";
1064+
/**
1065+
* Lua packages installed with LuaRocks.
1066+
*
1067+
* @since 1.6.0
1068+
*/
9481069
public static final String LUAROCKS = "luarocks";
1070+
/**
1071+
* Maven JARs and related artifacts.
1072+
*
1073+
* @since 1.0.0
1074+
*/
9491075
public static final String MAVEN = "maven";
1076+
/**
1077+
* MLflow ML models (Azure ML, Databricks, etc.).
1078+
*
1079+
* @since 1.6.0
1080+
*/
9501081
public static final String MLFLOW = "mlflow";
1082+
/**
1083+
* Nixos packages
1084+
*
1085+
* @since 1.6.0
1086+
*/
9511087
public static final String NIX = "nix";
1088+
/**
1089+
* Node NPM packages.
1090+
*
1091+
* @since 1.0.0
1092+
*/
9521093
public static final String NPM = "npm";
1094+
/**
1095+
* NuGet .NET packages.
1096+
*
1097+
* @since 1.0.0
1098+
*/
9531099
public static final String NUGET = "nuget";
1100+
/**
1101+
* All artifacts stored in registries that conform to the
1102+
* <a href="https://github.com/opencontainers/distribution-spec">OCI Distribution Specification</a>, including
1103+
* container images built by Docker and others.
1104+
*
1105+
* @since 1.6.0
1106+
*/
9541107
public static final String OCI = "oci";
1108+
/**
1109+
* Dart and Flutter packages.
1110+
*
1111+
* @since 1.6.0
1112+
*/
9551113
public static final String PUB = "pub";
1114+
/**
1115+
* Python packages.
1116+
*
1117+
* @since 1.0.0
1118+
*/
9561119
public static final String PYPI = "pypi";
1120+
/**
1121+
* QNX packages.
1122+
*
1123+
* @since 1.6.0
1124+
*/
9571125
public static final String QPKG = "qpkg";
1126+
/**
1127+
* RPMs.
1128+
*
1129+
* @since 1.0.0
1130+
*/
9581131
public static final String RPM = "rpm";
1132+
/**
1133+
* ISO-IEC 19770-2 Software Identification (SWID) tags.
1134+
*
1135+
* @since 1.6.0
1136+
*/
9591137
public static final String SWID = "swid";
1138+
/**
1139+
* Swift packages.
1140+
*
1141+
* @since 1.6.0
1142+
*/
9601143
public static final String SWIFT = "swift";
1144+
/**
1145+
* Debian, Debian derivatives, and Ubuntu packages.
1146+
*
1147+
* @since 1.0.0
1148+
* @deprecated use {@link #DEB} instead
1149+
*/
9611150
@Deprecated
9621151
public static final String DEBIAN = "deb";
1152+
/**
1153+
* Nixos packages.
1154+
*
1155+
* @since 1.1.0
1156+
* @deprecated use {@link #NIX} instead
1157+
*/
9631158
@Deprecated
9641159
public static final String NIXPKGS = "nix";
9651160

0 commit comments

Comments
 (0)