Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
DuplicatePropertyDeclarationsException |
|
|
1.25;1.25 |
1 | /* |
|
2 | * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH |
|
3 | * |
|
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | * you may not use this file except in compliance with the License. |
|
6 | * You may obtain a copy of the License at |
|
7 | * |
|
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 | * |
|
10 | * Unless required by applicable law or agreed to in writing, software |
|
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 | * See the License for the specific language governing permissions and |
|
14 | * limitations under the License. |
|
15 | */ |
|
16 | package de.smartics.properties.api.core.domain; |
|
17 | ||
18 | import java.util.List; |
|
19 | ||
20 | import de.smartics.exceptions.i18n.message.MessageParam; |
|
21 | import de.smartics.properties.api.core.app.PropertyRootException; |
|
22 | ||
23 | /** |
|
24 | * Signals that a set of property descriptor has been encountered twice. |
|
25 | */ |
|
26 | public class DuplicatePropertyDeclarationsException extends |
|
27 | PropertyRootException |
|
28 | { |
|
29 | // ********************************* Fields ********************************* |
|
30 | ||
31 | // --- constants ------------------------------------------------------------ |
|
32 | ||
33 | /** |
|
34 | * The class version identifier. |
|
35 | * <p> |
|
36 | * The value of this constant is {@value}. |
|
37 | * </p> |
|
38 | */ |
|
39 | private static final long serialVersionUID = 1L; |
|
40 | ||
41 | // --- members -------------------------------------------------------------- |
|
42 | ||
43 | /** |
|
44 | * The list of property declarations of declaration collisions. This is where |
|
45 | * two interfaces declare properties with identical keys. |
|
46 | * |
|
47 | * @serial |
|
48 | */ |
|
49 | private final List<DuplicatePropertyDeclarationException> exceptions; |
|
50 | ||
51 | /** |
|
52 | * The summary of exception. |
|
53 | * |
|
54 | * @serial |
|
55 | */ |
|
56 | @MessageParam |
|
57 | private final String exceptionsMessage; // NOPMD |
|
58 | ||
59 | // ****************************** Initializer ******************************* |
|
60 | ||
61 | // ****************************** Constructors ****************************** |
|
62 | ||
63 | /** |
|
64 | * Default constructor. |
|
65 | * |
|
66 | * @param exceptions the list of property declarations of declaration |
|
67 | * collisions. |
|
68 | */ |
|
69 | public DuplicatePropertyDeclarationsException( |
|
70 | final List<DuplicatePropertyDeclarationException> exceptions) |
|
71 | { |
|
72 | 0 | super(PropertyCode.DUPLICATE_DECLARATIONS); |
73 | 0 | this.exceptions = exceptions; |
74 | 0 | this.exceptionsMessage = createMessage(exceptions); |
75 | 0 | } |
76 | ||
77 | // ****************************** Inner Classes ***************************** |
|
78 | ||
79 | // ********************************* Methods ******************************** |
|
80 | ||
81 | // --- init ----------------------------------------------------------------- |
|
82 | ||
83 | private static String createMessage( |
|
84 | final List<DuplicatePropertyDeclarationException> exceptions) |
|
85 | { |
|
86 | 0 | final StringBuilder buffer = new StringBuilder(128); |
87 | 0 | for (final DuplicatePropertyDeclarationException e : exceptions) |
88 | { |
|
89 | 0 | buffer.append("\n ").append(e.getLocalizedMessage()); |
90 | } |
|
91 | 0 | return buffer.toString(); |
92 | } |
|
93 | ||
94 | // --- get&set -------------------------------------------------------------- |
|
95 | ||
96 | /** |
|
97 | * Returns the list of property declarations of declaration collisions. This |
|
98 | * is where two interfaces declare properties with identical keys. |
|
99 | * |
|
100 | * @return the list of property declarations of declaration collisions. |
|
101 | */ |
|
102 | public final List<DuplicatePropertyDeclarationException> getExceptions() |
|
103 | { |
|
104 | 0 | return exceptions; |
105 | } |
|
106 | ||
107 | /** |
|
108 | * Returns the count of duplicate property declarations. |
|
109 | * |
|
110 | * @return the count of duplicate property declarations. |
|
111 | */ |
|
112 | @MessageParam("duplicateCount") |
|
113 | public final int getDuplicateCount() |
|
114 | { |
|
115 | 0 | return exceptions.size(); |
116 | } |
|
117 | ||
118 | // --- business ------------------------------------------------------------- |
|
119 | ||
120 | // --- object basics -------------------------------------------------------- |
|
121 | ||
122 | } |