@Test public void createConsequenceWithDrools() { ArrayList<String> fields = new ArrayList<>(); fields.add("\"age\""); MaterializedLambda.BitMaskVariable bitMaskVariable = new MaterializedLambda.BitMaskVariableWithFields("DomainClassesMetadataA3B8DE4BEBF13D94572A10FD20BBE729.org_drools_modelcompiler_domain_Person_Metadata_INSTANCE", fields, "mask_$p"); CreatedClass aClass = new MaterializedLambdaConsequence("defaultpkg", "defaultpkg.RulesA3B8DE4BEBF13D94572A10FD20BBE729", Collections.singletonList(bitMaskVariable)) .create("(org.drools.model.Drools drools, org.drools.modelcompiler.domain.Person $p) -> {{($p).setAge($p.getAge() + 1); drools.update($p, mask_$p);}}", new ArrayList<>(), new ArrayList<>()); String expectedResult = "" + "package defaultpkg.P52;\n" + "import static defaultpkg.RulesA3B8DE4BEBF13D94572A10FD20BBE729.*; " + "import org.drools.modelcompiler.dsl.pattern.D; " + "\n"+ "@org.drools.compiler.kie.builder.MaterializedLambda() " + "public enum LambdaConsequence526B250E5F70E575F0059D0E397318C6 implements org.drools.model.functions.Block2<org.drools.model.Drools, org.drools.modelcompiler.domain.Person> {\n" + " INSTANCE;\n" + " public static final String EXPRESSION_HASH = \"1FE08C27A04F37AADD1A62E562519E8D\";\n" + " private final org.drools.model.BitMask mask_$p = org.drools.model.BitMask.getPatternMask(DomainClassesMetadataA3B8DE4BEBF13D94572A10FD20BBE729.org_drools_modelcompiler_domain_Person_Metadata_INSTANCE, \"age\");\n" + " @Override()\n" + " public void execute(org.drools.model.Drools drools, org.drools.modelcompiler.domain.Person $p) throws java.lang.Exception {\n" + " {\n" + " ($p).setAge($p.getAge() + 1);\n" + " drools.update($p, mask_$p);\n" + " }" + " }\n" + " }\n"; assertThat(aClass.getCompilationUnitAsString(), equalToIgnoringWhiteSpace(expectedResult)); }
@Override protected EnumDeclaration create(CompilationUnit compilationUnit) { EnumDeclaration lambdaClass = super.create(compilationUnit); boolean hasDroolsParameter = lambdaParameters.stream().anyMatch(this::isDroolsParameter); if (hasDroolsParameter) { bitMaskVariables.forEach(vd -> vd.generateBitMaskField(lambdaClass)); } return lambdaClass; }
MaterializedLambdaConsequence extends MaterializedLambda { @Override protected EnumDeclaration create(CompilationUnit compilationUnit) { EnumDeclaration lambdaClass = super.create(compilationUnit); boolean hasDroolsParameter = lambdaParameters.stream().anyMatch(this::isDroolsParameter); if (hasDroolsParameter) { bitMaskVariables.forEach(vd -> vd.generateBitMaskField(lambdaClass)); } return lambdaClass; } }
MaterializedLambdaConsequence extends MaterializedLambda { @Override protected EnumDeclaration create(CompilationUnit compilationUnit) { EnumDeclaration lambdaClass = super.create(compilationUnit); boolean hasDroolsParameter = lambdaParameters.stream().anyMatch(this::isDroolsParameter); if (hasDroolsParameter) { bitMaskVariables.forEach(vd -> vd.generateBitMaskField(lambdaClass)); } return lambdaClass; } MaterializedLambdaConsequence(String packageName, String ruleClassName, List<BitMaskVariable> bitMaskVariables); }
MaterializedLambdaConsequence extends MaterializedLambda { @Override protected EnumDeclaration create(CompilationUnit compilationUnit) { EnumDeclaration lambdaClass = super.create(compilationUnit); boolean hasDroolsParameter = lambdaParameters.stream().anyMatch(this::isDroolsParameter); if (hasDroolsParameter) { bitMaskVariables.forEach(vd -> vd.generateBitMaskField(lambdaClass)); } return lambdaClass; } MaterializedLambdaConsequence(String packageName, String ruleClassName, List<BitMaskVariable> bitMaskVariables);  }
MaterializedLambdaConsequence extends MaterializedLambda { @Override protected EnumDeclaration create(CompilationUnit compilationUnit) { EnumDeclaration lambdaClass = super.create(compilationUnit); boolean hasDroolsParameter = lambdaParameters.stream().anyMatch(this::isDroolsParameter); if (hasDroolsParameter) { bitMaskVariables.forEach(vd -> vd.generateBitMaskField(lambdaClass)); } return lambdaClass; } MaterializedLambdaConsequence(String packageName, String ruleClassName, List<BitMaskVariable> bitMaskVariables);   }