Search in sources :

Example 1 with NpmRequires

use of com.synopsys.integration.detectable.detectables.npm.lockfile.model.NpmRequires in project synopsys-detect by blackducksoftware.

the class NpmDependencyConverter method convertPackageMapToDependencies.

public List<NpmDependency> convertPackageMapToDependencies(NpmDependency parent, Map<String, PackageLockDependency> packageLockDependencyMap) {
    List<NpmDependency> children = new ArrayList<>();
    if (packageLockDependencyMap == null || packageLockDependencyMap.size() == 0) {
        return children;
    }
    for (Map.Entry<String, PackageLockDependency> packageEntry : packageLockDependencyMap.entrySet()) {
        String packageName = packageEntry.getKey();
        PackageLockDependency packageLockDependency = packageEntry.getValue();
        NpmDependency dependency = createNpmDependency(packageName, packageLockDependency.version, packageLockDependency.dev, packageLockDependency.peer);
        dependency.setParent(parent);
        children.add(dependency);
        List<NpmRequires> requires = convertNameVersionMapToRequires(packageLockDependency.requires);
        dependency.addAllRequires(requires);
        List<NpmDependency> grandChildren = convertPackageMapToDependencies(dependency, packageLockDependency.dependencies);
        dependency.addAllDependencies(grandChildren);
    }
    return children;
}
Also used : PackageLockDependency(com.synopsys.integration.detectable.detectables.npm.lockfile.model.PackageLockDependency) NpmDependency(com.synopsys.integration.detectable.detectables.npm.lockfile.model.NpmDependency) NpmRequires(com.synopsys.integration.detectable.detectables.npm.lockfile.model.NpmRequires) ArrayList(java.util.ArrayList) Map(java.util.Map)

Aggregations

NpmDependency (com.synopsys.integration.detectable.detectables.npm.lockfile.model.NpmDependency)1 NpmRequires (com.synopsys.integration.detectable.detectables.npm.lockfile.model.NpmRequires)1 PackageLockDependency (com.synopsys.integration.detectable.detectables.npm.lockfile.model.PackageLockDependency)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1