Java - fire event when any property of object changes
<p>In Java, what is the most elegant way for an object to fire an event whenever any property of an object changes?</p>

<p>My domain model has several objects like </p>

<pre><code>class MyClass {

    String id;
    String name;
    Collection&lt;MyThing&gt; mythings= new HashSet&lt;MyThing&gt;();
    // more fields...
    Date lastUpdated;

    //constructor, getters and setters, etc
}
</code></pre>

<p>I need lastUpdated to be set to "today" whenever any of the properties (id/name/mythings) changes.</p>

<p>I would prefer a solution that is not JDO-specific, and definitely don't want this logic in the datastore (auto-timestamp column in the RDBMS etc).</p>

<p>I could put</p>

<pre><code>this.lastUpdated = new Date();
</code></pre>

<p>in every setter, or fire a custom event in every setter, but that's ugly and error-prone.</p>

<p>Is there a more elegant solution?</p>
