eb0b6c472a00568d0b648b30a858050c530fc15b
[debian/openrocket] / src / net / sf / openrocket / util / Monitorable.java
1 package net.sf.openrocket.util;
2
3 public interface Monitorable {
4
5         /**
6          * Return a modification ID unique to the current state of this object and contained objects.
7          * The general contract is that if a specific object has the same modification ID at two moments
8          * in time, then the state of the object has not changed in between.  Additionally the
9          * modification ID value must be monotonically increasing.  This value can be used as a monitor
10          * to whether an object has been changed between two points of time.
11          * <p>
12          * Implementations may optionally fulfill the stronger requirement that any two objects of the same
13          * type that have the same modification ID will be equal, though for complex objects guaranteeing
14          * this may be impractical.
15          * <p>
16          * Objects that contain only primitive types or immutable objects can implement this method by
17          * increasing a modification counter or retrieving a new unique ID every time a value is set.
18          * <p>
19          * Objects that contain other objects with a mutable state may for example return the sum of the
20          * object's own modification ID, a modification ID counter (initially zero) and the modification ID
21          * of the contained objects.  When a mutable object is set, the modification counter is increased by
22          * the modification ID of the current object in order to preserve monotonicity.
23          * <p>
24          * If an object does not have any fields, this method can simply return zero.
25          * <p>
26          * Cloned objects may or may not have the same modification ID as the original object.
27          * 
28          * @return              a modification ID value for this object.
29          * @see                 UniqueID#next()
30          */
31         public int getModID();
32         
33 }