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 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) {
        final Node parent = node.getParent();
        // if node has no parent, then "" is the path
        if (parent == null) {
            return "";
        }
        // if node's parent is base, then node is the path
        if (parent.equals(base)) {
            return node.getData().getName();
        }
        // else append to parent path
        final StringBuilder path = new StringBuilder();
        return path
                .append(getPath(parent, base, delimiter))
                .append(delimiter)
                .append(node.getData().getName())
                .toString();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy