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