Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-5328

Externalize lambda for binding variable

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major Major
    • 7.38.0.Final
    • 7.37.0.Final
    • executable model
    • None
    • 2020 Week 19-21 (from May 4)
    • 4
    • NEW
    • NEW

      When "drools.externaliseCanonicalModelLambda" is enabled, Predicate, Extractor and Consequence are externalized. But still lambda for binding variable exists:
      e.g. CompilerTest#testStringValueOf)

          public static org.drools.model.Rule rule_R() {
              final org.drools.model.Variable<java.lang.Integer> var_GENERATED_$pattern_Integer$1$ = D.declarationOf(java.lang.Integer.class,
                         DomainClassesMetadata81A66AD685F7689036AAA5128956C14B.java_lang_Integer_Metadata_INSTANCE,
                         "GENERATED_$pattern_Integer$1$");
      
              final org.drools.model.Variable<Integer> var_$i = D.declarationOf(Integer.class, "$i");
      
              final org.drools.model.Variable<org.drools.modelcompiler.domain.Person> var_GENERATED_$pattern_Person$1$ = D.declarationOf(org.drools.modelcompiler.domain.Person.class,
                     DomainClassesMetadata81A66AD685F7689036AAA5128956C14B.org_drools_modelcompiler_domain_Person_Metadata_INSTANCE,
                     "GENERATED_$pattern_Person$1$");
      
              org.drools.model.Rule rule = D.rule("R").build(D.pattern(var_GENERATED_$pattern_Integer$1$).bind(var_$i, (java.lang.Integer _this) -> _this.intValue()),
                 D.pattern(var_GENERATED_$pattern_Person$1$).expr("476633DA7C4638FC84A32859E0C843E6",
                                                                  var_$i,
                                                                  (_this, $i) -> org.drools.modelcompiler.util.EvaluationUtil.areNullSafeEquals(_this.getName(),
                                                                  (String.valueOf($i))),
                                                                  D.reactOn("name")),
                 D.on(var_$i).execute(defaultpkg.P1D.LambdaConsequence1D5F4C5CA006007B1D3974ED5A5A05B6.INSTANCE));
              return rule;
          }
      

      See

      bind(var_$i, (java.lang.Integer _this) -> _this.intValue())
      

      Function1$Impl is instantiated by PatternDSL$PatternDefImpl.bind()

      Note: The above example shows another lambda

      expr("476633DA7C4638FC84A32859E0C843E6",
                                                                  var_$i,
                                                                  (_this, $i) -> org.drools.modelcompiler.util.EvaluationUtil.areNullSafeEquals(_this.getName(),
                                                                  (String.valueOf($i)))
      

      This will be addressed by another JIRA.

              rhn-support-tkobayas Toshiya Kobayashi
              rhn-support-tkobayas Toshiya Kobayashi
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: