1 package info.globalcode.sql.dk;
3 import static info.globalcode.sql.dk.Functions.isNotEmpty;
4 import java.util.ArrayList;
5 import java.util.Collection;
10 * @author Ing. František Kučera (frantovo.cz)
12 public class CLIOptions {
15 private String databaseName;
16 private boolean batch;
19 public enum COMMAND_TYPE {
23 /** INSERT, UPDATE, DELETE */
26 private COMMAND_TYPE commandType;
27 private final Collection<NamedParameter> namedParameters = new ArrayList<>();
28 private final List<Parameter> numberedParameters = new ArrayList<>();
30 public void validate() throws InvalidOptionsException {
31 InvalidOptionsException e = new InvalidOptionsException();
34 (hasDb() ? 1 : 0) + //
35 (hasSql() ? 1 : 0) + //
39 e.addProblem(new InvalidOptionsException.OptionProblem("Invalid combination of DB, SQL and BATCH – please specify just 2 of this 3 options"));
42 if (!namedParameters.isEmpty() && !numberedParameters.isEmpty()) {
43 e.addProblem(new InvalidOptionsException.OptionProblem("Named and numbered parameters can not be used together in one command."));
47 if (e.hasProblems()) {
52 public boolean hasSql() {
53 return isNotEmpty(sql, true);
56 public boolean hasDb() {
57 return isNotEmpty(databaseName, true);
60 public boolean hasBatch() {