Builder
Build a package-url programmatically
Construction of a PackageUrl is done with a Builder via builder():
PackageUrl purl = PackageUrl.builder()
.type("maven")
.namespace("junit")
.name("junit")
.version("4.12")
.build();
Mutation
Mutation is also handled by a builder by converting an existing PackageUrl
into a Builder
:
PackageUrl purl = PackageUrl.parse("pkg:maven/junit/junit@4.12");
PackageUrl purlNoVersion = purl.asBuilder().version(null).build();