Way to handle two-dimensional conditions when creating objects?
<p>I have two variables, <code>foo</code> and <code>bar</code>, that determine which kind of object I need to create. At the moment, both of these can hold two different values, and the objects are created as such:</p>

<pre><code>Result createResult(int foo, int bar) {
    if(foo == 0) {
        if(bar == 0) return new FirstResult();
        if(bar == 1) return new SecondResult();
    }else if(foo == 1) {
        if(bar == 0) return new ThirdResult();
        if(bar == 1) return new FourthResult();
    }
    return null;
}

// Common interface for all the objects
interface Result {

}
</code></pre>

<p>This work for just these four types, but what if there's more types? How should the object creation be handled so that it would be more efficient?</p>