How to use Spring state machine for an Order object

Viewed 6896

I'm trying to use Spring State Machine in my project, because there is an object is Order with several state

  • NEW
  • PAID
  • PACKAGED
  • DELIVERED
  • CANCELED
  • RETURNED

That object could be implement as following

public class Order {
  private String id;
  private Customer customer;
  private OrderState state;
// Some other fields with getter and setter
}

and I introduced OrderService, get order from DB, set some information including OrderState, and then save to DB.

However I don't know how to apply Spring state machine into this one, is it too complex to use with simple purpose like that?

1 Answers
Related