Set default value for remaining size of list by use of Java 8 and Stream I have written a method which will return the size 16 List every time. If the input List has size less than 16, the remaining list object will be filled with default values.  Is there any way to remove the if and for condition from the enrichAddress method?.
@Component
public class TestService{

public List&lt;TestB&gt; enrichAddress(List&lt;TestA&gt; cardAccountDetails) {
if (CollectionUtils.isEmpty(cardAccountDetails)) return Collections.emptyList();

List&lt;TestB&gt; testBList = cardAccountDetails.stream().map(AccountService::buildAddress).collect(Collectors.toList());
if (testBList.size() &lt; 16) {
  int accountCounts = testBList.size();
  for (; accountCounts &lt; 16; accountCounts++) {
    testBList.add(buildDefaultAddress());
  }
}
return testBList;
}

private TestA buildDefaultAddress() {
TestA testA = new TestA();


testA.setA(&quot;NONE&quot;);
testA.setAccS(&quot;TEST_STATUS&quot;);

testA.setAccT(&quot;TEST_ACCOUNT_TYPE&quot;);
testA.setADes(&quot;&quot;);

return testA;
}

private static TestA buildAddress(TestB testB) {
TestA testA = new TestA();

testA.setDes(testB.getDes());
testA.setAcc(testB.getAcN());
testA.setAccSt(testB.getAccS());

testA.setAccT(testB.getAcCT());
testA.setAc(testB.getAct());

return testA;
 }
}
As mtj already mentioned in the comment, adding stream trickery to fulfill this need only makes the code less readable. Streams are nifty, exciting and popular but they are not always the right tool for the job. Sometimes a plain loop is still the best choice.
The common pattern in padding a collection (well, most often it's a string that gets padded) to certain size is to use a while loop. It has least amount of excess variables and code and the syntax communicates intent quite naturally (&quot;while size is less than 16, do this&quot;). But this still only tells that you are intentionally padding the collection to 16 elements. You also need to document in comments the reason why you are padding the collection to 16 elements.
List&lt;Address&gt; addresses = cardAccountDetails
    .stream()
    .map(AccountService::buildAddress)
    .collect(Collectors.toList());

while (addresses.size() &lt; 16) {
    addresses.add(buildDefaultAddress());
}