class StateMachine implements MatchProcessor {

    @Override
    public MatchProcessorResult process(StringBuilder characterBuffer, int firstModifiableCharacterInBuffer,
            MatchResult matchResult) {

        // modify stream
        MatchProcessorResult result = transitions.process(characterBuffer, firstModifiableCharacterInBuffer,
                matchResult);

        // change state if needed
        State newState = transitions.pollNewState();
        if (newState != currentState) {
            changeStateTo(newState);
        }

        return result;
    }

    public  StateMachine(State initialState, DelegatingMatcher delegatingMatcher);

}