Add isInitialized method to configuration classes and update version#368
Merged
Conversation
- introduce isInitialized method to check if the config has been loaded from disk - update SpongeJsonConfigClass and SpongeYmlConfigClass to implement the new method
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds an initialization-state API to SpongeConfigClass and updates JSON/YML config implementations to expose whether their lazy manager has been created, alongside a version bump.
Changes:
- Introduce
isInitialized()as a new abstract API onSpongeConfigClass. - Refactor JSON/YML config classes to use an explicit
managerLazydelegate and use it forisInitialized(). - Bump project version to
3.19.0.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/config/SpongeYmlConfigClass.kt | Refactors manager initialization and adds isInitialized() implementation for YML configs |
| surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/config/SpongeJsonConfigClass.kt | Refactors manager initialization and adds isInitialized() implementation for JSON configs |
| surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/config/SpongeConfigClass.kt | Adds new abstract isInitialized() API |
| surf-api-core/surf-api-core/api/surf-api-core.api | Updates published API surface to include isInitialized() and finalizes manager overrides |
| gradle.properties | Version bump to 3.19.0 |
Comment on lines
+36
to
43
| private val managerLazy = lazy { | ||
| surfConfigApi.createSpongeJsonConfigManager( | ||
| configClass, | ||
| configFolder, | ||
| fileName, | ||
| migrationBuilder | ||
| ) | ||
| } |
| * The manager is created using [SurfConfigApi.createSpongeJsonConfigManager] | ||
| * with [configClass], [configFolder], [fileName] and [migrationBuilder]. | ||
| */ | ||
| final override val manager by managerLazy |
Comment on lines
+81
to
+84
| /** | ||
| * Whether the config has been initialized and loaded from disk. | ||
| */ | ||
| abstract fun isInitialized(): Boolean |
Comment on lines
+36
to
43
| private val managerLazy = lazy { | ||
| surfConfigApi.createSpongeYmlConfigManager( | ||
| configClass, | ||
| configFolder, | ||
| fileName, | ||
| migrationBuilder | ||
| ) | ||
| } |
Comment on lines
+51
to
+55
| final override val manager by managerLazy | ||
|
|
||
| final override fun isInitialized(): Boolean { | ||
| return managerLazy.isInitialized() | ||
| } |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces an
isInitialized()method to the configuration class hierarchy, allowing consumers to check if a configuration has been loaded from disk. It also refactors the initialization logic for configuration managers to improve encapsulation and consistency. The project version is incremented as part of this release.Config system improvements
isInitialized()toSpongeConfigClass, enabling all config types to report their initialization state. [1] [2]isInitialized()in bothSpongeJsonConfigClassandSpongeYmlConfigClassby exposing the state of their respective lazy manager initializations. [1] [2] [3]SpongeJsonConfigClassandSpongeYmlConfigClassto use a privatemanagerLazyproperty, improving encapsulation and allowing access to the initialization state. [1] [2]Versioning
3.19.0ingradle.propertiesto reflect these API and implementation changes.