X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fcommons%2Fcommandline%2Fparameterparser%2FParameter.java;h=1e738a5caa1d424b961ef52cbb5f8aced21619ba;hb=cf965fda534cc562368c9f2a3f34475e2519fcdc;hp=1575fcf0471a169004158dc3aa651971a4bbdbcb;hpb=6a9352a6edbeaa1a2b3dafc09e91f53ab1871e1c;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 1575fcf..1e738a5 100755 --- a/src/main/java/eu/svjatoslav/commons/commandline/parameterparser/Parameter.java +++ b/src/main/java/eu/svjatoslav/commons/commandline/parameterparser/Parameter.java @@ -1,6 +1,6 @@ /* * Svjatoslav Commons - shared library of common functionality. - * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * Copyright ©2012-2013, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public License @@ -51,9 +51,8 @@ public class Parameter { // save aliases { final ArrayList aliasesList = new ArrayList(); - for (final String alias : aliases) { + for (final String alias : aliases) aliasesList.add(alias); - } this.aliases = aliasesList; } @@ -112,26 +111,23 @@ public class Parameter { } public File getArgumentAsFile() { - if (arguments.size() != 1) { + if (arguments.size() != 1) throw new RuntimeException("Parameter " + description + " shall have exactly 1 argument."); - } return new File(arguments.get(0)); } public int getArgumentAsInteger() { - if (arguments.size() != 1) { + if (arguments.size() != 1) throw new RuntimeException("Parameter " + description + " shall have exactly 1 argument."); - } return Integer.parseInt(arguments.get(0)); } public String getArgumentAsString() { - if (arguments.size() != 1) { + if (arguments.size() != 1) throw new RuntimeException("Parameter " + description + " shall have exactly 1 argument."); - } return arguments.get(0); } @@ -149,9 +145,8 @@ public class Parameter { public List getArgumentsAsIntegers() { final ArrayList result = new ArrayList(); - for (final String argument : arguments) { + for (final String argument : arguments) result.add(Integer.valueOf(argument)); - } return result; } @@ -169,9 +164,8 @@ public class Parameter { if (enableArguments) { buffer.append(" (" + argumentType.describeFormat() + ")"); - if (enableMultipleArguments) { + if (enableMultipleArguments) buffer.append("..."); - } } buffer.append("\n");