I hava a function like this:
doSomething(){
Object a = getA() //can return null
// a lot of additional code
}
... but i want to add a possibility to give object a into method so i created a new method:
doSomething(){
doSomething(null);
}
doSomething(Object a){
if(a == null){
a = getA()
}
}
but this is not correct because the object passed into method can also be null and then i wanto to it to null, not use getA() method so i did something like this:
doSomething(){
doSomething(null, false);
}
doSomething(Object a, boolean useObject){
if(!useObject){
a = getA()
}
but this seems kind of ugly. Is there a better solution?