java/sql-dk/src/main/java/info/globalcode/sql/dk/InvalidOptionsException.java
author František Kučera <franta-hg@frantovo.cz>
Thu, 24 Oct 2019 21:43:08 +0200
branchv_0
changeset 250 aae5009bd0af
parent 238 4a1864c3e867
permissions -rw-r--r--
fix license version: GNU GPLv3
franta-hg@16
     1
/**
franta-hg@16
     2
 * SQL-DK
franta-hg@16
     3
 * Copyright © 2013 František Kučera (frantovo.cz)
franta-hg@16
     4
 *
franta-hg@16
     5
 * This program is free software: you can redistribute it and/or modify
franta-hg@16
     6
 * it under the terms of the GNU General Public License as published by
franta-hg@250
     7
 * the Free Software Foundation, version 3 of the License.
franta-hg@16
     8
 *
franta-hg@16
     9
 * This program is distributed in the hope that it will be useful,
franta-hg@16
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
franta-hg@16
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
franta-hg@16
    12
 * GNU General Public License for more details.
franta-hg@16
    13
 *
franta-hg@16
    14
 * You should have received a copy of the GNU General Public License
franta-hg@16
    15
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
franta-hg@16
    16
 */
franta-hg@1
    17
package info.globalcode.sql.dk;
franta-hg@1
    18
franta-hg@1
    19
import java.util.ArrayList;
franta-hg@1
    20
import java.util.Collection;
franta-hg@1
    21
import java.util.Collections;
franta-hg@1
    22
franta-hg@1
    23
/**
franta-hg@1
    24
 *
franta-hg@1
    25
 * @author Ing. František Kučera (frantovo.cz)
franta-hg@1
    26
 */
franta-hg@1
    27
public class InvalidOptionsException extends Exception {
franta-hg@1
    28
franta-hg@1
    29
	private final Collection<OptionProblem> problems = new ArrayList<>();
franta-hg@1
    30
franta-hg@1
    31
	public Collection<OptionProblem> getProblems() {
franta-hg@1
    32
		return Collections.unmodifiableCollection(problems);
franta-hg@1
    33
	}
franta-hg@1
    34
franta-hg@1
    35
	public void addProblem(OptionProblem p) {
franta-hg@1
    36
		problems.add(p);
franta-hg@1
    37
	}
franta-hg@1
    38
franta-hg@1
    39
	public boolean hasProblems() {
franta-hg@1
    40
		return !problems.isEmpty();
franta-hg@1
    41
	}
franta-hg@1
    42
franta-hg@1
    43
	public static class OptionProblem {
franta-hg@1
    44
franta-hg@1
    45
		private String description;
franta-hg@63
    46
		private Throwable exception;
franta-hg@1
    47
franta-hg@1
    48
		public OptionProblem(String description) {
franta-hg@1
    49
			this.description = description;
franta-hg@1
    50
		}
franta-hg@1
    51
franta-hg@63
    52
		public OptionProblem(String description, Throwable exception) {
franta-hg@63
    53
			this.description = description;
franta-hg@63
    54
			this.exception = exception;
franta-hg@63
    55
		}
franta-hg@63
    56
franta-hg@1
    57
		public String getDescription() {
franta-hg@1
    58
			return description;
franta-hg@1
    59
		}
franta-hg@63
    60
franta-hg@63
    61
		public Throwable getException() {
franta-hg@63
    62
			return exception;
franta-hg@63
    63
		}
franta-hg@1
    64
	}
franta-hg@1
    65
}