title: Java 8 streams do something with an element which has a boolean field
body: <p>I wanna make streams from a list, and do something with an object if an certain field is true.</p>
  
  <p>Let me show you what have I done till now:</p>
  
  <pre><code>    List&lt;UserData&gt; userDataList = new ArrayList&lt;&gt;();
  
      phoneNumbers.forEach(phoneNumber -&gt; {
          if (phoneNumber.getPrimary()) {
              UserData userData = new UserData();
              userData.setDescription(phoneNumber.getType());
              userData.setValue(phoneNumber.getNumber);
              userDataList.add(userData);
          }
      });
  </code></pre>
  
  <p>So if <code>phoneNumber.getPrimary() == true</code> will do the following task, if not -
   ignore it.</p>