Hi,

How to compare that one list of object contains all objects from other list in Jess ?

How to obtain inside jess (in Jess source file: clp)
two list of objects (java.util.ArrayList) as two separate facts ?


I have 2 lists of objects of the same class.

My rule must check if all objects from first list exists in second list
(if second list contains all objects from first list)

Example:

In first I have for example 2 objects (of class TestData)
and in second list I have 3 objects = the same 2 objects as in first list and one other object.
Rule for this case should be fulfilled.



           public class TestData {
               private String name;
               private Integer id;
public TestData(Integer id,String name) {
                   this.name = name;
                   this.id = id;
               }
...//getters and setters
           }
....
           List<TestData> list1 = new ArrayList<TestData>();
           List<TestData> list2 = new ArrayList<TestData>();
           list1.add( new TestData(1,"test a"));
           list1.add( new TestData(1,"test b"));
           list2.addAll(list1);
           list2.add( new TestData(1,"test c"));
System.out.println("__java check__:" + list2.containsAll(list1)); //this will be: TRUE this.engine.add( list1 );
           this.engine.add( list2 );
...
           this.engine.run()
           ....



thanks for any answer
and sorry for my english


Michal




--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to