helloworld.groovy.drl

来自「drools 一个开放源码的规则引擎」· DRL 代码 · 共 60 行

DRL
60
字号
<?xml version="1.0"?>

<rule-set name="helloworld"
          xmlns="http://drools.org/rules"
          xmlns:groovy="http://drools.org/semantics/groovy"
          xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
          xs:schemaLocation="http://drools.org/rules rules.xsd
                             http://drools.org/semantics/groovy groovy.xsd">

  <import>java.lang.Object</import>
  <import>java.lang.String</import>

  <groovy:functions>
  	static def helloWorld(String hello)
  	{
  		println hello + " World";
  	}

  	static def goodbyeWorld(String goodbye)
  	{
  		println goodbye + " Cruel World";
  	}
  </groovy:functions>

  <rule name="Hello World">
    <parameter identifier="hello">
      <class>String</class>
    </parameter>

    <groovy:condition>hello.equals("Hello")</groovy:condition>

    <groovy:consequence>
      helloWorld(hello);
    </groovy:consequence>
  </rule>

  <rule name="Goodbye Cruel World">
    <parameter identifier="goodbye">
      <class>String</class>
    </parameter>

    <groovy:condition>goodbye.equals("Goodbye")</groovy:condition>

    <groovy:consequence>
      goodbyeWorld(goodbye)
    </groovy:consequence>
  </rule>

  <rule name="Debug">
    <parameter identifier="object">
      <class>Object</class>
    </parameter>

    <groovy:consequence>
      println "Asserted object: " + object ;
    </groovy:consequence>
  </rule>

</rule-set>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?