I am trying to validate a set of values 'RecordStatus' and 'Condition'. Have come up with the below method.
Define a class RecordStatusCodition with strings recordStatus and condition.
Define a class RecordStatusCoditionValidator implemented as below
ArrayList validList = new ArrayList() {{
add(new RecordStatusCodition ("CREATED","A")); add(new RecordStatusCodition ("INSERTED","B")); add(new RecordStatusCodition ("INSERTED","A")); }};
public boolean isProcessed(RecordStatusCodition recordStatusCodition ) {
return checkList.contains(recordStatusCodition);
}
}
This class is being called from my code elsewhere to check for the conditions
if(!RecordStatusCoditionValidator.isProcessed(new RecordStatusCodition("","")))
// do processing
}
Similar to the above, there are various other conditions with different lists, which might have to be changed frequently
Although this works fine, I need to know if there is a better approach for this since this is something which most part of my code will be depending on?