Saturday March 08, 2003
How do I remove duplicates in a List? I have a List that may contain duplicates and I need to filter out the duplicates (so I don't get a foreign key violation when inserting records). Are there any Jakarta' Commons utilities to do this? I can see a few solutions to my problem:
- Present it on the UI. This might be tough since I'm using a select box JavaScript library. Hmmm, I am using a custom setter for the String[] that gets sent in, maybe I can do it there - checking to see if the ArrayList I'm setting already contains the given String.
- Filter it out in the business layer.
- Use a type of List that doesn't allow duplicates, and just ignores a duplicate value when you try to add it.
I just thought of #1 while writing this post. It's cool how talking about your problems can help solve them - no wonder shrinks get paid so much. I'm still interested in any proposed utility classes. Posted in Java at Mar 08 2003, 07:15:42 AM MST 5 Comments
Search This Site
Recent Entries
- Happy Birthday Mom!
- 2008 - A Year in Review
- Portland Tech Meetup Tomorrow Night
- My "almost slept in a snow cave" Adventure with Clint Foster
- My Christmas Travel Adventure
- AppFuse Light converted to Maven modules, upgraded to Tapestry 5 and Stripes 1.5
- Dojo/Comet support in Java Web Frameworks
- Abbie is a Blue Skier!
- How I recovered data from my failed Linux box
- Costa Rica was Awesome!
Posted by Lance on March 08, 2003 at 09:23 AM MST #
Posted by Anonymous on March 08, 2003 at 09:55 AM MST #
public void add(Object obj) { if(!this.prop.contains(obj)) this.prop.add(obj); }No need to re-implement the wheel :)Posted by Carl Fyffe on March 08, 2003 at 08:16 PM MST #
Posted by Anonymous on March 08, 2003 at 10:03 PM MST #
Posted by Anonymous on March 09, 2003 at 09:28 AM MST #