Java Class turns invalid after a method call
<p>I have a class that interfaces with an RPGLE program.</p>

<p>The client will hold a reference to the class and perform certain operations.  Calling methods etc.</p>

<p>After a call to a particular method - <code>endDocument()</code>, the class is then is an invalid state because I call <code>destroy()</code> on a number of objects (which is required by the API).</p>

<p>Other than having a boolean member flag "illigalState" and at the top of every method checking it, throwing an <code>IllegalStateException()</code>, how might I handle this problem?</p>

<p>I don't want the user to be able to use the class after it is in this illegal state, but they have a reference to it.</p>
