class RuleModel implements HasImports,
                                  HasPackageName {

    public List<String> getLHSVariables(final boolean includePatterns,
                                        final boolean includeFields) {
        List<String> result = new ArrayList<>();

        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) {
                FactPattern fact = (FactPattern) pat;
                if (fact.isBound()) {
                    if (includePatterns) {
                        result.add(fact.getBoundName());
                    }
                }

                if (includeFields) {
                    for (int j = 0; j < fact.getFieldConstraints().length; j++) {
                        FieldConstraint fc = fact.getFieldConstraints()[j];
                        if (fc instanceof SingleFieldConstraintEBLeftSide) {
                            SingleFieldConstraintEBLeftSide exp = (SingleFieldConstraintEBLeftSide) fc;
                            if (exp.getExpressionLeftSide() != null && exp.getExpressionLeftSide().isBound()) {
                                result.add(exp.getExpressionLeftSide().getBinding());
                            }
                        } else if (fc instanceof SingleFieldConstraint) {
                            SingleFieldConstraint con = (SingleFieldConstraint) fc;
                            if (con.isBound()) {
                                result.add(con.getFieldBinding());
                            }
                            if (con.getExpressionValue() != null && con.getExpressionValue().isBound()) {
                                result.add(con.getExpressionValue().getBinding());
                            }
                        }
                    }
                }
            }
        }

        return result;
    }

    public  RuleModel();

}