java - Preventing duplicate items in list from printing to cell table gwt -


if have class called 'testclass' full of getters , setters, , set properties on class object in class so:

            testclass testclass = new testclass();              testclass.setappid("id");             testclass.setstatus("status");             testclass.setmessage("message");              list<testclass> list = dataprovider.getlist(); 

and then, before adding object java list, have make sure doesn't exist in list avoid duplicates.

to achieve this, following check see if 3 properties of corresponding values exist in testclass object present in list. if don't, may added list.

            if(!list.contains(testclass.getappid().equals("id")) &&                !list.contains(testclass.getstatus().equals("status")) &&                !list.contains(testclass.getmessage().equals("message"))) {                 list.add(testclass);             }       dataprovider.refresh(); 

the above code within click handler, ever executed when button clicked.

why then, despite futile attempt @ stopping duplicates entering list, fail stop duplicate records being added cell table in gwt?

am wrong in thinking list logic problem?

thank help, hope i've been thorough enough.

your testclass.getappid().equals("id") call returns true or false. list not "contain" true or false therefore condition becomes true , element added. code should this:

for(testclass testclass: list){      if(!testclass.getappid().equals("id") &&         !testclass.getstatus().equals("status") &&         !testclass.getmessage().equals("message")){          list.add(testclass);     } }  dataprovider.refresh(); 

Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -