On 11/8/11 2:15 PM, Wanja Gayk wrote:
> In article<3iYsq.9363$>,
> says...
>
>> Sounds almost like you want a visitor pattern instead, or an
>> intermediate object:
>>
>> public class SearchResult {
>> public boolean isSingleArray() { ... }
>> public boolean isMultipleArray() { ... }
>>
>> // Throws IllegalStateException if !isSingleArray
>> public SingleArray getSingleArray() { ... }
>> // Throws IllegalStateException if !isMutipleArray
>> public MultipleArray getMultipleArray() { ... }
>>
>> }
>
> That doesn't seem to be any better than the infamous instaceof-cascade -
> I'd rather say it's even uglier.
Being converted to a visitor pattern would be better, granted, but the
OP was extremely vague on the requirements.