All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.kie.kogito.examples.Rules471B42E068A21F8D5BEF529A54AE3B27_PersonValidationServiceRuleMethods0 Maven / Gradle / Ivy

There is a newer version: 0.9.0
Show newest version
package org.kie.kogito.examples;

import java.util.*;
import org.drools.model.*;
import org.drools.modelcompiler.dsl.pattern.D;
import org.drools.model.Index.ConstraintType;
import java.time.*;
import java.time.format.*;
import java.text.*;
import org.drools.core.util.*;
import org.kie.kogito.examples.demo.Person;
import static org.kie.kogito.examples.Rules471B42E068A21F8D5BEF529A54AE3B27.*;

public class Rules471B42E068A21F8D5BEF529A54AE3B27_PersonValidationServiceRuleMethods0 {

    /**
     * Rule name: Is adult
     */
    public static org.drools.model.Rule rule_Is_32adult() {
        final org.drools.model.Variable var_$person = D.declarationOf(org.kie.kogito.examples.demo.Person.class,
                                                                                                           DomainClassesMetadata471B42E068A21F8D5BEF529A54AE3B27.org_kie_kogito_examples_demo_Person_Metadata_INSTANCE,
                                                                                                           "$person",
                                                                                                           D.entryPoint("persons"));
        final org.drools.model.BitMask mask_$person = org.drools.model.BitMask.getPatternMask(DomainClassesMetadata471B42E068A21F8D5BEF529A54AE3B27.org_kie_kogito_examples_demo_Person_Metadata_INSTANCE,
                                                                                              "adult");
        org.drools.model.Rule rule = D.rule("org.kie.kogito.examples",
                                            "Is adult").unit(org.kie.kogito.examples.PersonValidationService.class)
                                                       .build(D.pattern(var_$person).expr("78043B7D0A1598801B4B437C3CDA7CF8",
                                                                                          (org.kie.kogito.examples.demo.Person _this) -> org.drools.modelcompiler.util.EvaluationUtil.greaterThanNumbers(_this.getAge(),
                                                                                                                                                                                                         18),
                                                                                          D.alphaIndexedBy(java.lang.Integer.class,
                                                                                                           org.drools.model.Index.ConstraintType.GREATER_THAN,
                                                                                                           DomainClassesMetadata471B42E068A21F8D5BEF529A54AE3B27.org_kie_kogito_examples_demo_Person_Metadata_INSTANCE.getPropertyIndex("age"),
                                                                                                           (org.kie.kogito.examples.demo.Person _this) -> _this.getAge(),
                                                                                                           18),
                                                                                          D.reactOn("age")),
                                                              D.on(var_$person).execute((org.drools.model.Drools drools, org.kie.kogito.examples.demo.Person $person) -> {
                                                                  {
                                                                      ($person).setAdult(true);
                                                                      drools.update($person,
                                                                                    mask_$person);
                                                                  }
                                                              }));
        return rule;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy