title: How to implement a FSM - Finite State Machine in Java
body: <p>I have something to do for work and I need your help.
  We want to implement a <code>FSM - Finite State Machine</code>, to identify char sequence(like: A, B, C, A, C), and tell if it accepted.</p>
  
  <p>We think to implement three classes: <code>State</code>, <code>Event</code> and <code>Machine</code>.
  The <code>state</code> class presents a node in the <code>FSM</code>, we thought to implement it with <code>State design pattern</code>, every node will extend from the abstract class state and every class would handle different types of events and indicate transitions to a new state. Is it good idea in your opinion?</p>
  
  <p>Second thing, we don't know how to save all the transitions. Again we thought to implement it with some kind of <code>map</code>, that hold the starting point and gets some kind of vector with the next states, but I'm not sure thats a good idea. </p>
  
  <p>I would be happy to get some ideas of how to implement it or maybe you can give me some starting points.</p>
  
  <p>How should I save the FSM, meaning how should I build the tree at the beginning of the program?
  I googled it and found a lot of examples but nothing that helps me.</p>
  
  <p>Thanks a lot.</p>