File tree Expand file tree Collapse file tree 3 files changed +27
-6
lines changed
src/main/java/org/apposed/appose Expand file tree Collapse file tree 3 files changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -78,13 +78,26 @@ public interface Builder<T extends Builder<T>> {
7878 * using the current builder configuration. This is more robust than trying to
7979 * update an existing environment in place.
8080 * </p>
81+ * <p>
82+ * This method is a shorthand for {@link #delete()} then {@link #build()}.
83+ * </p>
8184 *
8285 * @return The newly rebuilt {@link Environment}.
8386 * @throws IOException If something goes wrong during rebuild.
8487 */
85- Environment rebuild () throws IOException ;
88+ default Environment rebuild () throws IOException {
89+ delete ();
90+ return build ();
91+ }
8692
8793 /**
94+ * Deletes the builder's linked environment directory, if any.
95+ *
96+ * @throws IOException If something goes wrong during deletion.
97+ */
98+ void delete () throws IOException ;
99+
100+ /**
88101 * Wraps an existing environment directory, detecting and using any
89102 * configuration files present for future rebuild() calls.
90103 * <p>
Original file line number Diff line number Diff line change @@ -87,6 +87,17 @@ default Environment rebuild() throws IOException {
8787 return builder ().rebuild ();
8888 }
8989
90+ /**
91+ * Deletes the existing environment directory, if any.
92+ *
93+ * @return This environment, for fluid chaining.
94+ * @throws IOException If something goes wrong during deletion.
95+ */
96+ default Environment delete () throws IOException {
97+ builder ().delete ();
98+ return this ;
99+ }
100+
90101 /**
91102 * Creates a Python script service.
92103 * <p>
Original file line number Diff line number Diff line change @@ -68,12 +68,9 @@ public abstract class BaseBuilder<T extends BaseBuilder<T>> implements Builder<T
6868 // -- Builder methods --
6969
7070 @ Override
71- public Environment rebuild () throws IOException {
71+ public void delete () throws IOException {
7272 File dir = envDir ();
73- if (dir .exists ()) {
74- FilePaths .deleteRecursively (dir );
75- }
76- return build ();
73+ if (dir .exists ()) FilePaths .deleteRecursively (dir );
7774 }
7875
7976 @ Override
You can’t perform that action at this time.
0 commit comments