/** * Add flows to the split, in addition to the current state already present in the parent builder. * * @param flows more flows to add to the split * @return the parent builder */ public FlowBuilder<Q> add(Flow... flows) { Collection<Flow> list = new ArrayList<>(Arrays.asList(flows)); String name = "split" + (parent.splitCounter++); int counter = 0; State one = parent.currentState; Flow flow = null; if (!(one == null || one instanceof FlowState)) { FlowBuilder<Flow> stateBuilder = new FlowBuilder<>(name + "_" + (counter++)); stateBuilder.currentState = one; flow = stateBuilder.build(); } else if (one instanceof FlowState && parent.states.size() == 1) { list.add(((FlowState) one).getFlows().iterator().next()); } if (flow != null) { list.add(flow); } State next = parent.createState(list, executor); parent.currentState = next; return parent; }
protected Flow flow() { if (!dirty) { // optimization in case this method is called consecutively return flow; } flow = new SimpleFlow(name); // optimization for flows that only have one state that itself is a flow: if (currentState instanceof FlowState && states.size() == 1) { return ((FlowState) currentState).getFlows().iterator().next(); } addDanglingEndStates(); flow.setStateTransitions(transitions); dirty = false; return flow; }
private void validateFirstStep(State startState) throws JobExecutionException { while(true) { if(startState instanceof DelegateState) { startState = ((DelegateState) startState).getState(); } else if(startState instanceof JsrStepState) { String stepName = startState.getName().substring(startState.getName().indexOf(".") + 1, startState.getName().length()); Step step = ((JsrStepState) startState).getStep(stepName); if(step instanceof DecisionStep) { throw new JobExecutionException("Decision step is an invalid first step"); } else { break; } } else if(startState instanceof FlowState){ Flow firstFlow = ((FlowState) startState).getFlows().iterator().next(); startState = firstFlow.getStates().iterator().next(); } else { break; } } }
protected Flow flow() { if (!dirty) { // optimization in case this method is called consecutively return flow; } flow = new SimpleFlow(name); // optimization for flows that only have one state that itself is a flow: if (currentState instanceof FlowState && states.size() == 1) { return ((FlowState) currentState).getFlows().iterator().next(); } addDanglingEndStates(); flow.setStateTransitions(transitions); dirty = false; return flow; }
/** * Add flows to the split, in addition to the current state already present in the parent builder. * * @param flows more flows to add to the split * @return the parent builder */ public FlowBuilder<Q> add(Flow... flows) { Collection<Flow> list = new ArrayList<Flow>(Arrays.asList(flows)); String name = "split" + (parent.splitCounter++); int counter = 0; State one = parent.currentState; Flow flow = null; if (!(one == null || one instanceof FlowState)) { FlowBuilder<Flow> stateBuilder = new FlowBuilder<Flow>(name + "_" + (counter++)); stateBuilder.currentState = one; flow = stateBuilder.build(); } else if (one instanceof FlowState && parent.states.size() == 1) { list.add(((FlowState) one).getFlows().iterator().next()); } if (flow != null) { list.add(flow); } State next = parent.createState(list, executor); parent.currentState = next; return parent; }
/** * Add flows to the split, in addition to the current state already present in the parent builder. * * @param flows more flows to add to the split * @return the parent builder */ public FlowBuilder<Q> add(Flow... flows) { Collection<Flow> list = new ArrayList<Flow>(Arrays.asList(flows)); String name = "split" + (parent.splitCounter++); int counter = 0; State one = parent.currentState; Flow flow = null; if (!(one == null || one instanceof FlowState)) { FlowBuilder<Flow> stateBuilder = new FlowBuilder<Flow>(name + "_" + (counter++)); stateBuilder.currentState = one; flow = stateBuilder.build(); } else if (one instanceof FlowState && parent.states.size() == 1) { list.add(((FlowState) one).getFlows().iterator().next()); } if (flow != null) { list.add(flow); } State next = parent.createState(list, executor); parent.currentState = next; return parent; }
protected Flow flow() { if (!dirty) { // optimization in case this method is called consecutively return flow; } flow = new SimpleFlow(name); // optimization for flows that only have one state that itself is a flow: if (currentState instanceof FlowState && states.size() == 1) { return ((FlowState) currentState).getFlows().iterator().next(); } addDanglingEndStates(); flow.setStateTransitions(transitions); dirty = false; return flow; }
protected Flow flow() { if (!dirty) { // optimization in case this method is called consecutively return flow; } flow = new SimpleFlow(name); // optimization for flows that only have one state that itself is a flow: if (currentState instanceof FlowState && states.size() == 1) { return ((FlowState) currentState).getFlows().iterator().next(); } addDanglingEndStates(); flow.setStateTransitions(transitions); dirty = false; return flow; }
private void validateFirstStep(State startState) throws JobExecutionException { while(true) { if(startState instanceof DelegateState) { startState = ((DelegateState) startState).getState(); } else if(startState instanceof JsrStepState) { String stepName = startState.getName().substring(startState.getName().indexOf(".") + 1, startState.getName().length()); Step step = ((JsrStepState) startState).getStep(stepName); if(step instanceof DecisionStep) { throw new JobExecutionException("Decision step is an invalid first step"); } else { break; } } else if(startState instanceof FlowState){ Flow firstFlow = ((FlowState) startState).getFlows().iterator().next(); startState = firstFlow.getStates().iterator().next(); } else { break; } } }
private void validateFirstStep(State startState) throws JobExecutionException { while(true) { if(startState instanceof DelegateState) { startState = ((DelegateState) startState).getState(); } else if(startState instanceof JsrStepState) { String stepName = startState.getName().substring(startState.getName().indexOf(".") + 1, startState.getName().length()); Step step = ((JsrStepState) startState).getStep(stepName); if(step instanceof DecisionStep) { throw new JobExecutionException("Decision step is an invalid first step"); } else { break; } } else if(startState instanceof FlowState){ Flow firstFlow = ((FlowState) startState).getFlows().iterator().next(); startState = firstFlow.getStates().iterator().next(); } else { break; } } }
private void validateFirstStep(State startState) throws JobExecutionException { while(true) { if(startState instanceof DelegateState) { startState = ((DelegateState) startState).getState(); } else if(startState instanceof JsrStepState) { String stepName = startState.getName().substring(startState.getName().indexOf(".") + 1, startState.getName().length()); Step step = ((JsrStepState) startState).getStep(stepName); if(step instanceof DecisionStep) { throw new JobExecutionException("Decision step is an invalid first step"); } else { break; } } else if(startState instanceof FlowState){ Flow firstFlow = ((FlowState) startState).getFlows().iterator().next(); startState = firstFlow.getStates().iterator().next(); } else { break; } } }