* {@link KamNode#getKam() node's KAM})
*/
protected SimplePath(final Kam kam, final KamNode source,
final KamNode target, final List<KamEdge> edges) {
if (kam == null) {
throw new InvalidArgument("kam", kam);
}
if (source == null) {
throw new InvalidArgument("source", source);
}
if (edges == null) {
throw new InvalidArgument("edges", edges);
}
if (!kam.equals(source.getKam())) {
throw new InvalidArgument(
"Source node must be part of the Path Kam");
}
this.kam = kam;
this.source = source;
this.target = target;
if (target != null && !kam.equals(target.getKam())) {
throw new InvalidArgument(
"Target node must be part of the Path Kam");
}
if (target == null && !edges.isEmpty()) {
throw new InvalidArgument(
"Cannot add edges to a Path with a null target");
}
List<KamEdge> kamEdges = new ArrayList<KamEdge>(edges.size());
for (KamEdge e : edges) {
if (!kam.equals(e.getKam())) {
throw new InvalidArgument("Edge must be part of the Path Kam");
}
kamEdges.add(e);
}
this.edgeList = Collections.unmodifiableList(kamEdges);
}