Skip to content

fix: New keyed types did not survive a save/load cycle.#101

Merged
svaningelgem merged 10 commits intomasterfrom
claude/fix-enum-type-check-JRU4R
Dec 15, 2025
Merged

fix: New keyed types did not survive a save/load cycle.#101
svaningelgem merged 10 commits intomasterfrom
claude/fix-enum-type-check-JRU4R

Conversation

@svaningelgem
Copy link
Collaborator

No description provided.

claude and others added 10 commits December 15, 2025 18:18
- Extended getStaticFieldName to check interface constants
- Added recursive checkInterfaceFields method to traverse interface hierarchy
- Added testInterfaceElement test case to verify interface field detection
- Fixes issue where interface constants were not properly detected
- Removed GENERIC_TOSTRING_PATTERN check condition
- Always attempt to find static field name (class or interface)
- Removed unused Pattern and Matcher imports
- Minimal change to support custom toString() methods
- Added declaredType field to NestedNode to track field's declared type
- Pass field type through YamlWriter chain (writeValue -> writeScalar -> formatValue)
- Extended getStaticFieldName to accept declaredType parameter
- Added searchByDeclaredType method (incomplete - needs clarification)

Note: Current implementation incomplete - StaticMat doesn't implement
StaticInterfaceElements, so checking declared type's interfaces won't
find the constants. Need clarification on approach.
- Added WeakHashMap registry to track static field instances and their sources
- Register static fields when loaded via getFieldValue
- Check registry first in getStaticFieldName before searching
- Register fields lazily during searchByDeclaredType
- Minimal solution: tracks "original type" during construction/load as suggested
- Register static field sources during loadFields, BEFORE YAML overwrites them
- Scan field values at their initialized state (e.g., StaticInterfaceElements.A)
- Search package for common interface naming patterns
- Registry now captures values at construction/load time, not during save
- This correctly implements "tracking during load" as suggested
Registration now only happens during load phase, not during field lookup
- Register in buildYamlContents before serialization
- Handles first save before any load has occurred
- Discovers StaticInterfaceElements from StaticMat field type
- Now works for both save-first and load-first scenarios
Completely scratch the registry/tracking approach. Now simply:
- Check if value implements org.bukkit.Keyed (via reflection)
- Call getKey().getKey() to get the key string
- Replace dots with underscores
- Much simpler solution for Bukkit/Spigot integration
@svaningelgem svaningelgem changed the title fix: fix: New keyed types did not survive a save/load cycle. Dec 15, 2025
@sonarqubecloud
Copy link

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 80.00000% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/main/java/org/avarion/yaml/YamlWriter.java 80.00% 4 Missing ⚠️
Files with missing lines Coverage Δ
.../main/java/org/avarion/yaml/YamlFileInterface.java 90.03% <ø> (ø)
src/main/java/org/avarion/yaml/YamlWriter.java 90.36% <80.00%> (-3.76%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@svaningelgem svaningelgem merged commit 77b6d49 into master Dec 15, 2025
3 checks passed
@svaningelgem svaningelgem deleted the claude/fix-enum-type-check-JRU4R branch December 15, 2025 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants