Shreyas arya

Generation

generate functionMon, 23 Jan 2023

We need to create validators for each status. The validator will check if transition from current state is allowed or not. WorkflowExecutionValidator will pick up an appropriate validator from a list and check if transition is allowed. Validators are implemented for each workflow execution status Validators are applied in production code

class WorkflowExecutionValidator { List<WorkflowExecutionStatusValidator> validators; public boolean isTransitionAllowed(WorkflowExecutionStatus currentStatus, WorkflowExecutionStatus newStatus){ //get validator by currentStatus, get a list of validators, check if the new status is in the list of allowed statuses for(WorkflowExecutionStatusValidator validator: validators){ if(validator.getCurrentStatus() == currentStatus){ return validator.isAllowed(newStatus); } } return false; } }

Questions about programming?Chat with your personal AI assistant