-
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
5 changed files
with
137 additions
and
3 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
src/main/java/com/github/kerbity/kerb/event/SettableEvent.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,47 @@ | ||
/* | ||
* 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.Settable; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* Used to create a single settable event. | ||
* An event used as a request to get a value from the clients. | ||
* | ||
* @param <T> The type of class to get. | ||
*/ | ||
public class SettableEvent<T> implements Event, Settable<T, SettableEvent<T>> { | ||
|
||
private @Nullable T instance; | ||
|
||
@Override | ||
public @NotNull SettableEvent<T> set(@Nullable T instance) { | ||
this.instance = instance; | ||
return this; | ||
} | ||
|
||
@Override | ||
public @Nullable T get() { | ||
return this.instance; | ||
} | ||
} |
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
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
49 changes: 49 additions & 0 deletions
49
src/main/java/com/github/kerbity/kerb/indicator/Settable.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,49 @@ | ||
/* | ||
* 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; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* Indicates if the class is settable | ||
* to a specific type. | ||
* | ||
* @param <T> The specific settable type. | ||
* @param <C> The settable class type. | ||
*/ | ||
public interface Settable<T, C extends Settable<T, C>> { | ||
|
||
/** | ||
* Used to set the settable value. | ||
* | ||
* @param instance The instance of the value. | ||
* @return This instance. | ||
*/ | ||
@NotNull C set(@Nullable T instance); | ||
|
||
/** | ||
* Used to get the settable value. | ||
* | ||
* @return The instance of the value. | ||
*/ | ||
@Nullable T get(); | ||
} |
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