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

poussecafe.doc.AggregateGraphPath Maven / Gradle / Ivy

There is a newer version: 0.29.0
Show newest version
package poussecafe.doc;

import java.util.ArrayList;
import java.util.List;

import static java.util.stream.Collectors.joining;

public class AggregateGraphPath {

    public AggregateGraphPath with(String name) {
        AggregateGraphPath newPath = new AggregateGraphPath();
        newPath.names = new ArrayList<>(names);
        newPath.addName(name);
        return newPath;
    }

    private List names = new ArrayList<>();

    private void addName(String name) {
        names.add(name);
    }

    public String formatNames() {
        return formatPath(names);
    }

    private String formatPath(List newPath) {
        return newPath.stream().collect(joining(" -> "));
    }

    public String lastName() {
        return names.get(names.size() - 1);
    }

    public String formatNamesWith(String newNodeName) {
        List newNames = new ArrayList<>(names);
        newNames.add(newNodeName);
        return formatPath(newNames);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy