java – Method with 2 parameters and IF statement to check all possibilities. What is the best approach?

So, let's say I have a method:

public object getResult (Long A, Long B) {...}

And I want to check all possible states, so I did:

if (A == null && B == null) {...}
if else (A! = null && B == null) {...}
if else (A == null && B! = null) {...}
if else (A! = null && B! = null) {...}

I was looking for a better solution, but I did not find anything. Indices to improve the appearance? Maybe a switch? Or nested FIs?