aboutsummaryrefslogtreecommitdiffstats
path: root/policy-core/drools-artifact-1.1/src/main/resources/rules.drl
blob: 9dac208b108fd0e6f6436e7d8cce9d912a9cf4ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package org.onap.policy.drools.core.test;

rule "Initialization"
	when
	then
	{
	  System.out.println("Initialization rule running");
	}
end

rule "Add elements of an int array"
	when
		$object : Object()
	then
	{
	  if ($object instanceof int[])
		{
		  int[] array = (int[])($object);

		  System.out.println("Received array of length " + array.length);
		  int sum = 0;
		  for (int i = 1 ; i < array.length ; i += 1)
			{
			  sum += array[i];
			}
		  array[0] = sum;
		  retract($object);
		}
	}
end