jeudi 22 janvier 2015

Is RETURN going out the method at any moment, even if it is in a complex IF statement?

I have a code like this:



private final Something (SomethingElse nimportant)

List list = (List) mListOfSomething.get(SOME_ENUMS);

if (list == null)
// dont ask me why not list.isEmpty(), I'm not the author of this code)
list = new ArrayList();

if (transaction.getPartner() instanceof IAnotherSomething) {

IAnotherSomething ias = (IAnotherSomething) transaction.getPartner();
return ias.getContract().next();
}

// NIMPORTANT code ommited, produces boolean "something"

if (something) {
// something happens
list.add(contract)
}

if (!something) {
// something else happens
list.add(contract)
}
}

return (IContract) list.get(0);
}


I have a brainpain - IF the list IS empty, (or == null) AND this if statement (transaction.getPartner() instanceof IAnotherSomething) is true, the method shoud exit on this if statement and should return ias.getContract().next() - or am I wrong about this?


Aucun commentaire:

Enregistrer un commentaire