public LinePath build()

in commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/path/LinePath.java [693:732]


        public LinePath build(final boolean close) {
            if (close) {
                closePath();
            }

            // combine all of the line subsets
            List<LineConvexSubset> result = null;

            if (prepended != null) {
                result = prepended;
                Collections.reverse(result);
            }

            if (appended != null) {
                if (result == null) {
                    result = appended;
                } else {
                    result.addAll(appended);
                }
            }

            if (result == null) {
                result = Collections.emptyList();
            }

            if (result.isEmpty() && startVertex != null) {
                throw new IllegalStateException(
                        MessageFormat.format("Unable to create line path; only a single unique vertex provided: {0} ",
                                startVertex));
            }

            // clear internal state
            appended = null;
            prepended = null;

            // build the final path instance, using the shared empty instance if
            // no line subsets are present

            return result.isEmpty() ? empty() : new LinePath(result);
        }