Class PackageReference

  • All Implemented Interfaces:
    kotlin.Comparable , org.ossreviewtoolkit.model.DependencyNode

    
    public final class PackageReference
     implements Comparable<PackageReference>, DependencyNode
                        

    A human-readable reference to a software Package. Each package reference itself refers to other package references that are dependencies of the package.

    • Method Detail

      • getLinkage

         PackageLinkage getLinkage()

        The type of linkage used for the referred package from its dependent package. As most of our supported package managers / languages only support dynamic linking or at least default to it, also use that as the default value here to not blow up our result files.

      • compareTo

         Integer compareTo(PackageReference other)

        A comparison function to sort package references by their identifier. This function ignores all other properties except for id.

      • dependsOn

         final Boolean dependsOn(Identifier id)

        Return whether the package identified by id is a (transitive) dependency of this reference.

      • visitDependencies

         <T extends Any> T visitDependencies(Function1<Sequence<DependencyNode>, T> block)

        Visit the direct dependencies of this DependencyNode by calling the specified block with a sequence of all child nodes. The code block can produce a result, which is returned by this function. The function is the basis for traversing the whole dependency graph; each call yields the direct dependencies of a node, by calling the function recursively on these dependencies, the transitive dependency set can be visited.

        Notes:

        • Not all storage formats used for dependency information use structures that can be mapped directly to this interface; therefore, some kind of wrapping may be required. To allow for optimizations, this function operates of a sequence rather than a collection; a collection would require wrapping a whole level of dependencies, while this is not necessarily required with a sequence.

        • When constructing dependency graphs, package managers are required to prevent cycles. Therefore, code using this function does not have to implement its own check for cycles to prevent infinite loops. With other words: It is safe to recursively call visitDependencies on the nodes in the sequence.