I\'ve an object with a certain state. The object is passed around and it\'s state is temporarly altered. Something like:
public void doSomething(MyObject obj) {
Nope, there's no such thing. The closest is probably a try/finally block:
try { obj.changeState(...); obj.use(); } finally { obj.loadState(); }
This ensures that loadState() gets called even when an Exception is thrown or there's an early return.
loadState()
return