Package metricapp.utility.stateTransitionUtils

This package is a module to manage the transition between two states for Elements of the Grid and others.

See: Description

Package metricapp.utility.stateTransitionUtils Description

This package is a module to manage the transition between two states for Elements of the Grid and others. It was born from the need to decouple business and logic controllers to state transitions of the Elements. Our Elements was structured with a State Machine Diagram in our documentation, this module implements transition actions.

To achieve these needs, this module implements different and well integrated solutions:

The Command Pattern is used to bring users an object, configured and ready to run, that he can easily execute when he needs. StateTransitionCommand is the interface of this kind of object.

This module doesn't implement directly the State Pattern, but it is inspired of it. Elements change their behaviour according to internal state in transparent way. State is the enumeration where the states are described.

Factory Pattern is implemented in single packages. Every entity has a factory that can create new StateTransitionCommand, configured and ready to run. In this way the user can easily get a configured command, he has only to execute it. With different objects released to user, the speed of execution in multithread scenario is incremented, it permits massive use of parallel work.

Abstract Factory Pattern is used to uniform behaviour of different factories. Different entities has the same interface. This improve the readiness of the code, it's user friendly and it is debuggable and manageable.

Every Factory use Reflection to inspect the entity state transition package to retrieve the correct transition. This is the most flexible structure, in fact to add a transition a user just needs to create a new class in the entity state transition package. No other actions are required.

Every Factory is instanced with the use of Singleton Pattern, to guarantee performances. It's not necessary for abstract factory to create a new object at every request. Singleton is implemented by Initialization-on-demand holder idiom

Example of use: AbstractStateTransitionFactory.getFactory(Entity.Metric).transition(oldMetric, newMetric).execute();