If you have to check 3 conditions, and in an cases return the same value, like in this example:
if (designatorType != AttributeDesignator.ENVIRONMENT_TARGET)
return new EvaluationResult(BagAttribute.
createEmptyBag(attributeType));
if (! attributeId.toString().equals("processor-load"))
return new EvaluationResult(BagAttribute.
createEmptyBag(attributeType));
if (! attributeType.toString().equals(IntegerAttribute.identifier))
return new EvaluationResult(BagAttribute.
createEmptyBag(attributeType));
Wouldn’t it be better to rewrite it like this
if (designatorType != AttributeDesignator.ENVIRONMENT_TARGET) ||
(! attributeId.toString().equals("processor-load")) ||
(! attributeType.toString().equals(IntegerAttribute.identifier)) ||
return new EvaluationResult(BagAttribute.
createEmptyBag(attributeType));
This is probably highly subjective but still I hope someone can give a valid answer :-).
1 Answer