/** add another view for this object. <code>other</code> must be freshly constructed. To be called by subclasses when they have constructed a new view for this object. <p>The method is synchronised because addView is an update operation that may happen in a read context (because of .as()). Synchronising it ensures that simultaneous updates don't end up leaving the rings in an inconsistent state. (It's not clear whether this would actually lead to any problems; it's hard to write tests to expose these issues.) This method is public ONLY so that it can be tested. TODO find a better way to make it testable. */ public synchronized void addView( Polymorphic<T> other ) { if (other.ring == other) { other.ring = this.ring; this.ring = other; } else throw new AlreadyLinkedViewException( other ); }
/** add another view for this object. <code>other</code> must be freshly constructed. To be called by subclasses when they have constructed a new view for this object. <p>The method is synchronised because addView is an update operation that may happen in a read context (because of .as()). Synchronising it ensures that simultaneous updates don't end up leaving the rings in an inconsistent state. (It's not clear whether this would actually lead to any problems; it's hard to write tests to expose these issues.) This method is public ONLY so that it can be tested. TODO find a better way to make it testable. */ public synchronized void addView( Polymorphic<T> other ) { if (other.ring == other) { other.ring = this.ring; this.ring = other; } else throw new AlreadyLinkedViewException( other ); }