Conditions | 7 |
Total Lines | 135 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | package it.cnr.istc.pst.platinum.ai.framework.time.solver.apsp; |
||
115 | @Override |
||
116 | public void notify(TemporalNetworkNotification info) |
||
117 | { |
||
118 | // check notification type |
||
119 | switch (info.getType()) |
||
120 | { |
||
121 | // temporal network initialized |
||
122 | // case INITIALIZATION: { |
||
123 | // |
||
124 | // // initialize data structures |
||
125 | // this.dg(); |
||
126 | // // set to propagate flag |
||
127 | // this.toPropagate = true; |
||
128 | // } |
||
129 | // break; |
||
130 | |||
131 | // temporal constraint added |
||
132 | // case ADD_REL: { |
||
133 | // |
||
134 | // // handle request |
||
135 | // AddRelationTemporalNetworkNotification notif = (AddRelationTemporalNetworkNotification) info; |
||
136 | // // check pairs of involved time points |
||
137 | // Map<TimePoint, Set<TimePoint>> p2p= new HashMap<>(); |
||
138 | // // check added constraints |
||
139 | // for (TimePointDistanceConstraint constraint : notif.getRels()) { |
||
140 | // // check time points |
||
141 | // if (!p2p.containsKey(constraint.getReference())) { |
||
142 | // p2p.put(constraint.getReference(), new HashSet<>()); |
||
143 | // } |
||
144 | // |
||
145 | // // add pair |
||
146 | // p2p.get(constraint.getReference()).add(constraint.getTarget()); |
||
147 | // } |
||
148 | // |
||
149 | // |
||
150 | // // update the internal distance graph |
||
151 | // for (TimePoint reference : p2p.keySet()) { |
||
152 | // for (TimePoint target : p2p.get(reference)) { |
||
153 | // |
||
154 | // // get constraint bounds |
||
155 | // long[] bounds = this.tn.getConstraintBounds(reference, target); |
||
156 | // // check if bound exists |
||
157 | // if (bounds != null) { |
||
158 | // // add/replace the associated edge of the distance graph |
||
159 | // this.dg.add(reference, target, bounds[1]); |
||
160 | // this.dg.add(target, reference, -bounds[0]); |
||
161 | // } |
||
162 | // } |
||
163 | // } |
||
164 | // |
||
165 | // // set propagate flag |
||
166 | // this.toPropagate = true; |
||
167 | // } |
||
168 | // break; |
||
169 | |||
170 | // temporal constraint deleted |
||
171 | // case DEL_REL: { |
||
172 | // |
||
173 | // // handle request |
||
174 | // DelRelationTemporalNetworkNotification notif = (DelRelationTemporalNetworkNotification) info; |
||
175 | // // check pairs of involved time points |
||
176 | // Map<TimePoint, Set<TimePoint>> p2p= new HashMap<>(); |
||
177 | // for (TimePointDistanceConstraint constraint : notif.getRels()) { |
||
178 | // // check time points |
||
179 | // if (!p2p.containsKey(constraint.getReference())) { |
||
180 | // p2p.put(constraint.getReference(), new HashSet<>()); |
||
181 | // } |
||
182 | // |
||
183 | // // add pair |
||
184 | // p2p.get(constraint.getReference()).add(constraint.getTarget()); |
||
185 | // } |
||
186 | // |
||
187 | // |
||
188 | // // update the internal distance graph |
||
189 | // for (TimePoint reference : p2p.keySet()) { |
||
190 | // for (TimePoint target : p2p.get(reference)) { |
||
191 | // |
||
192 | // // get constraint bounds |
||
193 | // long[] bounds = this.tn.getConstraintBounds(reference, target); |
||
194 | // // check if bound exists |
||
195 | // if (bounds != null) { |
||
196 | // // add/replace the associated edge of the distance graph |
||
197 | // this.dg.add(reference, target, bounds[1]); |
||
198 | // this.dg.add(target, reference, -bounds[0]); |
||
199 | // } |
||
200 | // } |
||
201 | // } |
||
202 | // |
||
203 | // // set propagate flag |
||
204 | // this.toPropagate = true; |
||
205 | // } |
||
206 | // break; |
||
207 | |||
208 | // time point deleted |
||
209 | case INITIALIZATION : |
||
210 | case ADD_TP : |
||
211 | case ADD_REL : |
||
212 | case DEL_REL : |
||
213 | case DEL_TP : { |
||
214 | |||
215 | // handle request |
||
216 | // DelTimePointTemporalNetworkNotification notif = (DelTimePointTemporalNetworkNotification) info; |
||
217 | // delete time points |
||
218 | // for (TimePoint point : notif.getPoints()) { |
||
219 | // // delete node from the distance graph |
||
220 | // this.dg.delete(point); |
||
221 | // } |
||
222 | // |
||
223 | // recompute dependency graph distance bounds |
||
224 | this.dg(); |
||
225 | // set to propagate flag |
||
226 | this.toPropagate = true; |
||
227 | } |
||
228 | break; |
||
229 | |||
230 | // time point added |
||
231 | // case ADD_TP: { |
||
232 | // |
||
233 | // // handle request |
||
234 | // AddTimePointTemporalNetworkNotification notif = (AddTimePointTemporalNetworkNotification) info; |
||
235 | // // get added time points |
||
236 | // for (TimePoint point : notif.getPoints()) { |
||
237 | // // add the point to the distance graph |
||
238 | // this.dg.add(point); |
||
239 | // } |
||
240 | // |
||
241 | // |
||
242 | // // it is not necessary to update information yet |
||
243 | // this.toPropagate = true; |
||
244 | // } |
||
245 | // break; |
||
246 | |||
247 | // other |
||
248 | default: { |
||
249 | throw new RuntimeException("[" + this.getClass().getName() + "]: Unknown notification received type= " + info.getType()); |
||
|
|||
250 | } |
||
490 |