https://github.com/astrapi69/state-pattern
Library for implement the state pattern
https://github.com/astrapi69/state-pattern
Last synced: 7 months ago
JSON representation
Library for implement the state pattern
- Host: GitHub
- URL: https://github.com/astrapi69/state-pattern
- Owner: astrapi69
- License: mit
- Created: 2024-08-05T09:37:10.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-16T14:52:59.000Z (over 1 year ago)
- Last Synced: 2025-06-25T23:35:09.872Z (7 months ago)
- Language: Java
- Size: 129 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Overview
[](https://github.com/astrapi69/state-pattern/actions/workflows/gradle.yml)
[](https://codecov.io/gh/astrapi69/state-pattern)
[](https://github.com/astrapi69/state-pattern/issues)
[](https://maven-badges.herokuapp.com/maven-central/io.github.astrapi69/state-pattern)
[](http://www.javadoc.io/doc/io.github.astrapi69/state-pattern)
[](http://opensource.org/licenses/MIT)
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GVBTWLRAZ7HB8)
[](https://hitsofcode.com/github/astrapi69/state-pattern/view?branch=develop)
# State Pattern Library
Welcome to the State Pattern Library! This library provides implementations of the state pattern for managing the states of various components such as buttons and wizards.
> Please support this project by simply putting a Github
> Star ⭐
>
> Share this library with friends on Twitter and everywhere else you can
>
> If you love this project
> [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GVBTWLRAZ7HB8)
## Table of Contents
- [State Pattern Library](#state-pattern-library)
- [Table of Contents](#table-of-contents)
- [Installation](#import-dependencies-to-your-project)
- [Usage](#usage)
- [Button State Machine](#button-state-machine)
- [Component State Machine](#component-state-machine)
- [Wizard State Machine](#wizard-state-machine)
- [Classes and Interfaces](#classes-and-interfaces)
- [License](#license)
## Usage
### Button State Machine
The `ButtonStateMachine` class is an abstract class that provides states for buttons.
```java
import io.github.astrapi69.design.pattern.state.button.ButtonStateMachine;
public class MyButtonStateMachine extends ButtonStateMachine {
@Override
protected void updateButtonState() {
// Implementation
}
@Override
protected void setEnabled(boolean enabled) {
button.setEnabled(enabled);
}
}
```
### Component State Machine
The ComponentStateMachine class is an abstract class that provides states for components.
```java
import io.github.astrapi69.design.pattern.state.component.ComponentStateMachine;
public class MyComponentStateMachine extends ComponentStateMachine {
@Override
protected void updateComponentState() {
// Implementation
}
@Override
protected void setEnabled(boolean enabled) {
component.setEnabled(enabled);
}
}
```
### Wizard State Machine
The WizardStateMachine class manages the state transitions for a wizard.
```java
import io.github.astrapi69.design.pattern.state.wizard.WizardStateMachine;
import io.github.astrapi69.design.pattern.state.wizard.WizardState;
public class MyWizardStateMachine extends WizardStateMachine {
public MyWizardStateMachine() {
setCurrentState(new MyFirstWizardState());
}
// Define your wizard states
}
```
## Note
No animals were harmed in the making of this library.
## License
The source code comes under the liberal MIT License, making state-pattern great for all types of applications.
## Import dependencies to your project
gradle (click to expand)
## gradle dependency
Replace the variable ${latestVersion} with the current latest version: [](https://maven-badges.herokuapp.com/maven-central/io.github.astrapi69/state-pattern)
You can first define the version in the ext section and add than the following gradle dependency to
your project `build.gradle` if you want to import the core functionality of state-pattern:
define version in file gradle.properties
```
statePatternVersion=${latestVersion}
```
or in build.gradle ext area
```
statePatternVersion = "${latestVersion}"
```
then add the dependency to the dependencies area
```
implementation("io.github.astrapi69:state-pattern:$statePatternVersion")
```
# with new libs.versions.toml file
If you use the new libs.versions.toml file for new automatic catalog versions update
```
[versions]
state-pattern-version=${latestVersion}
[libraries]
state-pattern = { module = "io.github.astrapi69:state-pattern", version.ref = "state-pattern-version" }
```
then add the dependency to the dependencies area
```
implementation libs.state.pattern
```
Maven (click to expand)
## Maven dependency
Maven dependency is now on sonatype.
Check out [sonatype repository](https://oss.sonatype.org/index.html#nexus-search;gav~io.github.astrapi69~state-pattern~~~) for latest snapshots and releases.
Add the following maven dependency to your project `pom.xml` if you want to import the core
functionality of state-pattern:
Then you can add the dependency to your dependencies:
...
```xml
${latestVersion}
```
...
...
...
```xml
io.github.astrapi69
state-pattern
${state-pattern.version}
```
...
Snapshots (click to expand)
## 📸 Snapshots
[](https://oss.sonatype.org/content/repositories/snapshots/io/github/astrapi69/state-pattern/)
This section describes how to import snapshot versions into your project.
Add the following code snippet to your gradle file in the repositories section:
```
repositories {
//...
```
```groovy
maven {
name "Sonatype Nexus Snapshots"
url "https://oss.sonatype.org/content/repositories/snapshots"
mavenContent {
snapshotsOnly()
}
}
```
```
}
```
# Donations
This project is kept as an open source product and relies on contributions to remain being
developed. If you like this library, please consider a donation
over paypal:
or over bitcoin(BTC) with this address:
bc1ql2y99q7e8psndhcc3gferk03esw3qqf677rhjy

or over FIO with this address:
FIO7tFMUVAA9cHiPPqKMfMXiSxHrbpiFyRYqTketNuM67aULuwjop

or over Ethereum(ETH) with:
0xc057D159D3C8f3311E73568b334FF6fE82EB2b7D

or over Ethereum Classic(ETC) with:
0xF708cA86D86C246B69c3F4BAe431eBbe0c2bfddD

or over Dogecoin(DOGE) with:
D5yi4Um8cpakd6yPRm2hGWuQ5nrVzhSSW1

or over Monero(XMR) with:
49bqeRQ7Bf49oJFVC72pqpe5hFbb62pfXDYPdLsadGGF81KZW2ZfrPZ8PbAVu5X2v1TYAspeczMya3cYQysNS4usRRPQHVw

or over the donation buttons at the top.
## Semantic Versioning
The versions of state-pattern are maintained with the Semantic Versioning guidelines.
Release version numbers will be incremented in the following format:
`..`
For detailed information on versioning you can visit the [wiki page](https://github.com/lightblueseas/mvn-parent-projects/wiki/Semantic-Versioning).
## What can i do to support this project
You can donate or contribute solve issues or pull request. Every support are welcome.
## Want to Help and improve it? ###
The source code for state-pattern are on GitHub. Please feel free to fork and send pull requests!
Create your own fork of [astrapi69/state-pattern/fork](https://github.com/astrapi69/state-pattern/fork)
To share your changes, [submit a pull request](https://github.com/astrapi69/state-pattern/pull/new/develop).
Don't forget to add new units tests on your changes.
## Contacting the Developers
Do not hesitate to contact the state-pattern developers with your questions, concerns, comments, bug reports, or feature requests.
- Feature requests, questions and bug reports can be reported at the [issues page](https://github.com/astrapi69/state-pattern/issues).
## Similar projects
## Credits