@Test public void checkGetLHSFieldVariables() { final List<String> allLHSVariables = model.getLHSVariables(false, true); assertEquals(3, allLHSVariables.size()); assertTrue(allLHSVariables.contains("$sfc1")); assertTrue(allLHSVariables.contains("$sfc2")); assertTrue(allLHSVariables.contains("$sfc3")); }
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; }
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; } }
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; } RuleModel(); }
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; } RuleModel(); List<String> getLHSBoundFacts(); FactPattern getLHSBoundFact(final String var); SingleFieldConstraint getLHSBoundField(final String var); String getLHSBindingType(final String var); String getFieldBinding(FieldConstraint fc,
                                  String var); List<String> getRHSBoundFacts(); ActionInsertFact getRHSBoundFact(final String var); FactPattern getLHSParentFactPatternForBinding(final String var); List<String> getAllLHSVariables(); List<String> getLHSPatternVariables(); List<String> getLHSVariables(final boolean includePatterns,
                                        final boolean includeFields); List<String> getAllRHSVariables(); List<String> getAllVariables(); List<String> getFieldBinding(FieldConstraint f); boolean removeLhsItem(final int idx); boolean isBoundFactUsed(final String binding); void addLhsItem(final IPattern pat); void addLhsItem(final IPattern pat,
                           boolean append); void addLhsItem(final IPattern pat,
                           int position); void moveLhsItemDown(int itemIndex); void moveLhsItemUp(int itemIndex); void moveRhsItemDown(int itemIndex); void moveRhsItemUp(int itemIndex); void addRhsItem(final IAction action); void addRhsItem(final IAction action,
                           boolean append); void addRhsItem(final IAction action,
                           int position); void removeRhsItem(final int idx); void addAttribute(final RuleAttribute attribute); void removeAttribute(final int idx); void addMetadata(final RuleMetadata metadata); void removeMetadata(final int idx); RuleMetadata getMetaData(String attributeName); boolean updateMetadata(final RuleMetadata target); List<String> getBoundVariablesInScope(final BaseSingleFieldConstraint con); boolean isVariableNameUsed(String s); boolean hasDSLSentences(); boolean isNegated(); void setNegated(boolean isNegated); Imports getImports(); @Override void setImports(final Imports imports); String getPackageName(); void setPackageName(String packageName); @Override boolean equals(Object o); @Override int hashCode(); }
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; } RuleModel(); List<String> getLHSBoundFacts(); FactPattern getLHSBoundFact(final String var); SingleFieldConstraint getLHSBoundField(final String var); String getLHSBindingType(final String var); String getFieldBinding(FieldConstraint fc,
                                  String var); List<String> getRHSBoundFacts(); ActionInsertFact getRHSBoundFact(final String var); FactPattern getLHSParentFactPatternForBinding(final String var); List<String> getAllLHSVariables(); List<String> getLHSPatternVariables(); List<String> getLHSVariables(final boolean includePatterns,
                                        final boolean includeFields); List<String> getAllRHSVariables(); List<String> getAllVariables(); List<String> getFieldBinding(FieldConstraint f); boolean removeLhsItem(final int idx); boolean isBoundFactUsed(final String binding); void addLhsItem(final IPattern pat); void addLhsItem(final IPattern pat,
                           boolean append); void addLhsItem(final IPattern pat,
                           int position); void moveLhsItemDown(int itemIndex); void moveLhsItemUp(int itemIndex); void moveRhsItemDown(int itemIndex); void moveRhsItemUp(int itemIndex); void addRhsItem(final IAction action); void addRhsItem(final IAction action,
                           boolean append); void addRhsItem(final IAction action,
                           int position); void removeRhsItem(final int idx); void addAttribute(final RuleAttribute attribute); void removeAttribute(final int idx); void addMetadata(final RuleMetadata metadata); void removeMetadata(final int idx); RuleMetadata getMetaData(String attributeName); boolean updateMetadata(final RuleMetadata target); List<String> getBoundVariablesInScope(final BaseSingleFieldConstraint con); boolean isVariableNameUsed(String s); boolean hasDSLSentences(); boolean isNegated(); void setNegated(boolean isNegated); Imports getImports(); @Override void setImports(final Imports imports); String getPackageName(); void setPackageName(String packageName); @Override boolean equals(Object o); @Override int hashCode(); static final String DEFAULT_TYPE; public String name; public String parentName; public String modelVersion; public RuleAttribute[] attributes; public RuleMetadata[] metadataList; public IPattern[] lhs; public IAction[] rhs; }