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