java/sql-dk/src/main/java/info/globalcode/sql/dk/InvalidOptionsException.java
branchv_0
changeset 238 4a1864c3e867
parent 63 3b9ec9c23a37
child 250 aae5009bd0af
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/java/sql-dk/src/main/java/info/globalcode/sql/dk/InvalidOptionsException.java	Mon Mar 04 20:15:24 2019 +0100
     1.3 @@ -0,0 +1,66 @@
     1.4 +/**
     1.5 + * SQL-DK
     1.6 + * Copyright © 2013 František Kučera (frantovo.cz)
     1.7 + *
     1.8 + * This program is free software: you can redistribute it and/or modify
     1.9 + * it under the terms of the GNU General Public License as published by
    1.10 + * the Free Software Foundation, either version 3 of the License, or
    1.11 + * (at your option) any later version.
    1.12 + *
    1.13 + * This program is distributed in the hope that it will be useful,
    1.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    1.16 + * GNU General Public License for more details.
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License
    1.19 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
    1.20 + */
    1.21 +package info.globalcode.sql.dk;
    1.22 +
    1.23 +import java.util.ArrayList;
    1.24 +import java.util.Collection;
    1.25 +import java.util.Collections;
    1.26 +
    1.27 +/**
    1.28 + *
    1.29 + * @author Ing. František Kučera (frantovo.cz)
    1.30 + */
    1.31 +public class InvalidOptionsException extends Exception {
    1.32 +
    1.33 +	private final Collection<OptionProblem> problems = new ArrayList<>();
    1.34 +
    1.35 +	public Collection<OptionProblem> getProblems() {
    1.36 +		return Collections.unmodifiableCollection(problems);
    1.37 +	}
    1.38 +
    1.39 +	public void addProblem(OptionProblem p) {
    1.40 +		problems.add(p);
    1.41 +	}
    1.42 +
    1.43 +	public boolean hasProblems() {
    1.44 +		return !problems.isEmpty();
    1.45 +	}
    1.46 +
    1.47 +	public static class OptionProblem {
    1.48 +
    1.49 +		private String description;
    1.50 +		private Throwable exception;
    1.51 +
    1.52 +		public OptionProblem(String description) {
    1.53 +			this.description = description;
    1.54 +		}
    1.55 +
    1.56 +		public OptionProblem(String description, Throwable exception) {
    1.57 +			this.description = description;
    1.58 +			this.exception = exception;
    1.59 +		}
    1.60 +
    1.61 +		public String getDescription() {
    1.62 +			return description;
    1.63 +		}
    1.64 +
    1.65 +		public Throwable getException() {
    1.66 +			return exception;
    1.67 +		}
    1.68 +	}
    1.69 +}