A Lightweight Java-based Statechart Library

GitHub Repository

https://github.com/SkafteDev/Java-StateCharts

Project Description

A lightweight Java library for building statechart and event-based logic using a clear, expressive, and framework-independent approach. Inspired by modern state machine and statechart principles, it provides a structured way to model complex behavior, transitions, and events without locking you into any specific runtime or architectural style. The library focuses on readability, making state-based logic easier to reason about, test, and maintain. It supports hierarchical states, parallel states, guards, actions, and event-driven transitions, allowing developers to replace scattered conditional logic with a clean, well-organized state model. Several examples and a simulator is provided to illustrate how discrete events or real-time simulation events can be fed into a statechart.

Feature Highlights

  • Suitable for building protocols, workflows, device logic, and other event-based systems.
  • Clear and expressive API for defining states, transitions, and events.
  • Support for hierarchical (nested) and parallel states for modeling complex behavior.
  • Guards, actions, and entry/exit handlers for full control of state logic.
  • Strong emphasis on testability of event-driven behavior and states.
  • Designed to be lightweight and easy to integrate.