|
| 1 | +package net.onelitefeather.guira; |
| 2 | + |
| 3 | +import de.icevizion.aves.map.BaseMap; |
| 4 | +import net.onelitefeather.guira.data.SetupData; |
| 5 | +import org.jetbrains.annotations.Contract; |
| 6 | +import org.jetbrains.annotations.NotNull; |
| 7 | +import org.jetbrains.annotations.Nullable; |
| 8 | +import org.jetbrains.annotations.UnmodifiableView; |
| 9 | + |
| 10 | +import java.util.Map; |
| 11 | +import java.util.Optional; |
| 12 | +import java.util.UUID; |
| 13 | + |
| 14 | +/** |
| 15 | + * The (@link SetupDataService} is responsible for managing setup data during a runtime session. |
| 16 | + * It allows adding, removing, and retrieving setup data associated with a unique identifier (UUID). |
| 17 | + * |
| 18 | + * @param <T> the type of setup data |
| 19 | + * @author thEvilReaper |
| 20 | + * @version 1.0.0 |
| 21 | + * @since 0.1.0 |
| 22 | + */ |
| 23 | +public interface SetupDataService<T extends SetupData<? extends BaseMap>> { |
| 24 | + |
| 25 | + /** |
| 26 | + * Creates a new instance of SetupDataService. |
| 27 | + * |
| 28 | + * @param <T> the type of setup data |
| 29 | + * @return a new instance of SetupDataService |
| 30 | + */ |
| 31 | + @Contract(pure = true) |
| 32 | + static @NotNull <T extends SetupData<? extends BaseMap>> SetupDataService<T> create() { |
| 33 | + return new SetupDataServiceImpl<>(); |
| 34 | + } |
| 35 | + |
| 36 | + /** |
| 37 | + * Adds a new setup data to the service. |
| 38 | + * |
| 39 | + * @param uuid the unique identifier for the setup data |
| 40 | + * @param data the setup data to add |
| 41 | + */ |
| 42 | + void add(@NotNull UUID uuid, @NotNull T data); |
| 43 | + |
| 44 | + /** |
| 45 | + * Removes the setup data associated with the given UUID. |
| 46 | + * |
| 47 | + * @param uuid the unique identifier for the setup data |
| 48 | + * @return an optional containing the removed setup data, or empty if not found |
| 49 | + */ |
| 50 | + @NotNull Optional<@Nullable T> remove(@NotNull UUID uuid); |
| 51 | + |
| 52 | + /** |
| 53 | + * Retrieves the setup data associated with the given UUID. |
| 54 | + * |
| 55 | + * @param uuid the unique identifier for the setup data |
| 56 | + * @return an optional containing the setup data, or empty if not found |
| 57 | + */ |
| 58 | + @NotNull Optional<@Nullable T> get(@NotNull UUID uuid); |
| 59 | + |
| 60 | + /** |
| 61 | + * Returns an unmodifiable view of the setup data map. |
| 62 | + * |
| 63 | + * @return an unmodifiable view |
| 64 | + */ |
| 65 | + @NotNull |
| 66 | + @UnmodifiableView |
| 67 | + Map<UUID, T> getView(); |
| 68 | +} |
0 commit comments