X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fcommons%2Fcommandline%2Fparameterparser%2FParameter.java;h=bc8db0e9b40c5c28743d51c1de1ac48ffe72f0a8;hb=57ac589c5bb0860921e6f75e26a76958b76ac244;hp=d55407b3ecfa0be7ca9e10aa7a88ea30dbc99a3f;hpb=41647e2ea4fbbe65049d79c6b2bc73ecdd2a193c;p=svjatoslav_commons.git diff --git a/src/main/java/eu/svjatoslav/commons/commandline/parameterparser/Parameter.java b/src/main/java/eu/svjatoslav/commons/commandline/parameterparser/Parameter.java index d55407b..bc8db0e 100755 --- a/src/main/java/eu/svjatoslav/commons/commandline/parameterparser/Parameter.java +++ b/src/main/java/eu/svjatoslav/commons/commandline/parameterparser/Parameter.java @@ -11,13 +11,20 @@ package eu.svjatoslav.commons.commandline.parameterparser; import java.util.ArrayList; import java.util.Collections; +import java.util.List; public abstract class Parameter { - public String description; - public final ArrayList arguments = new ArrayList<>(); - ArgumentCount argumentCount; - private final ArrayList aliases = new ArrayList<>(); + /** + * Purpose of this argument, like: input image path, compression level, etc... + * + * Note: for describing argument type (file, integer, ...) there is {@link #describeFormat()}. + */ + public final String description; + + public final List arguments = new ArrayList<>(); + final ArgumentCount argumentCount; + private final List aliases = new ArrayList<>(); /** * Indicates that at least one argument is mandatory for this parameter. */ @@ -52,7 +59,7 @@ public abstract class Parameter { // save aliases Collections.addAll(aliases, aliasArray); - return (I)this; + return (I) this; } /** @@ -92,7 +99,10 @@ public abstract class Parameter { } /** - * @return Single line argument type description. + * @return Single line argument type description. If argument type should be file, + * date, integer, regular expression, etc.. + * + * Note: for argument purpose description there is {@link #description} */ public abstract String describeFormat(); @@ -116,7 +126,11 @@ public abstract class Parameter { // first line buffer.append(getAliases()); if (!argumentCount.equals(ArgumentCount.NONE)) { - buffer.append(" (" + describeFormat() + ")"); + buffer + .append(" (") + .append(isMandatory() ? "mandatory, " : "") + .append(describeFormat()) + .append(")"); if (argumentCount.equals(ArgumentCount.MULTI)) buffer.append("..."); @@ -182,7 +196,7 @@ public abstract class Parameter { @SuppressWarnings("unchecked") public I setMandatory() { mandatory = true; - return (I)this; + return (I) this; } /**