I have the following pattern appearing many times in my Java code and was wondering how some of you might refactor it.
Object obj1 = buildObj1();
if (obj1 != null) {
return obj1;
}
Object obj2 = buildObj2();
if (obj2 != null) {
return obj2;
}
Object obj3 = buildObj3();
if (obj3 != null) {
return obj3;
}