Class UpdateManager
java.lang.Object
simpaths.model.annotations.UpdateManager
Reflection-based processor that applies
Lag and NullInitialised annotations
at the start of each simulation time interval.
Processing order
- Read phase — all
Lag-annotated fields have their source values read (via field reference or getter) and cached before any writes occur. - Lag write phase — all cached lag values are written to their annotated fields.
- Null phase — all
NullInitialised-annotated fields are set tonull.
Reading all sources before writing any lag field guarantees correct behaviour for multi-period lag chains regardless of field declaration order. For example:
L3 ← L2 (reads L2 before L2 is overwritten by the L2←L1 assignment) L2 ← L1 (reads L1 before L1 is overwritten by the L1←current assignment) L1 ← current
Typical usage in an entity's update method
// In Person.updateLaggedVariables() or BenefitUnit.updateAttributes():
UpdateManager.applyAnnotations(this);
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplyAnnotations(Object entity) Applies allLagandNullInitialisedannotations on the given entity, walking the full class hierarchy.
-
Method Details
-
applyAnnotations
Applies allLagandNullInitialisedannotations on the given entity, walking the full class hierarchy.- Parameters:
entity- the object whose annotated fields should be updated; must not benull- Throws:
IllegalArgumentException- if aLagannotation specifies neitherfieldnorgetter, or ifNullInitialisedis placed on a primitive fieldRuntimeException- wrapping any reflection error encountered during processing
-