FactHandle assertObject(Object object, boolean dynamic, boolean logical, Rule rule, Activation activation) throws FactException {  FactHandleImpl handle = (FactHandleImpl) this.identityMap.get( object );   if ( (handle != null) && (logical) ) { return handle; }   Object logicalState = this.equalsMap.get( object );   if ( (handle != null) && (!logical) && logicalState == WorkingMemoryImpl.STATED ) { return handle; }  if ( !logical ) {   if ( logicalState instanceof FactHandleImpl ) { handle = (FactHandleImpl) logicalState; removeLogicalDependencies( handle ); } else { handle = (FactHandleImpl) newFactHandle(); }  putObject( handle, object );  this.equalsMap.put( object, WorkingMemoryImpl.STATED );  if ( dynamic ) { addPropertyChangeListener( object ); } } else {  if ( logicalState == WorkingMemoryImpl.STATED ) { return null; }  handle = (FactHandleImpl) logicalState;   if ( handle == null ) { handle = (FactHandleImpl) newFactHandle();  putObject( handle, object );  this.equalsMap.put( object, handle ); } addLogicalDependency( handle, activation, activation.getPropagationContext(), rule ); }  handle.setObject( object );  PropagationContext propagationContext = new PropagationContextImpl( ++this.propagationIdCounter, PropagationContext.ASSERTION, rule, activation );  this.ruleBase.assertObject( handle, object, propagationContext, this );  this.workingMemoryEventSupport.fireObjectAsserted( propagationContext, handle, object ); return handle;
public FactHandle assertObject(Object object) throws FactException { return assertObject( object,  false, false, null, null );
    FactHandle assertObject(Object object,                            boolean dynamic,                            boolean logical,                            Rule rule,                            Activation activation) throws FactException {        // check if the object already exists in the WM        FactHandleImpl handle = (FactHandleImpl) this.identityMap.get( object );        // return if the handle exists and this is a logical assertion        if ( (handle != null) && (logical) ) {            return handle;        }        // lets see if the object is already logical asserted        Object logicalState = this.equalsMap.get( object );        // if we have a handle and this STATED fact was previously STATED        if ( (handle != null) && (!logical) && logicalState == WorkingMemoryImpl.STATED ) {            return handle;        }        if ( !logical ) {            // If this stated assertion already has justifications then we need            // to cancel them            if ( logicalState instanceof FactHandleImpl ) {                handle = (FactHandleImpl) logicalState;                removeLogicalDependencies( handle );            } else {                handle = (FactHandleImpl) newFactHandle();            }            putObject( handle,                       object );            this.equalsMap.put( object,                                WorkingMemoryImpl.STATED );            if ( dynamic ) {                addPropertyChangeListener( object );            }        } else {            // This object is already STATED, we cannot make it justifieable            if ( logicalState == WorkingMemoryImpl.STATED ) {                return null;            }            handle = (FactHandleImpl) logicalState;            // we create a lookup handle for the first asserted equals object            // all future equals objects will use that handle            if ( handle == null ) {                handle = (FactHandleImpl) newFactHandle();                putObject( handle,                           object );                this.equalsMap.put( object,                                    handle );            }            addLogicalDependency( handle, activation, activation.getPropagationContext(), rule );        }        handle.setObject( object );        PropagationContext propagationContext = new PropagationContextImpl( ++this.propagationIdCounter,                                                                            PropagationContext.ASSERTION,                                                                            rule,                                                                            activation );        this.ruleBase.assertObject( handle,                                    object,                                    propagationContext,                                    this );        this.workingMemoryEventSupport.fireObjectAsserted( propagationContext,                                                           handle,                                                           object );        return handle;    }