You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As far as I can tell, we can fire multiple facts at once, and the rules that match the fact's value will be executed. What if we want to evaluate multiple objects representing the same fact?
We cannot enter two facts with the same key because the Facts object is a hashmap. So I'm thinking we can make lists for each object type and then apply the rules to each object in the list. But how can rules be applied to each object in that list, where the list is a fact?
List dataBall = new ArrayList<>();
dataBall.add(new Ball("Red", 7, "B"));
dataBall.add(new Ball("Blue", 3, "A"));
List dataBat = new ArrayList<>();
dataBat.add(new Bat("Green", 8, "B"));
dataBat.add(new Bat("Red", 5, "A"));
dataBat.add(new Bat("Green", 6, "B"));
Facts fact = new Facts();
fact.put("ball", dataBall);
fact.put("bat", dataBat);
I want to execute two different rules based on the facts. As an example: For the fact "ball," I'd like to run the ball rule for each ball in the dataBall list. Similarly, for bat. All of this in one execution/ fire.
The text was updated successfully, but these errors were encountered:
hey, the way i can think of achieving this is by implementing a method for both the dataBall and the dataBat class with the same name, which returns a bool. in fact.put() you should use the same name for both classes, f.e. "myClass". you can then call this method in the condition where you check which class is calling an evaluate according to this. For the action u also define a method on the class level where you can implement anything.
As far as I can tell, we can fire multiple facts at once, and the rules that match the fact's value will be executed. What if we want to evaluate multiple objects representing the same fact?
We cannot enter two facts with the same key because the Facts object is a hashmap. So I'm thinking we can make lists for each object type and then apply the rules to each object in the list. But how can rules be applied to each object in that list, where the list is a fact?
List dataBall = new ArrayList<>();
dataBall.add(new Ball("Red", 7, "B"));
dataBall.add(new Ball("Blue", 3, "A"));
List dataBat = new ArrayList<>();
dataBat.add(new Bat("Green", 8, "B"));
dataBat.add(new Bat("Red", 5, "A"));
dataBat.add(new Bat("Green", 6, "B"));
Facts fact = new Facts();
fact.put("ball", dataBall);
fact.put("bat", dataBat);
I want to execute two different rules based on the facts. As an example: For the fact "ball," I'd like to run the ball rule for each ball in the dataBall list. Similarly, for bat. All of this in one execution/ fire.
The text was updated successfully, but these errors were encountered: