I have a lot more of these else-if conditions that I have not included. How could I refactor this to reduce the cyclomatic complexity?
if (ONE.equalsIgnoreCase(eachTag.getNodeName()))
{
myclassDto.setOne(formatter
.getElementValueAfterNullCheckWithTrim((Element) eachTag));
}
else if (TWO.equalsIgnoreCase(eachTag.getNodeName()))
{
myclassDto.setTwo(formatter
.getElementValueAfterNullCheckWithTrim((Element) eachTag));
}
else if (THREE.equalsIgnoreCase(eachTag.getNodeName()))
{
myclassDto.setThree(formatter
.getElementValueAfterNullCheckWithTrim((Element) eachTag));
}
else if (FOUR.equalsIgnoreCase(eachTag.getNodeName()))
{
myclassDto.setFour(formatter
.getElementValueAfterNullCheckWithTrim((Element) eachTag));
}
else if (FIVE.equalsIgnoreCase(eachTag.getNodeName()))
{
myclassDto.setFive(formatter
.getElementValueAfterNullCheckWithTrim((Element) eachTag));
}
else if (SIX.equalsIgnoreCase(eachTag.getNodeName()))
{
myclassDto.setSix(formatter
.getElementValueAfterNullCheckWithTrim((Element) eachTag));
}
How can I reduce the cyclomatic complexity of this function in java?