More constructors for ArgSetting

This commit is contained in:
Magnus Ulf 2015-05-12 16:25:12 +02:00 committed by Olof Larsson
parent 057b827db0
commit 419f0c608d
2 changed files with 33 additions and 10 deletions

View File

@ -52,19 +52,42 @@ public class ArgSetting
// To minimize confusion and mixing of arguments for the constructor // To minimize confusion and mixing of arguments for the constructor
// description must not be set in the constructor. // description must not be set in the constructor.
// With default option and required from console. // All
public ArgSetting(AR<?> reader, boolean requiredFromConsole, String name, String def) public ArgSetting(AR<?> reader, boolean requiredFromConsole, String name, String def)
{ {
// Null checks
if (reader == null) throw new IllegalArgumentException("reader mustn't be null");
if (name == null) throw new IllegalArgumentException("name mustn't be null");
this.setReader(reader); this.setReader(reader);
this.setRequiredFromConsole(requiredFromConsole); this.setRequiredFromConsole(requiredFromConsole);
this.setName(name); this.setName(name);
this.setDefault(def); this.setDefault(def);
} }
// Without reqFromConsole.
public ArgSetting(AR<?> reader, String name, String def)
{
this(reader, false, name, def);
}
// Without default.
public ArgSetting(AR<?> reader, boolean requiredFromConsole, String name)
{
this(reader, requiredFromConsole, name, null);
}
// Without reqFromConsole and default.
public ArgSetting (AR<?> reader, String name)
{
this(reader, false, name, null);
}
// -------------------------------------------- // // -------------------------------------------- //
// STATIC FACTORY // STATIC FACTORY
// -------------------------------------------- // // -------------------------------------------- //
@Deprecated
public static ArgSetting of(AR<?> reader, boolean requiredFromConsole, String name, String def) public static ArgSetting of(AR<?> reader, boolean requiredFromConsole, String name, String def)
{ {
// Null checks // Null checks
@ -110,7 +133,7 @@ public class ArgSetting
{ {
// We can't use a singletone, because people might // We can't use a singletone, because people might
// want to set a description. // want to set a description.
return ArgSetting.of(ARInteger.get(), false, "page", "1"); return new ArgSetting(ARInteger.get(), "page", "1");
} }
} }

View File

@ -237,49 +237,49 @@ public class MassiveCommand
// All // All
public ArgSetting addArg(AR<?> reader, boolean requiredFromConsole, String name, String def, boolean concatFromHere) public ArgSetting addArg(AR<?> reader, boolean requiredFromConsole, String name, String def, boolean concatFromHere)
{ {
return this.addArg(ArgSetting.of(reader, requiredFromConsole, name, def), concatFromHere); return this.addArg(new ArgSetting(reader, requiredFromConsole, name, def), concatFromHere);
} }
// Without concat. // Without concat.
public ArgSetting addArg(AR<?> reader, boolean requiredFromConsole, String name, String def) public ArgSetting addArg(AR<?> reader, boolean requiredFromConsole, String name, String def)
{ {
return this.addArg(reader, requiredFromConsole, name, def, false); return this.addArg(new ArgSetting(reader, requiredFromConsole, name, def), false);
} }
// Without reqFromConsole. // Without reqFromConsole.
public ArgSetting addArg(AR<?> reader, String name, String def, boolean concatFromHere) public ArgSetting addArg(AR<?> reader, String name, String def, boolean concatFromHere)
{ {
return this.addArg(reader, false, name, def, concatFromHere); return this.addArg(new ArgSetting(reader, name, def), concatFromHere);
} }
// Without default. // Without default.
public ArgSetting addArg(AR<?> reader, boolean requiredFromConsole, String name, boolean concatFromHere) public ArgSetting addArg(AR<?> reader, boolean requiredFromConsole, String name, boolean concatFromHere)
{ {
return this.addArg(reader, requiredFromConsole, name, null, concatFromHere); return this.addArg(new ArgSetting(reader, requiredFromConsole, name), concatFromHere);
} }
// Without concat & reqFromConsole. // Without concat & reqFromConsole.
public ArgSetting addArg(AR<?> reader, String name, String def) public ArgSetting addArg(AR<?> reader, String name, String def)
{ {
return this.addArg(reader, false, name, def, false); return this.addArg(new ArgSetting(reader, name, def), false);
} }
// Without concat and default. // Without concat and default.
public ArgSetting addArg(AR<?> reader, boolean requiredFromConsole, String name) public ArgSetting addArg(AR<?> reader, boolean requiredFromConsole, String name)
{ {
return this.addArg(reader, requiredFromConsole, name, null, false); return this.addArg(new ArgSetting(reader, requiredFromConsole, name), false);
} }
// Without reqFromConsole and default. // Without reqFromConsole and default.
public ArgSetting addArg(AR<?> reader, String name, boolean concatFromHere) public ArgSetting addArg(AR<?> reader, String name, boolean concatFromHere)
{ {
return this.addArg(reader, false, name, null, concatFromHere); return this.addArg(new ArgSetting(reader, name), concatFromHere);
} }
// Without concat, reqFromConsole and default. // Without concat, reqFromConsole and default.
public ArgSetting addArg(AR<?> reader, String name) public ArgSetting addArg(AR<?> reader, String name)
{ {
return this.addArg(reader, false, name, null, false); return this.addArg(new ArgSetting(reader, name), false);
} }
// FIELD: requiredArgs // FIELD: requiredArgs