Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to remove null bean attributes present in a List?
    primarykey
    data
    text
    <p>I am using Spring-WS to populate a <code>List&lt;SomeBean&gt;</code> w.r.t. a web-service. The final list that I get after consuming the service contains <code>null</code> entries for some of its properties. For example, consider the following list of <code>MangaBean</code> which has title, author and genre as properties.</p> <pre><code>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] </code></pre> <p>The <code>genre</code> entry for some beans are <code>null</code>. I am trying to remove the objects with <strong>null properties</strong> in the list. My questions are:</p> <ol> <li>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?</li> <li>If I should alter the list and remove those null entries, how should I do it?</li> </ol> <p>I tried <a href="https://stackoverflow.com/questions/4819635/how-to-remove-all-null-elements-from-a-arraylist">this</a> 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. :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload