I have inherited the Java function below, and it works the way it should, but you have to look at it for a minute to figure out exactly what is going on. Is there a more succinct or elegant way to encode this logic?
private Float applyFactors(Float originalValue, Float localFactor, Float globalFactor){
if (globalFactor == null || globalFactor == 0){
if (localFactor == null || localFactor == 0){
return null;
} else {
return localFactor * originalValue;
}
} else {
if (localFactor == null || localFactor == 0){
return globalFactor * originalValue;
} else {
return localFactor * originalValue * globalFactor;
}
}
}