152 |
152 |
}
|
153 |
153 |
|
154 |
154 |
/**
|
155 |
|
* Updates the last parameters used for computing.
|
|
155 |
* Stores the last parameters used for computing.
|
156 |
156 |
* @throws Exception
|
157 |
157 |
*/
|
158 |
158 |
protected void updateLastComputingParameters() throws Exception {
|
... | ... | |
168 |
168 |
}
|
169 |
169 |
}
|
170 |
170 |
|
171 |
|
protected Object getParameterForKey(String key) {
|
|
171 |
/**
|
|
172 |
* Gets a parameter used for last computing.
|
|
173 |
* @param key
|
|
174 |
* @return
|
|
175 |
*/
|
|
176 |
protected Object getLastParameter(String key) {
|
172 |
177 |
Field[] fields = this.getClass().getDeclaredFields();
|
173 |
178 |
for (Field f : fields) {
|
174 |
179 |
Parameter parameter = f.getAnnotation(Parameter.class);
|
... | ... | |
187 |
192 |
return null;
|
188 |
193 |
}
|
189 |
194 |
|
190 |
|
protected boolean hasParameterChanged(String key) {
|
|
195 |
/**
|
|
196 |
* Checks if a parameter value has changed since last computing.
|
|
197 |
* @param key
|
|
198 |
* @return
|
|
199 |
*/
|
|
200 |
protected boolean parameterHasChanged(String key) {
|
191 |
201 |
if ("".equals(key)) {
|
192 |
202 |
return false;
|
193 |
203 |
}
|
194 |
204 |
Object o = lastComputingParameters.get(key);
|
195 |
|
Object newValue = getParameterForKey(key);
|
|
205 |
Object newValue = getLastParameter(key);
|
196 |
206 |
if (o == null && newValue != null) {
|
197 |
207 |
return true;
|
198 |
|
} else {
|
|
208 |
}
|
|
209 |
else {
|
199 |
210 |
return o.equals(newValue);
|
200 |
211 |
}
|
201 |
212 |
}
|
202 |
213 |
|
|
214 |
|
|
215 |
|
203 |
216 |
/**
|
|
217 |
* Updates the dirty state by comparing an old parameter with a new one.
|
|
218 |
*
|
|
219 |
* @param previousValue may be null
|
|
220 |
* @param newValue may be null
|
|
221 |
*/
|
|
222 |
protected void updateDirty(Object previousValue, Object newValue) {
|
|
223 |
if (previousValue == null || !previousValue.equals(newValue)) {
|
|
224 |
Log.info("Setting dirty to true: old = "+ previousValue + " / new = " + newValue);
|
|
225 |
this.setDirty();
|
|
226 |
}
|
|
227 |
}
|
|
228 |
|
|
229 |
|
|
230 |
/**
|
204 |
231 |
* Updates the dirty states by comparing TXMResult @Parameter with previously used parameters in the compute() method.
|
205 |
232 |
*
|
206 |
233 |
* To work correctly the equals method of the TXMResult parameters must be correctly implemented.
|
... | ... | |
237 |
264 |
|
238 |
265 |
|
239 |
266 |
/**
|
240 |
|
* Updates the dirty state by comparing an old parameter with a new one.
|
241 |
|
*
|
242 |
|
* @param previousValue may be null
|
243 |
|
* @param newValue may be null
|
244 |
|
*/
|
245 |
|
protected void updateDirty(Object previousValue, Object newValue) {
|
246 |
|
if (previousValue == null || !previousValue.equals(newValue)) {
|
247 |
|
Log.info("Setting dirty to true: old = "+ previousValue + " / new = " + newValue);
|
248 |
|
this.dirty = true;
|
249 |
|
}
|
250 |
|
}
|
251 |
|
|
252 |
|
|
253 |
|
/**
|
254 |
267 |
* Gets the dirty states.
|
255 |
268 |
*
|
256 |
269 |
* @return
|