Here you can find the source of addIf(Collection
public static <T> Collection<T> addIf(Collection<T> coll, T value, boolean expr)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.util.Collection; public class Main { /**//from w w w .j a va 2 s .c o m * Adds a value to the collection if the boolean expression is true. * Returns the collection as a convenience for chained invocations. * * @since 1.0.8 */ public static <T> Collection<T> addIf(Collection<T> coll, T value, boolean expr) { if (expr) coll.add(value); return coll; } }