lundi 20 février 2017

A better way to replace many if conditions

I'm pretty new with Java.

I would like to be advised if there is an intelligent way to replace many many if statement.

The problem: Let's say i have a validator class that check tags in incoming message. Each tag can be mandatory or not for my application.

Instead of using many if statements :

if (isExistTag1)
else if (isExistTag2)
else if (isExistTag3)
.
.
.
else if (isExistTagN)

what can be an improved way?

Thank you.

Aucun commentaire:

Enregistrer un commentaire