All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.kemitix.dependency.digraph.maven.plugin.DefaultNodePathGenerator Maven / Gradle / Ivy

There is a newer version: 0.9.1
Show newest version
package net.kemitix.dependency.digraph.maven.plugin;

import lombok.val;

import net.kemitix.node.Node;

/**
 * Default implementation of the Node ID Generator.
 *
 * @author Paul Campbell
 */
class DefaultNodePathGenerator implements NodePathGenerator {

    @Override
    public String getPath(
            final Node node, final Node base,
            final String delimiter) {
        val path = new StringBuilder();
        node.getData()
            .map(PackageData::getName)
            .ifPresent(name -> node.getParent().ifPresent(parent -> {
                if (!parent.equals(base)) {
                    path.append(getPath(parent, base, delimiter))
                        .append(delimiter);
                }
                path.append(name);
            }));
        return path.toString();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy