mercredi 5 décembre 2018

How to restrict status transition values to only valid values in Java?

I have to implement a status transition validation, like:

'P' -> 'W' -> 'M' -> 'F' -> 'G'
'P' -> 'I' -> 'B' -> 'M' -> 'F' -> 'G'

where "->" denotes "can move to"

In short, a particular status can move to only certain status, but not other status.

Note: There are finite number of status in the system.

I have read about Strategy pattern, but I did not feel this particular problem suited to it. What will be best way to implement this in Java 8 ?

Aucun commentaire:

Enregistrer un commentaire