< Q extends BaseProxy > Q processReturnOperation ( final SimpleProxyId < Q > id , final OperationMessage op , final WriteOperation ... operations ) { final AutoBean < Q > toMutate = this . getProxyForReturnPayloadGraph ( id ) ; toMutate . setTag ( Constants . VERSION_PROPERTY_B64 , op . getVersion ( ) ) ; final Map < String , Splittable > properties = op . getPropertyMap ( ) ; if ( properties != null ) { // Apply updates toMutate . accept ( new AutoBeanVisitor ( ) { @ Override public boolean visitReferenceProperty ( final String propertyName , final AutoBean < ? > value , final PropertyContext ctx ) { if ( ctx . canSet ( ) ) { if ( properties . containsKey ( propertyName ) ) { final Splittable raw = properties . get ( propertyName ) ; Object decoded = null ; if ( ctx . getType ( ) == Map . class ) { final MapPropertyContext mapCtx = ( MapPropertyContext ) ctx ; final Class < ? > keyType = mapCtx . getKeyType ( ) ; final Class < ? > valueType = mapCtx . getValueType ( ) ; decoded = EntityCodex . decode ( AbstractRequestContext . this , mapCtx . getType ( ) , keyType , valueType , raw ) ; } else { final Class < ? > elementType = ctx instanceof CollectionPropertyContext ? ( ( CollectionPropertyContext ) ctx ) . getElementType ( ) : null ; decoded = EntityCodex . decode ( AbstractRequestContext . this , ctx . getType ( ) , elementType , raw ) ; } ctx . set ( decoded ) ; } } return false ; } @ Override public boolean visitValueProperty ( final String propertyName , final Object value , final PropertyContext ctx ) { if ( ctx . canSet ( ) ) { if ( properties . containsKey ( propertyName ) ) { final Splittable raw = properties . get ( propertyName ) ; Object decoded = ValueCodex . decode ( ctx . getType ( ) , raw ) ; /* * Hack for Date subtypes, consider generalizing for "custom serializers" */ if ( decoded != null && Date . class . equals ( ctx . getType ( ) ) ) { decoded = new DatePoser ( ( Date ) decoded ) ; } ctx . set ( decoded ) ; } } return false ; } } ) ; } // Finished applying updates, freeze the bean this . makeImmutable ( toMutate ) ; final Q proxy = toMutate . as ( ) ; /* * Notify subscribers if the object differs from when it first came into the RequestContext. */ if ( operations != null && this . state . requestFactory . isEntityType ( id . getProxyClass ( ) ) ) { for ( final WriteOperation writeOperation : operations ) { if ( writeOperation . equals ( WriteOperation . UPDATE ) && ! this . state . requestFactory . hasVersionChanged ( id , op . getVersion ( ) ) ) { // No updates if the server reports no change continue ; } this . state . requestFactory . getEventBus ( ) . fireEventFromSource ( new EntityProxyChange <> ( ( EntityProxy ) proxy , writeOperation ) , id . getProxyClass ( ) ) ; } } return proxy ; }
Create a new EntityProxy from a snapshot in the return payload .