@Override public boolean equals(Object obj) { if (obj instanceof StateTransition) { @SuppressWarnings("unchecked") StateTransition<T> other = (StateTransition<T>) obj; return action == other.action && sourceState.getName().equals(other.sourceState.getName()) && targetState.getName().equals(other.targetState.getName()); } else { return false; } }
private Map<String, State<T>> loadStates(final Collection<State<T>> validStates) { Map<String, State<T>> tmp = new HashMap<>(4); for (State<T> state : validStates) { tmp.put(state.getName(), state); } return Collections.unmodifiableMap(tmp); }
private void addComputationState( SharedBufferAccessor<T> sharedBufferAccessor, List<ComputationState> computationStates, State<T> currentState, NodeId previousEntry, DeweyNumber version, long startTimestamp, EventId startEventId) throws Exception { ComputationState computationState = ComputationState.createState( currentState.getName(), previousEntry, version, startTimestamp, startEventId); computationStates.add(computationState); sharedBufferAccessor.lockNode(previousEntry); }
public NFAState createInitialNFAState() { Queue<ComputationState> startingStates = new LinkedList<>(); for (State<T> state : states.values()) { if (state.isStart()) { startingStates.add(ComputationState.createStartState(state.getName())); } } return new NFAState(startingStates); }
private <T> Set<Tuple2<String, StateTransitionAction>> unfoldTransitions(final State<T> state) { final Set<Tuple2<String, StateTransitionAction>> transitions = new HashSet<>(); for (StateTransition<T> transition : state.getStateTransitions()) { transitions.add(Tuple2.of( transition.getTargetState().getName(), transition.getAction())); } return transitions; }
private State<T> copy(final State<T> state) { final State<T> copyOfState = createState( NFAStateNameHandler.getOriginalNameFromInternal(state.getName()), state.getStateType()); for (StateTransition<T> tStateTransition : state.getStateTransitions()) { copyOfState.addStateTransition( tStateTransition.getAction(), tStateTransition.getTargetState().equals(tStateTransition.getSourceState()) ? copyOfState : tStateTransition.getTargetState(), tStateTransition.getCondition()); } return copyOfState; }
stateMap.put(state.getName(), state);
@Test public void testNoUnnecessaryStateCopiesCreated() { final Pattern<Event, Event> pattern = Pattern.<Event>begin("start").where(startFilter) .notFollowedBy("not").where(startFilter) .followedBy("oneOrMore").where(startFilter).oneOrMore() .followedBy("end").where(endFilter); final NFACompiler.NFAFactoryCompiler<Event> nfaFactoryCompiler = new NFACompiler.NFAFactoryCompiler<>(pattern); nfaFactoryCompiler.compileFactory(); int endStateCount = 0; for (State<Event> state : nfaFactoryCompiler.getStates()) { if (state.getName().equals("end")) { endStateCount++; } } assertEquals(1, endStateCount); }
if (untilCondition != null) { State<T> sinkStateCopy = copy(sinkState); originalStateMap.put(sinkState.getName(), sinkStateCopy);
if (untilCondition != null) { singletonState.addProceed( originalStateMap.get(proceedState.getName()), new RichAndCondition<>(proceedCondition, untilCondition));
State<T> sinkStateCopy = copy(sinkState); loopingState.addProceed(sinkStateCopy, new RichAndCondition<>(proceedCondition, untilCondition)); originalStateMap.put(sinkState.getName(), sinkStateCopy);
currentState.getName(), event.getEventId(), previousEntry,
private State<T> getStateByName(String name, NFA<T> nfa) { for (State<T> state: nfa.states) { if (state.getName().equals(name)) { return state; } } return null; }
@Override public boolean apply(@Nullable ComputationState<T> input) { return input != null && input.getState().getName().equals(BEGINNING_STATE_NAME); } }).getState();