Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
LicenseTemplateException |
|
| 1.0;1 |
1 | /** | |
2 | * Licensed to the Apache Software Foundation (ASF) under one | |
3 | * or more contributor license agreements. See the NOTICE file | |
4 | * distributed with this work for additional information | |
5 | * regarding copyright ownership. The ASF licenses this file | |
6 | * to you under the Apache License, Version 2.0 (the | |
7 | * "License"); you may not use this file except in compliance | |
8 | * with the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, | |
13 | * software distributed under the License is distributed on an | |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
15 | * KIND, either express or implied. See the License for the | |
16 | * specific language governing permissions and limitations | |
17 | * under the License. | |
18 | */ | |
19 | package org.apache.creadur.whisker.model; | |
20 | ||
21 | import java.util.Collection; | |
22 | import java.util.Map; | |
23 | ||
24 | /** | |
25 | * Indicates that generating an instance of a license | |
26 | * from the template (for the license family) has failed. | |
27 | */ | |
28 | public class LicenseTemplateException extends Exception { | |
29 | ||
30 | /** Exception are serializable, so provide a SUID. */ | |
31 | private static final long serialVersionUID = -4085365930968672572L; | |
32 | ||
33 | /** | |
34 | * Builds an instance. | |
35 | * @param parameters not null | |
36 | * @param name not null | |
37 | * @return not null | |
38 | */ | |
39 | public static LicenseTemplateException notLicenseTemplate( | |
40 | final Map<String, String> parameters, final String name) { | |
41 | 0 | return new LicenseTemplateException("This is not a templated license", |
42 | parameters, name); | |
43 | } | |
44 | ||
45 | /** | |
46 | * Constructs an instance. | |
47 | * @param message not null | |
48 | * @param parameters parameters passed | |
49 | * @param name license name | |
50 | */ | |
51 | public LicenseTemplateException(final String message, | |
52 | final Map<String, String> parameters, final String name) { | |
53 | // TODO: improve reporting | |
54 | 0 | super(message); |
55 | 0 | } |
56 | ||
57 | /** | |
58 | * Constructs an instance. | |
59 | * @param message not null | |
60 | * @param expectedParameters not null | |
61 | * @param actualParameters not null | |
62 | */ | |
63 | public LicenseTemplateException(final String message, | |
64 | final Collection<String> expectedParameters, | |
65 | final Collection<String> actualParameters) { | |
66 | // TODO improve reporting | |
67 | 0 | super(message); |
68 | 0 | } |
69 | ||
70 | /** | |
71 | * Constructs an instance | |
72 | * @param message not null | |
73 | * @param name not null | |
74 | */ | |
75 | public LicenseTemplateException(final String message, final String name) { | |
76 | // TODO improve reporting | |
77 | 0 | super(message); |
78 | 0 | } |
79 | ||
80 | /** | |
81 | * Builds an exception indicating that parameter passed | |
82 | * do not fulfill expectations. | |
83 | * @param expectedParameters not null | |
84 | * @param actualParameters not null | |
85 | * @return not null | |
86 | */ | |
87 | public static LicenseTemplateException parameterMismatch( | |
88 | final Collection<String> expectedParameters, | |
89 | final Collection<String> actualParameters) { | |
90 | 0 | return new LicenseTemplateException("Parameter mismatch.", |
91 | expectedParameters, actualParameters); | |
92 | } | |
93 | ||
94 | /** | |
95 | * Builds an exception indicating that duplicate parameter | |
96 | * names have been passed. | |
97 | * @param name names the parameter duplicated, not null | |
98 | * @return not null | |
99 | */ | |
100 | public static LicenseTemplateException duplicateParameterName( | |
101 | final String name) { | |
102 | 0 | return new LicenseTemplateException("Duplicate parameter name.", name); |
103 | } | |
104 | ||
105 | } |