in commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatArcPath.java [513:551]
public GreatArcPath build(final boolean close) {
if (close) {
closePath();
}
// combine all of the arcs
List<GreatArc> result = null;
if (prependedArcs != null) {
result = prependedArcs;
Collections.reverse(result);
}
if (appendedArcs != null) {
if (result == null) {
result = appendedArcs;
} else {
result.addAll(appendedArcs);
}
}
if (result == null) {
result = Collections.emptyList();
}
if (result.isEmpty() && startVertex != null) {
throw new IllegalStateException(
MessageFormat.format("Unable to create path; only a single point provided: {0}",
startVertex));
}
// clear internal state
appendedArcs = null;
prependedArcs = null;
// build the final path instance, using the shared empty instance if
// no arcs are present
return result.isEmpty() ? empty() : new GreatArcPath(result);
}