From 63af3357667726a86f2a5d3ecfb82d51d5120921 Mon Sep 17 00:00:00 2001
From: Georg Seibt <seibt@fim.uni-passau.de>
Date: Wed, 20 Apr 2016 23:08:32 +0200
Subject: [PATCH] doc, ensure the isSane() method only performs its checks once
 (if it returned successful)

---
 .../seibt/gitwrapper/process/ToolWrapper.java | 31 ++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/src/de/uni_passau/fim/seibt/gitwrapper/process/ToolWrapper.java b/src/de/uni_passau/fim/seibt/gitwrapper/process/ToolWrapper.java
index 8c46299..df8a0ed 100644
--- a/src/de/uni_passau/fim/seibt/gitwrapper/process/ToolWrapper.java
+++ b/src/de/uni_passau/fim/seibt/gitwrapper/process/ToolWrapper.java
@@ -7,11 +7,23 @@ import java.util.Optional;
 
 import de.uni_passau.fim.seibt.gitwrapper.process.ProcessExecutor.ExecRes;
 
+/**
+ * Abstract superclass of all wrappers for external tools.
+ */
 public abstract class ToolWrapper {
 
     protected String cmd;
 
-    public ToolWrapper(String cmd) throws ToolNotWorkingException {
+    /**
+     * Constructs a new {@link ToolWrapper} wrapping the given external command <code>cmd</code>. Calls
+     * {@link #isWorking()} and throws a {@link ToolNotWorkingException} if it returns <code>false</code>.
+     *
+     * @param cmd
+     *         the external command to wrap
+     * @throws ToolNotWorkingException
+     *         if {@link #isWorking()} returns <code>false</code>
+     */
+    protected ToolWrapper(String cmd) throws ToolNotWorkingException {
         this.cmd = cmd;
 
         if (!isWorking()) {
@@ -19,8 +31,25 @@ public abstract class ToolWrapper {
         }
     }
 
+    /**
+     * Determines whether the wrapped command is working as expected.
+     *
+     * @return true iff the command is working
+     */
     protected abstract boolean isWorking();
 
+    /**
+     * Prepends the wrapped external command to (a copy of) the <code>parameters</code> and calls
+     * {@link ProcessExecutor#exec(File, boolean, List)}.
+     *
+     * @param workingDir
+     *         the working directory for the execution
+     * @param redirectError
+     *         whether to merge the standard output and error streams
+     * @param parameters
+     *         the parameters for the external command
+     * @return the result of the execution or an empty {@link Optional} if there is an exception executing the command
+     */
     protected Optional<ExecRes> exec(File workingDir, boolean redirectError, List<String> parameters) {
         LinkedList<String> pars = new LinkedList<>(parameters);
         pars.addFirst(cmd);
-- 
GitLab