1 | package de.uka.ipd.sdq.reliability.solver.reporting; |
2 | |
3 | import java.util.ArrayList; |
4 | import java.util.List; |
5 | |
6 | /** |
7 | * Class used for aggregation of failure probabilities according to an entity. |
8 | * An entity may be a component's ID, a component's interface ID, a component's |
9 | * signature ID, etc. |
10 | * |
11 | * @author Daniel Patejdl |
12 | * |
13 | */ |
14 | public class ImpactAnalysisFailureProbabilityAggregation { |
15 | /** |
16 | * A list of identification strings that make up the entire identifier and |
17 | * uniquely identify this instance. |
18 | */ |
19 | private List<String> entityIdentifiers; |
20 | |
21 | /** |
22 | * The entity's name parts. The entity's name is made up of its single |
23 | * parts. |
24 | */ |
25 | private List<String> entityNameParts; |
26 | |
27 | /** |
28 | * The failure probability aggregation type. |
29 | */ |
30 | ImpactAnalysisFailureType failureAggregationType; |
31 | |
32 | /** |
33 | * The aggregated failure probability of the entity. |
34 | */ |
35 | private double failureProbability; |
36 | |
37 | /** |
38 | * Creates a new failure probability aggregation instance. |
39 | * |
40 | * @param failureAggregationType |
41 | * the failure probability aggregation type of the entity |
42 | * @param entityIdentifiers |
43 | * the entity's identification strings list |
44 | * @param entityNameParts |
45 | * the entity's name parts; the entity's name is made up of its |
46 | * single parts |
47 | * @param failureProbability |
48 | * the failure probability of the entity |
49 | */ |
50 | public ImpactAnalysisFailureProbabilityAggregation( |
51 | ImpactAnalysisFailureType failureAggregationType, |
52 | List<String> entityIdentifiers, List<String> entityNameParts, |
53 | double failureProbability) { |
54 | this.failureAggregationType = failureAggregationType; |
55 | this.entityIdentifiers = new ArrayList<String>(entityIdentifiers.size()); |
56 | for (String identifier : entityIdentifiers) { |
57 | this.entityIdentifiers.add(identifier); |
58 | } |
59 | this.entityNameParts = new ArrayList<String>(entityNameParts); |
60 | this.failureProbability = failureProbability; |
61 | } |
62 | |
63 | /** |
64 | * Adds to the current entity's aggregated failure probability additional |
65 | * failure probability. |
66 | * |
67 | * @param failureProbability |
68 | * the failure probability to be added to the existing one |
69 | */ |
70 | public void addToFailureProbabilityBy(double failureProbability) { |
71 | this.failureProbability += failureProbability; |
72 | } |
73 | |
74 | /** |
75 | * Compares this instance's failure probability aggregation type and |
76 | * identification strings List to the given type and identification strings, |
77 | * respectively. |
78 | * |
79 | * @param otherEntityType |
80 | * the other entity's failure probability aggregation type |
81 | * @param otherEntityIdentifiers |
82 | * the other entitity's identification strings List |
83 | * @return <code>true</code>, if both types and identification strings match |
84 | * each other, <code>false</code> otherwise |
85 | */ |
86 | public boolean compareToIdentifier( |
87 | ImpactAnalysisFailureType otherEntityType, |
88 | List<String> otherEntityIdentifiers) { |
89 | if (failureAggregationType == otherEntityType |
90 | && entityIdentifiers.size() == otherEntityIdentifiers.size()) { |
91 | for (int i = 0; i < entityIdentifiers.size(); i++) { |
92 | if (entityIdentifiers.get(i).equals( |
93 | otherEntityIdentifiers.get(i))) { |
94 | continue; |
95 | } else { |
96 | return false; // at least one identification string does not |
97 | // match the other, |
98 | // so the overall IDs must be different as well |
99 | } |
100 | } |
101 | } else { |
102 | return false; // type and/or list size already don't match, so |
103 | // they're different identifiers |
104 | } |
105 | return true; |
106 | } |
107 | |
108 | /** |
109 | * Retrieves the identification strings List of the entity. |
110 | * |
111 | * @return the identification strings List |
112 | */ |
113 | public List<String> getEntityIdentifiers() { |
114 | return entityIdentifiers; |
115 | } |
116 | |
117 | /** |
118 | * Retrieves the name parts of the entity. The entity's name is made up of |
119 | * its single parts. |
120 | * |
121 | * @return the name parts of the entity |
122 | */ |
123 | public List<String> getEntityNameParts() { |
124 | return entityNameParts; |
125 | } |
126 | |
127 | /** |
128 | * Retrieves the entity's aggregated failure probability. |
129 | * |
130 | * @return the entity's aggregated failure probability |
131 | */ |
132 | public double getFailureProbability() { |
133 | return failureProbability; |
134 | } |
135 | |
136 | /** |
137 | * Returns the failure probability aggregation type. |
138 | * |
139 | * @return the failure probability aggregation type |
140 | */ |
141 | public ImpactAnalysisFailureType getType() { |
142 | return failureAggregationType; |
143 | } |
144 | |
145 | /** |
146 | * Sets the identification strings List of the entity. |
147 | * |
148 | * @param entityIdentifier |
149 | * the identification strings List |
150 | */ |
151 | public void setEntityIdentifiers(List<String> entityIdentifiers) { |
152 | this.entityIdentifiers = entityIdentifiers; |
153 | } |
154 | |
155 | /** |
156 | * Sets the name parts of the entity. The entity's name is made up of its |
157 | * single parts. |
158 | * |
159 | * @param entityNameParts |
160 | * the name parts of the entity |
161 | */ |
162 | public void setEntityNameParts(List<String> entityNameParts) { |
163 | this.entityNameParts = entityNameParts; |
164 | } |
165 | |
166 | /** |
167 | * Sets the entity's aggregated failure probability. |
168 | * |
169 | * @param failureProbability |
170 | * the entity's aggregated failure probability |
171 | */ |
172 | public void setFailureProbability(double failureProbability) { |
173 | this.failureProbability = failureProbability; |
174 | } |
175 | |
176 | /** |
177 | * Sets the failure probability aggregation type. |
178 | * |
179 | * @param failureAggregationType |
180 | * the failure probability aggregation type |
181 | */ |
182 | public void setType(ImpactAnalysisFailureType failureAggregationType) { |
183 | this.failureAggregationType = failureAggregationType; |
184 | } |
185 | } |