Class PackageURLBuilder

java.lang.Object
com.github.packageurl.PackageURLBuilder

public final class PackageURLBuilder extends Object
A builder construct for Package-URL objects.
  • Field Details

  • Constructor Details

    • PackageURLBuilder

      private PackageURLBuilder()
  • Method Details

    • aPackageURL

      public static PackageURLBuilder aPackageURL()
      Obtain a reference to a new builder object.
      Returns:
      a new builder object.
    • withType

      public PackageURLBuilder withType(String type)
      Adds the package URL type.
      Parameters:
      type - the package type
      Returns:
      a reference to the builder
      See Also:
    • withNamespace

      public PackageURLBuilder withNamespace(String namespace)
      Adds the package namespace.
      Parameters:
      namespace - the package namespace
      Returns:
      a reference to the builder
      See Also:
    • withName

      public PackageURLBuilder withName(String name)
      Adds the package name.
      Parameters:
      name - the package name
      Returns:
      a reference to the builder
      See Also:
    • withVersion

      public PackageURLBuilder withVersion(String version)
      Adds the package version.
      Parameters:
      version - the package version
      Returns:
      a reference to the builder
      See Also:
    • withSubpath

      public PackageURLBuilder withSubpath(String subpath)
      Adds the package subpath.
      Parameters:
      subpath - the package subpath
      Returns:
      a reference to the builder
      See Also:
    • withQualifier

      public PackageURLBuilder withQualifier(String key, String value)
      Adds a package qualifier.
      Parameters:
      key - the package qualifier key
      value - the package qualifier value
      Returns:
      a reference to the builder
      See Also:
    • withoutQualifier

      public PackageURLBuilder withoutQualifier(String key)
      Removes a package qualifier. This is a no-op if the qualifier is not present.
      Parameters:
      key - the package qualifier key to remove
      Returns:
      a reference to the builder
    • withNoQualifiers

      public PackageURLBuilder withNoQualifiers()
      Removes all qualifiers, if any.
      Returns:
      a reference to this builder.
    • getType

      public String getType()
      Returns current type value set in the builder.
      Returns:
      type set in this builder
    • getNamespace

      public String getNamespace()
      Returns current namespace value set in the builder.
      Returns:
      namespace set in this builder
    • getName

      public String getName()
      Returns current name value set in the builder.
      Returns:
      name set in this builder
    • getVersion

      public String getVersion()
      Returns current version value set in the builder.
      Returns:
      version set in this builder
    • getSubpath

      public String getSubpath()
      Returns current subpath value set in the builder.
      Returns:
      subpath set in this builder
    • getQualifiers

      public TreeMap<String,String> getQualifiers()
      Returns sorted map containing all qualifiers set in this builder. An empty map is returned if no qualifiers is set.
      Returns:
      all qualifiers set in this builder, or an empty map if none are set.
    • getQualifier

      public String getQualifier(String key)
      Returns a currently set qualifier value set in the builder for the specified key.
      Parameters:
      key - qualifier key
      Returns:
      qualifier value or null if one is not set.
    • build

      Builds the new PackageURL object.
      Returns:
      the new PackageURL object
      Throws:
      MalformedPackageURLException - thrown if the type or name has not been specified or if a field fails validation