private < T > AutoBean < T > checkStreamsNotCrossed ( final T object ) { final AutoBean < T > bean = AutoBeanUtils . getAutoBean ( object ) ; if ( bean == null ) { // Unexpected; some kind of foreign implementation? throw new IllegalArgumentException ( object . getClass ( ) . getName ( ) ) ; } final State otherState = bean . getTag ( REQUEST_CONTEXT_STATE ) ; if ( ! bean . isFrozen ( ) && otherState != this . state ) { /* * This means something is way off in the weeds. If a bean is editable, it's supposed to be * associated with a RequestContext. */ assert otherState != null : "Unfrozen bean with null RequestContext" ; /* * Already editing the object in another context or it would have been in the editing map. */ throw new IllegalArgumentException ( "Attempting to edit an EntityProxy" + " previously edited by another RequestContext" ) ; } return bean ; }
This method checks that a proxy object is either immutable or already edited by this context .