Skip to content

Commit 1d4ad9b

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 fe90327 commit 1d4ad9b

File tree

7 files changed

+266
-45
lines changed

7 files changed

+266
-45
lines changed

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

Lines changed: 210 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
* </pre>
4747
* <p>
4848
* Components are separated by a specific character for unambiguous parsing.
49-
* 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,
5050
* password, host and port components. A namespace segment may sometimes look
51-
* like a host but its interpretation is specific to a type.
51+
* like a host, but its interpretation is specific to a type.
5252
* </p>
5353
* <p>SPEC: <a href="https://github.com/package-url/purl-spec">https://github.com/package-url/purl-spec</a></p>
5454
*
@@ -82,14 +82,14 @@ public PackageURL(final String purl) throws MalformedPackageURLException {
8282
* @since 1.0.0
8383
*/
8484
public PackageURL(final String type, final String name) throws MalformedPackageURLException {
85-
this(type, null, name, null, null, null);
85+
this(type, null, name, null, (Map<String, String>) null, null);
8686
}
8787

8888
/**
8989
* Constructs a new PackageURL object.
9090
*
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)
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)
9393
* @param name the name of the package, not {@code null}
9494
* @param version the version of the package
9595
* @param qualifiers an array of key/value pair qualifiers
@@ -108,20 +108,14 @@ public PackageURL(
108108
final @Nullable TreeMap<String, String> qualifiers,
109109
final @Nullable String subpath)
110110
throws MalformedPackageURLException {
111-
this.type = toLowerCase(validateType(requireNonNull(type, "type")));
112-
this.namespace = validateNamespace(namespace);
113-
this.name = validateName(requireNonNull(name, "name"));
114-
this.version = validateVersion(type, version);
115-
this.qualifiers = parseQualifiers(qualifiers);
116-
this.subpath = validateSubpath(subpath);
117-
verifyTypeConstraints(this.type, this.namespace, this.name);
111+
this(type, namespace, name, version, qualifiers != null ? (Map<String, String>) qualifiers : null, subpath);
118112
}
119113

120114
/**
121115
* Constructs a new PackageURL object.
122116
*
123117
* @param type the type of package (i.e. maven, npm, gem, etc)
124-
* @param namespace the name prefix (i.e. group, owner, organization)
118+
* @param namespace the name prefix (i.e., group, owner, organization)
125119
* @param name the name of the package
126120
* @param version the version of the package
127121
* @param qualifiers an array of key/value pair qualifiers
@@ -130,6 +124,28 @@ public PackageURL(
130124
* @throws NullPointerException if {@code type} or {@code name} are {@code null}
131125
* @since 1.6.0
132126
*/
127+
public PackageURL(
128+
final String type,
129+
final @Nullable String namespace,
130+
final String name,
131+
final @Nullable String version,
132+
final @Nullable Map<String, String> qualifiers,
133+
final @Nullable String subpath)
134+
throws MalformedPackageURLException {
135+
this.type = toLowerCase(validateType(requireNonNull(type, "type")));
136+
this.namespace = validateNamespace(namespace);
137+
this.name = validateName(requireNonNull(name, "name"));
138+
this.version = validateVersion(type, version);
139+
this.qualifiers = parseQualifiers(qualifiers);
140+
this.subpath = validateSubpath(subpath);
141+
verifyTypeConstraints(this.type, this.namespace, this.name);
142+
}
143+
144+
/**
145+
* The PackageURL scheme constant.
146+
*
147+
* @since 1.6.0
148+
*/
133149
public PackageURL(
134150
final String type,
135151
final @Nullable String namespace,
@@ -191,16 +207,12 @@ public PackageURL(
191207
* Converts this {@link PackageURL} to a {@link PackageURLBuilder}.
192208
*
193209
* @return the builder
194-
* @deprecated Use {@link PackageURLBuilder#aPackageURL(PackageURL)} or {@link PackageURLBuilder#aPackageURL(String)}
210+
* @since 1.5.0
211+
* @deprecated use {@link PackageURLBuilder#aPackageURL(PackageURL)} or {@link PackageURLBuilder#aPackageURL(String)}
195212
*/
213+
@Deprecated
196214
public PackageURLBuilder toBuilder() {
197-
return PackageURLBuilder.aPackageURL()
198-
.withType(getType())
199-
.withNamespace(getNamespace())
200-
.withName(getName())
201-
.withVersion(getVersion())
202-
.withQualifiers(getQualifiers())
203-
.withSubpath(getSubpath());
215+
return PackageURLBuilder.aPackageURL(this);
204216
}
205217

206218
/**
@@ -632,7 +644,7 @@ private static byte percentDecode(final byte[] bytes, final int start) {
632644
return ((byte) ((c1 << 4) + c2));
633645
}
634646

635-
public static String percentDecode(final String source) {
647+
static String percentDecode(final String source) {
636648
if (source.isEmpty()) {
637649
return source;
638650
}
@@ -674,8 +686,16 @@ public static String percentDecode(final String source) {
674686
return new String(buffer.array(), 0, buffer.position(), StandardCharsets.UTF_8);
675687
}
676688

689+
/**
690+
* URI decodes the given string.
691+
*
692+
* @param source the encoded string
693+
* @return the decoded string
694+
* @since 1.4.2
695+
* @deprecated this method was made public in error in version 1.4.2 and will be removed without a replacement
696+
*/
677697
@Deprecated
678-
public String uriDecode(final String source) {
698+
public @Nullable String uriDecode(final @Nullable String source) {
679699
return source != null ? percentDecode(source) : null;
680700
}
681701

@@ -689,7 +709,7 @@ private static byte[] percentEncode(byte b) {
689709
return new byte[] {(byte) PERCENT_CHAR, b1, b2};
690710
}
691711

692-
public static String percentEncode(final String source) {
712+
static String percentEncode(final String source) {
693713
if (source.isEmpty()) {
694714
return source;
695715
}
@@ -889,10 +909,11 @@ private String encodePath(final String path) {
889909

890910
/**
891911
* Evaluates if the specified Package URL has the same values up to, but excluding
892-
* the qualifier (querystring). This includes equivalence of: scheme, type, namespace,
893-
* name, and version, but excludes qualifier and subpath from evaluation.
894-
* @deprecated
895-
* This method is no longer recommended and will be removed from a future release.
912+
* the qualifier (querystring).
913+
* This includes equivalence of the scheme, type, namespace, name, and version, but excludes qualifier and subpath
914+
* from evaluation.
915+
*
916+
* @deprecated This method is no longer recommended and will be removed from a future release.
896917
* <p> Use {@link PackageURL#isCoordinatesEquals} instead.</p>
897918
*
898919
* @param purl the Package URL to evaluate
@@ -907,8 +928,9 @@ public boolean isBaseEquals(final PackageURL purl) {
907928

908929
/**
909930
* Evaluates if the specified Package URL has the same values up to, but excluding
910-
* the qualifier (querystring). This includes equivalence of: scheme, type, namespace,
911-
* name, and version, but excludes qualifier and subpath from evaluation.
931+
* the qualifier (querystring).
932+
* This includes equivalence of the scheme, type, namespace, name, and version, but excludes qualifier and subpath
933+
* from evaluation.
912934
*
913935
* @param purl the Package URL to evaluate, not {@code null}
914936
* @return true if equivalence passes, false if not
@@ -973,43 +995,199 @@ public int hashCode() {
973995
* @since 1.0.0
974996
*/
975997
public static final class StandardTypes {
998+
/**
999+
* Arch Linux and other users of the libalpm/pacman package manager.
1000+
*
1001+
* @since 1.6.0
1002+
*/
9761003
public static final String ALPM = "alpm";
1004+
/**
1005+
* APK-based packages.
1006+
*
1007+
* @since 1.6.0
1008+
*/
9771009
public static final String APK = "apk";
1010+
/**
1011+
* Bitbucket-based packages.
1012+
*/
9781013
public static final String BITBUCKET = "bitbucket";
1014+
/**
1015+
* Bitnami-based packages.
1016+
*
1017+
* @since 1.6.0
1018+
*/
9791019
public static final String BITNAMI = "bitnami";
1020+
/**
1021+
* Rust.
1022+
*
1023+
* @since 1.2.0
1024+
*/
9801025
public static final String CARGO = "cargo";
1026+
/**
1027+
* CocoaPods.
1028+
*
1029+
* @since 1.6.0
1030+
*/
9811031
public static final String COCOAPODS = "cocoapods";
1032+
/**
1033+
* Composer PHP packages.
1034+
*/
9821035
public static final String COMPOSER = "composer";
1036+
/**
1037+
* Conan C/C++ packages.
1038+
*
1039+
* @since 1.6.0
1040+
*/
9831041
public static final String CONAN = "conan";
1042+
/**
1043+
* Conda packages.
1044+
*
1045+
* @since 1.6.0
1046+
*/
9841047
public static final String CONDA = "conda";
1048+
/**
1049+
* CPAN Perl packages.
1050+
*
1051+
* @since 1.6.0
1052+
*/
9851053
public static final String CPAN = "cpan";
1054+
/**
1055+
* CRAN R packages.
1056+
*
1057+
* @since 1.6.0
1058+
*/
9861059
public static final String CRAN = "cran";
1060+
/**
1061+
* Debian, Debian derivatives, and Ubuntu packages.
1062+
*
1063+
* @since 1.6.0
1064+
*/
9871065
public static final String DEB = "deb";
1066+
/**
1067+
* Docker images.
1068+
*/
9881069
public static final String DOCKER = "docker";
1070+
/**
1071+
* RubyGems.
1072+
*/
9891073
public static final String GEM = "gem";
1074+
/**
1075+
* Plain, generic packages that do not fit anywhere else, such as for "upstream-from-distro" packages.
1076+
*/
9901077
public static final String GENERIC = "generic";
1078+
/**
1079+
* GitHub-based packages.
1080+
*/
9911081
public static final String GITHUB = "github";
1082+
/**
1083+
* Go packages.
1084+
*/
9921085
public static final String GOLANG = "golang";
1086+
/**
1087+
* Haskell packages.
1088+
*/
9931089
public static final String HACKAGE = "hackage";
1090+
/**
1091+
* Hex packages.
1092+
*
1093+
* @since 1.6.0
1094+
*/
9941095
public static final String HEX = "hex";
1096+
/**
1097+
* Hugging Face ML models.
1098+
*
1099+
* @since 1.6.0
1100+
*/
9951101
public static final String HUGGINGFACE = "huggingface";
1102+
/**
1103+
* Lua packages installed with LuaRocks.
1104+
*
1105+
* @since 1.6.0
1106+
*/
9961107
public static final String LUAROCKS = "luarocks";
1108+
/**
1109+
* Maven JARs and related artifacts.
1110+
*
1111+
* @since 1.0.0
1112+
*/
9971113
public static final String MAVEN = "maven";
1114+
/**
1115+
* MLflow ML models (Azure ML, Databricks, etc.).
1116+
*
1117+
* @since 1.6.0
1118+
*/
9981119
public static final String MLFLOW = "mlflow";
1120+
/**
1121+
* Nixos packages
1122+
*
1123+
* @since 1.6.0
1124+
*/
9991125
public static final String NIX = "nix";
1126+
/**
1127+
* Node NPM packages.
1128+
*
1129+
* @since 1.0.0
1130+
*/
10001131
public static final String NPM = "npm";
1132+
/**
1133+
* NuGet .NET packages.
1134+
*
1135+
* @since 1.0.0
1136+
*/
10011137
public static final String NUGET = "nuget";
1138+
/**
1139+
* All artifacts stored in registries that conform to the
1140+
* <a href="https://github.com/opencontainers/distribution-spec">OCI Distribution Specification</a>, including
1141+
* container images built by Docker and others.
1142+
*
1143+
* @since 1.6.0
1144+
*/
10021145
public static final String OCI = "oci";
1146+
/**
1147+
* Dart and Flutter packages.
1148+
*
1149+
* @since 1.6.0
1150+
*/
10031151
public static final String PUB = "pub";
1152+
/**
1153+
* Python packages.
1154+
*/
10041155
public static final String PYPI = "pypi";
1156+
/**
1157+
* QNX packages.
1158+
*
1159+
* @since 1.6.0
1160+
*/
10051161
public static final String QPKG = "qpkg";
1162+
/**
1163+
* RPMs.
1164+
*/
10061165
public static final String RPM = "rpm";
1166+
/**
1167+
* ISO-IEC 19770-2 Software Identification (SWID) tags.
1168+
*
1169+
* @since 1.6.0
1170+
*/
10071171
public static final String SWID = "swid";
1172+
/**
1173+
* Swift packages.
1174+
*
1175+
* @since 1.6.0
1176+
*/
10081177
public static final String SWIFT = "swift";
1009-
1178+
/**
1179+
* Debian, Debian derivatives, and Ubuntu packages.
1180+
*
1181+
* @deprecated use {@link #DEB} instead
1182+
*/
10101183
@Deprecated
10111184
public static final String DEBIAN = "deb";
1012-
1185+
/**
1186+
* Nixos packages.
1187+
*
1188+
* @since 1.1.0
1189+
* @deprecated use {@link #NIX} instead
1190+
*/
10131191
@Deprecated
10141192
public static final String NIXPKGS = "nix";
10151193

0 commit comments

Comments
 (0)