Class ComponentDescriptor.Builder

java.lang.Object
io.quarkus.sbom.ComponentDescriptor
io.quarkus.sbom.ComponentDescriptor.Builder
Enclosing class:
ComponentDescriptor

public static class ComponentDescriptor.Builder extends ComponentDescriptor
Builder for constructing ComponentDescriptor instances.
  • Constructor Details

    • Builder

      public Builder(ComponentDescriptor component)
      Creates a builder initialized with values from an existing ComponentDescriptor.
      Parameters:
      component - the component to copy values from
  • Method Details

    • setPurl

      public ComponentDescriptor.Builder setPurl(Purl purl)
      Sets the Package URL identifying this component.
      Parameters:
      purl - the Package URL
      Returns:
      this builder
    • setBomRef

      public ComponentDescriptor.Builder setBomRef(String bomRef)
      Sets an explicit bom-ref for this component. If not set, defaults to purl.toString().
      Parameters:
      bomRef - the bom-ref string
      Returns:
      this builder
    • setIntegrity

      public ComponentDescriptor.Builder setIntegrity(String integrity)
      Sets the integrity hash.

      This is typically an SRI hash from lock files (e.g., "sha512-abc123...").

      Parameters:
      integrity - the SRI hash, or null
      Returns:
      this builder
    • setDescription

      public ComponentDescriptor.Builder setDescription(String description)
      Sets the package description.
      Parameters:
      description - a human-readable description, or null
      Returns:
      this builder
    • setScope

      public ComponentDescriptor.Builder setScope(String scope)
      Sets the dependency scope.

      Common values are ComponentDescriptor.SCOPE_RUNTIME and ComponentDescriptor.SCOPE_DEVELOPMENT.

      Parameters:
      scope - the dependency scope, or null
      Returns:
      this builder
    • setDevelopmentScope

      public ComponentDescriptor.Builder setDevelopmentScope()
      Convenience method to set the scope to development.
      Returns:
      this builder
    • setPath

      public ComponentDescriptor.Builder setPath(Path path)
      Sets the file system path to the component artifact. Used for file hash computation in SBOM generators.
      Parameters:
      path - the file path, or null
      Returns:
      this builder
    • setDistributionPath

      public ComponentDescriptor.Builder setDistributionPath(String distributionPath)
      Sets the distribution path (relative location within the application distribution). Used for evidence/occurrence tracking in SBOM generators.
      Parameters:
      distributionPath - the distribution path, or null
      Returns:
      this builder
    • setPedigree

      public ComponentDescriptor.Builder setPedigree(String pedigree)
      Sets the pedigree notes describing component modifications.
      Parameters:
      pedigree - the pedigree notes, or null
      Returns:
      this builder
    • setTopLevel

      public ComponentDescriptor.Builder setTopLevel(boolean topLevel)
      Sets whether this component is a top-level (direct) dependency of the main application component.

      Extensions should set this to true for components that represent direct project dependencies (e.g., packages declared in package.json rather than transitive dependencies).

      Parameters:
      topLevel - true if this is a top-level dependency
      Returns:
      this builder
    • setLicenses

      public ComponentDescriptor.Builder setLicenses(List<LicenseInfo> licenses)
      Sets the licenses for this component, replacing any previously set licenses.
      Parameters:
      licenses - the list of license information entries
      Returns:
      this builder
    • addLicense

      public ComponentDescriptor.Builder addLicense(LicenseInfo license)
      Adds a license to this component.
      Parameters:
      license - the license information to add
      Returns:
      this builder
    • addComponent

      public ComponentDescriptor.Builder addComponent(ComponentDescriptor component)
      Adds a nested (bundled) component to this component.
      Parameters:
      component - the nested component descriptor
      Returns:
      this builder
    • build

      public ComponentDescriptor build()
      Builds an immutable ComponentDescriptor from this builder.
      Returns:
      a new immutable ComponentDescriptor instance
    • ensureImmutable

      protected ComponentDescriptor ensureImmutable()
      Overrides:
      ensureImmutable in class ComponentDescriptor