My use case requires me to implement multiple validators which implement the interface:
public interface Validator {
boolean validate(Object o);
}
Based on the business group of the Object o, a different combination of validators need to be applied.
For each business group, I plan to maintain a list of Validators. This list will be maintained in an external configuration store. Ex:
BusinessGroupA {
Validators = [v1,v2,v3,v4]
}
BusinessGroupB {
Validators = [v3,v6]
}
What seems to be a good way to uniquely identify each validator from the list? Should v1,v2 be spring ids corresponding to their respective validators or do I need to explicitly create a unique identifier for each such validator and map that internally through a hashmap in my code?
Is there a better way to do this?