public FactPattern getLHSParentFactPatternForBinding ( final String var ) { if ( this . lhs == null ) { return null ; } for ( int i = 0 ; i < this . lhs . length ; i ++ ) { IPattern pat = this . lhs [ i ] ; if ( pat instanceof FromCompositeFactPattern ) { pat = ( ( FromCompositeFactPattern ) pat ) . getFactPattern ( ) ; } if ( pat instanceof FactPattern ) { final FactPattern p = ( FactPattern ) pat ; if ( p . getBoundName ( ) != null && var . equals ( p . getBoundName ( ) ) ) { return p ; } for ( int j = 0 ; j < p . getFieldConstraints ( ) . length ; j ++ ) { FieldConstraint fc = p . getFieldConstraints ( ) [ j ] ; List < String > fieldBindings = getFieldBinding ( fc ) ; if ( fieldBindings . contains ( var ) ) { return p ; } } } } return null ; }
This will return the FactPattern that a variable is bound to . If the variable is bound to a FieldConstraint the parent FactPattern will be returned .