Merit of a "Search" class similar to a "Builder" class I have a class something like the following:  

class ItemManager {

    List&lt;Item&gt; items;

    public ItemManager() {

        items = Database.retrieveItems();

    }
}


An item has several attributes, so much so that I used a Builder class instead of a typical constructor(Like the builder classes found in Joshua Bloch's Effective Java).  I want to use ItemManager to keep track of a large number of items and I want to be able to search for Items that match one or more given attributes.  My question is, is the following method a reasonable approach, where can I improve it, and what is a common method of tackling this problem?

class ItemManager {

    ... // constructor etc.

    public Search getSearch() {
        return new Search();
    }

    public class Search {

        // Set default search parameters
        AttrA attrA = null;
        AttrB attrB = null;
        AttrC attrC = null;

        public Search setAttrA(AttrA a) {
            attrA = a;
            return this;
        }

        ... // set method for all attributes

        public List&lt;Item&gt; search() {

            List&lt;Item&gt; results = new ArrayList&lt;Item&gt;();

            for(Item i : items) {

                // If the search parameter is still null OR if the attribute
                // matches the search parameter, add it to the result set
                if ( (attrA==null || i.getAttrA().equals(attrA) )
                    &amp;&amp; (attrB==null || i.getAttrB().equals(attrB) )
                    &amp;&amp; (attrC==null || i.getAttrB().equals(attrC) ) {

                    results.add(i);

                }
            }

            return results;
        }
    }
}


The implementation would look somethign like this (bear in mind the actual Item class would have much more than three attributes):

ItemManager itemManager = new ItemManager();  

List&lt;Item&gt; items =
    itemManger.getSearch()    
    .setAttrA(a)
    .setAttrB(b)
    .search();


There's a number of ways I can think of to improve this, but I didn't want to include them all (so they're welcome).
You can generify your ItemManager

class ItemManager&lt;T extends Item&gt; {

    List&lt;T&gt; items;

    public ItemManager() {

        items = Database.retrieveItems();

    }
}


The search method can be refactored with this help of CollectionUtils like this

public Collection&lt;Item&gt; search() {
    return getMatchedItems();
}


And her is getMatchedItems()

public Collection&lt;Item&gt; getMatchedItems() {
    CollectionUtils.select(items, new Predicate() {
    public boolean evaluate(Object o) {
        Item item = (Item)o;
        return containsA(item) &amp;&amp; containsB(item) &amp;&amp; containsC(item) //explain below 
    }
    });

    return items
}


IMO its better to create seperate methods like containsA() , containsB().... 

Because as you mentioned you have many attributes(let presume 50), then one big if will sooner or later lend you in problems like readability, maintainability and testing.
You may say that creating separate methods may degrade your performance but jvm handles method inlining pretty well.