I am using Spring-WS to populate a List<SomeBean>
w.r.t. a web-service. The final list that I get after consuming the service contains null
entries for some of its properties. For example, consider the following list of MangaBean
which has title, author and genre as properties.
MangaBean [title=Bleach, author=Kubo Tite, genre=fantasy]
MangaBean [title=Naruto, author=Masashi Kishimoto, genre=action]
MangaBean [title=One Piece, author=Eiichiro Oda, genre=null]
MangaBean [title=Fairy Tail, author=Mashima Hiro, genre=null]
MangaBean [title=Rurouni Kenshin, author=Watsuki Nobuhiro, genre=Shounen]
MangaBean [title=Takamagahara, author=KAWAI Juuzou, genre=Supernatural]
MangaBean [title=Historys Strongest Disciple Kenichi, author=Matsuena Syun, genre=Martial arts]
MangaBean [title=Hajime no Ippo, author=Jyoji Morikawa, genre=null]
The genre
entry for some beans are null
. I am trying to remove the objects with null properties in the list.
My questions are:
- Is it proper/good practice to alter the original list by removing specific entries? Or should I populate another list w.r.t. the previous list?
- If I should alter the list and remove those null entries, how should I do it?
I tried this but it fails as the object-refs themselves aren't null. I tried the traditional for loop but it fails to remove adjucent objects with null properties. Cannot use the enhanced-for-loop for removing items while accessing the list. Kindly render me some brain. :)