-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
160 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/main/java/com/github/kerbity/kerb/event/CompletableEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Kerb | ||
* Event and request distributor server software. | ||
* | ||
* Copyright (C) 2023 Smuddgge | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.github.kerbity.kerb.event; | ||
|
||
import com.github.kerbity.kerb.indicator.Completable; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Used to create a completable event. | ||
* This lets you check if an event is completed | ||
* and lets you set to true when listening to it. | ||
* This essentially makes the event act as a task | ||
* to complete. | ||
*/ | ||
public class CompletableEvent implements Event, Completable<CompletableEvent> { | ||
|
||
private boolean isComplete; | ||
|
||
/** | ||
* Used to create a completable event. | ||
* An event that can be marked as completed. | ||
*/ | ||
public CompletableEvent() { | ||
this.isComplete = false; | ||
} | ||
|
||
@Override | ||
public @NotNull CompletableEvent complete() { | ||
this.isComplete = true; | ||
return this; | ||
} | ||
|
||
@Override | ||
public @NotNull CompletableEvent setComplete(boolean isComplete) { | ||
this.isComplete = isComplete; | ||
return this; | ||
} | ||
|
||
@Override | ||
public boolean isComplete() { | ||
return this.isComplete; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/com/github/kerbity/kerb/indicator/Completable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Kerb | ||
* Event and request distributor server software. | ||
* | ||
* Copyright (C) 2023 Smuddgge | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.github.kerbity.kerb.indicator; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Indicates if a class is completable. | ||
* | ||
* @param <T> The instance of the class that | ||
* is completable. | ||
*/ | ||
public interface Completable<T> { | ||
|
||
/** | ||
* Used to complete the task. | ||
* | ||
* @return The instance of the completable class. | ||
*/ | ||
@NotNull T complete(); | ||
|
||
/** | ||
* Used to set if the class is completed. | ||
* | ||
* @param isComplete True if the class is completed. | ||
* @return The instance of the completable class. | ||
*/ | ||
@NotNull T setComplete(boolean isComplete); | ||
|
||
/** | ||
* Used to check if the class is completed. | ||
* | ||
* @return True if the class is completed. | ||
*/ | ||
boolean isComplete(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters