Browse Source

Auto stash before merge of "master" and "origin/master"

Wilfried Klaas 6 years ago
parent
commit
07e8edcfe4
1 changed files with 7 additions and 1 deletions
  1. 7 1
      src/main/java/de/mcs/utils/jsap/CommandlineProcessor.java

+ 7 - 1
src/main/java/de/mcs/utils/jsap/CommandlineProcessor.java

@@ -21,6 +21,7 @@
  */
 package de.mcs.utils.jsap;
 
+import java.io.File;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -72,7 +73,12 @@ public class CommandlineProcessor {
     FileOption annotation = method.getAnnotation(FileOption.class);
     if (annotation != null) {
       try {
-        method.invoke(null, commandLineArgs.getFile(annotation.name()));
+        if (commandLineArgs.contains(annotation.name())) {
+          File file = commandLineArgs.getFile(annotation.name());
+          if ((file.getName() != null) && !"".equals(file.getName())) {
+            method.invoke(null, file);
+          }
+        }
       } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e1) {
         e1.printStackTrace();
       }