Skip to content

Commit ecb0188

Browse files
committed
Document codec format support and clarify DynamicOps implementations in the codec module.
1 parent 1245b93 commit ecb0188

14 files changed

Lines changed: 1859 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,19 @@ New module providing seamless Spring Boot integration with auto-configuration, f
141141

142142
### Documentation
143143

144+
#### Codec Formats Documentation
145+
- Added new `docs/codec/` section with comprehensive format documentation
146+
- [Codec Overview](docs/codec/index.md) — Format comparison, package structure, dependency guide
147+
- [JSON Support](docs/codec/json.md) — GsonOps and JacksonJsonOps usage, examples, comparison
148+
- [YAML Support](docs/codec/yaml.md) — SnakeYamlOps and JacksonYamlOps usage, examples, comparison
149+
- [TOML Support](docs/codec/toml.md) — JacksonTomlOps usage, configuration file examples
150+
- [XML Support](docs/codec/xml.md) — JacksonXmlOps usage, XML-to-JsonNode mapping
151+
- Updated [Dynamic System](docs/concepts/dynamic-system.md) with all DynamicOps implementations table
152+
- Updated [Codec System](docs/concepts/codec-system.md) with links to format-specific docs
153+
- Updated [How-To Index](docs/how-to/index.md) with Format Integration section
154+
- Updated [Custom DynamicOps Tutorial](docs/tutorials/custom-dynamicops.md) with built-in implementations reference
155+
156+
#### Spring Boot Integration Documentation
144157
- Added comprehensive Spring Boot Integration documentation
145158
- Quick Start Guide with complete code examples
146159
- Configuration Reference for all `aether.datafixers.*` properties

aether-datafixers-codec/src/main/java/de/splatgames/aether/datafixers/codec/gson/package-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
* <caption>Deprecation and Removal Schedule</caption>
5454
* <tr><th>Version</th><th>Status</th><th>Action Required</th></tr>
5555
* <tr><td>0.4.0</td><td>Deprecated</td><td>Update imports to new package; old code continues to work</td></tr>
56-
* <tr><td>0.5.0 - 0.9.x</td><td>Deprecated</td><td>Warnings during compilation; functionality unchanged</td></tr>
56+
* <tr><td>0.5.0</td><td>Deprecated</td><td>Warnings during compilation; functionality unchanged</td></tr>
5757
* <tr><td>1.0.0</td><td><strong>Removed</strong></td><td>Package deleted; migration required before upgrade</td></tr>
5858
* </table>
5959
*

aether-datafixers-codec/src/main/java/de/splatgames/aether/datafixers/codec/jackson/package-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
* <caption>Deprecation and Removal Schedule</caption>
6060
* <tr><th>Version</th><th>Status</th><th>Action Required</th></tr>
6161
* <tr><td>0.4.0</td><td>Deprecated</td><td>Update imports and class names; old code continues to work</td></tr>
62-
* <tr><td>0.5.0 - 0.9.x</td><td>Deprecated</td><td>Warnings during compilation; functionality unchanged</td></tr>
62+
* <tr><td>0.5.0</td><td>Deprecated</td><td>Warnings during compilation; functionality unchanged</td></tr>
6363
* <tr><td>1.0.0</td><td><strong>Removed</strong></td><td>Package deleted; migration required before upgrade</td></tr>
6464
* </table>
6565
*

docs/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ Practical task-oriented guides:
6565
- [Use Diagnostics](how-to/use-diagnostics.md)
6666
- [View all How-To Guides](how-to/index.md)
6767

68+
### Codec Formats
69+
70+
DynamicOps implementations for various data formats:
71+
72+
- [Codec Overview](codec/index.md) — Introduction to DynamicOps implementations
73+
- [JSON Support](codec/json.md) — GsonOps and JacksonJsonOps
74+
- [YAML Support](codec/yaml.md) — SnakeYamlOps and JacksonYamlOps
75+
- [TOML Support](codec/toml.md) — JacksonTomlOps
76+
- [XML Support](codec/xml.md) — JacksonXmlOps
77+
6878
### Examples
6979

7080
Working code examples:
@@ -140,7 +150,7 @@ Seamlessly integrate Aether Datafixers into Spring Boot applications:
140150
|--------|-------------|
141151
| `aether-datafixers-api` | Core interfaces and API contracts |
142152
| `aether-datafixers-core` | Default implementations |
143-
| `aether-datafixers-codec` | GsonOps, JacksonJsonOps implementations |
153+
| `aether-datafixers-codec` | DynamicOps for JSON, YAML, TOML, XML (Gson, Jackson, SnakeYAML) |
144154
| `aether-datafixers-spring-boot-starter` | Spring Boot auto-configuration, MigrationService, Actuator, Metrics |
145155
| `aether-datafixers-cli` | Command-line interface for data migration |
146156
| `aether-datafixers-testkit` | Testing utilities for DataFix, Schema, and migration testing |

docs/appendix/changelog.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,37 @@ History of documentation updates. For code changes, see the main [CHANGELOG.md](
66

77
## Version 0.4.0
88

9+
### New Section: Codec Formats
10+
11+
Added comprehensive documentation for all DynamicOps implementations in the codec module:
12+
13+
- [Codec Overview](../codec/index.md) — Introduction, format comparison, package structure
14+
- [JSON Support](../codec/json.md) — GsonOps and JacksonJsonOps documentation
15+
- [YAML Support](../codec/yaml.md) — SnakeYamlOps and JacksonYamlOps documentation
16+
- [TOML Support](../codec/toml.md) — JacksonTomlOps documentation
17+
- [XML Support](../codec/xml.md) — JacksonXmlOps documentation
18+
19+
### Key Codec Features Documented
20+
21+
- **Format-Based Package Structure**: New `codec.json`, `codec.yaml`, `codec.toml`, `codec.xml` packages
22+
- **Multiple Implementations per Format**: JSON (Gson, Jackson), YAML (SnakeYAML, Jackson)
23+
- **Consistent API**: All implementations follow the same `DynamicOps<T>` interface
24+
- **Thread-Safe Singletons**: `INSTANCE` constants for all implementations
25+
- **Custom Mapper Support**: Jackson-based implementations support custom mapper configuration
26+
- **Migration Examples**: Complete examples for each format
27+
- **Format Conversion**: Cross-format data conversion examples
28+
29+
### New DynamicOps Implementations
30+
31+
| Format | Implementation | Data Type | Library |
32+
|--------|------------------|---------------|--------------|
33+
| JSON | `GsonOps` | `JsonElement` | Gson |
34+
| JSON | `JacksonJsonOps` | `JsonNode` | Jackson |
35+
| YAML | `SnakeYamlOps` | `Object` | SnakeYAML |
36+
| YAML | `JacksonYamlOps` | `JsonNode` | Jackson YAML |
37+
| TOML | `JacksonTomlOps` | `JsonNode` | Jackson TOML |
38+
| XML | `JacksonXmlOps` | `JsonNode` | Jackson XML |
39+
940
### New Section: Spring Boot Integration
1041

1142
Added comprehensive documentation for the Spring Boot Starter module:
@@ -29,7 +60,11 @@ Added comprehensive documentation for the Spring Boot Starter module:
2960

3061
### Updated Pages
3162

32-
- [Main README](../README.md) — Added Spring Boot Integration section and module to table
63+
- [Main README](../README.md) — Added Codec Formats and Spring Boot Integration sections, updated module table
64+
- [Codec System](../concepts/codec-system.md) — Added links to format-specific documentation
65+
- [Dynamic System](../concepts/dynamic-system.md) — Added table of all DynamicOps implementations
66+
- [How-To Index](../how-to/index.md) — Added Format Integration section
67+
- [Custom DynamicOps Tutorial](../tutorials/custom-dynamicops.md) — Added reference to built-in implementations
3368
- [Installation Guide](../getting-started/installation.md) — Added Spring Boot module to overview and installation section
3469

3570
---

docs/codec/index.md

Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
# Codec Module Overview
2+
3+
The `aether-datafixers-codec` module provides `DynamicOps` implementations for various data serialization formats. These implementations enable Aether Datafixers to work with JSON, YAML, TOML, and XML data.
4+
5+
## Supported Formats
6+
7+
| Format | Implementation | Underlying Library | Data Type |
8+
|--------|----------------|-------------------|-----------|
9+
| **JSON** | `GsonOps` | Google Gson | `JsonElement` |
10+
| **JSON** | `JacksonJsonOps` | Jackson Databind | `JsonNode` |
11+
| **YAML** | `SnakeYamlOps` | SnakeYAML | `Object` (Map/List) |
12+
| **YAML** | `JacksonYamlOps` | Jackson YAML | `JsonNode` |
13+
| **TOML** | `JacksonTomlOps` | Jackson TOML | `JsonNode` |
14+
| **XML** | `JacksonXmlOps` | Jackson XML | `JsonNode` |
15+
16+
## Quick Start
17+
18+
### Add Dependency
19+
20+
```xml
21+
<dependency>
22+
<groupId>de.splatgames.aether</groupId>
23+
<artifactId>aether-datafixers-codec</artifactId>
24+
<version>${aether.version}</version>
25+
</dependency>
26+
```
27+
28+
All format-specific dependencies are **optional**. Add only the libraries you need:
29+
30+
```xml
31+
<!-- For GsonOps -->
32+
<dependency>
33+
<groupId>com.google.code.gson</groupId>
34+
<artifactId>gson</artifactId>
35+
<version>2.11.0</version>
36+
</dependency>
37+
38+
<!-- For JacksonJsonOps -->
39+
<dependency>
40+
<groupId>com.fasterxml.jackson.core</groupId>
41+
<artifactId>jackson-databind</artifactId>
42+
<version>2.18.2</version>
43+
</dependency>
44+
45+
<!-- For SnakeYamlOps -->
46+
<dependency>
47+
<groupId>org.yaml</groupId>
48+
<artifactId>snakeyaml</artifactId>
49+
<version>2.3</version>
50+
</dependency>
51+
52+
<!-- For JacksonYamlOps -->
53+
<dependency>
54+
<groupId>com.fasterxml.jackson.dataformat</groupId>
55+
<artifactId>jackson-dataformat-yaml</artifactId>
56+
<version>2.18.2</version>
57+
</dependency>
58+
59+
<!-- For JacksonTomlOps -->
60+
<dependency>
61+
<groupId>com.fasterxml.jackson.dataformat</groupId>
62+
<artifactId>jackson-dataformat-toml</artifactId>
63+
<version>2.18.2</version>
64+
</dependency>
65+
66+
<!-- For JacksonXmlOps -->
67+
<dependency>
68+
<groupId>com.fasterxml.jackson.dataformat</groupId>
69+
<artifactId>jackson-dataformat-xml</artifactId>
70+
<version>2.18.2</version>
71+
</dependency>
72+
```
73+
74+
### Basic Usage
75+
76+
```java
77+
// JSON with Gson
78+
import de.splatgames.aether.datafixers.codec.json.gson.GsonOps;
79+
Dynamic<JsonElement> jsonDynamic = new Dynamic<>(GsonOps.INSTANCE, jsonElement);
80+
81+
// YAML with SnakeYAML
82+
import de.splatgames.aether.datafixers.codec.yaml.snakeyaml.SnakeYamlOps;
83+
Dynamic<Object> yamlDynamic = new Dynamic<>(SnakeYamlOps.INSTANCE, yamlData);
84+
85+
// TOML with Jackson
86+
import de.splatgames.aether.datafixers.codec.toml.jackson.JacksonTomlOps;
87+
Dynamic<JsonNode> tomlDynamic = new Dynamic<>(JacksonTomlOps.INSTANCE, tomlNode);
88+
89+
// XML with Jackson
90+
import de.splatgames.aether.datafixers.codec.xml.jackson.JacksonXmlOps;
91+
Dynamic<JsonNode> xmlDynamic = new Dynamic<>(JacksonXmlOps.INSTANCE, xmlNode);
92+
```
93+
94+
## Package Structure
95+
96+
```
97+
de.splatgames.aether.datafixers.codec
98+
├── json
99+
│ ├── gson/
100+
│ │ └── GsonOps.java
101+
│ └── jackson/
102+
│ └── JacksonJsonOps.java
103+
├── yaml
104+
│ ├── snakeyaml/
105+
│ │ └── SnakeYamlOps.java
106+
│ └── jackson/
107+
│ └── JacksonYamlOps.java
108+
├── toml
109+
│ └── jackson/
110+
│ └── JacksonTomlOps.java
111+
└── xml
112+
└── jackson/
113+
└── JacksonXmlOps.java
114+
```
115+
116+
## Choosing an Implementation
117+
118+
### JSON
119+
120+
| Feature | GsonOps | JacksonJsonOps |
121+
|---------|---------|----------------|
122+
| Library Size | ~300 KB | ~1.7 MB |
123+
| Performance | Good | Excellent |
124+
| Streaming | No | Yes |
125+
| Custom Mappers | No | Yes |
126+
| Tree Model | `JsonElement` | `JsonNode` |
127+
128+
**Recommendation:** Use `GsonOps` for simple use cases with minimal dependencies. Use `JacksonJsonOps` when you need maximum performance or already use Jackson.
129+
130+
### YAML
131+
132+
| Feature | SnakeYamlOps | JacksonYamlOps |
133+
|---------|--------------|----------------|
134+
| Library Size | ~300 KB | ~100 KB + Jackson |
135+
| Native Types | Yes (Map/List) | No (JsonNode) |
136+
| YAML Features | Full | Subset |
137+
| Anchors/Aliases | Yes | Limited |
138+
| Multi-Document | Yes | Limited |
139+
140+
**Recommendation:** Use `SnakeYamlOps` for full YAML feature support. Use `JacksonYamlOps` when you need consistent `JsonNode` handling across formats.
141+
142+
### TOML
143+
144+
| Feature | JacksonTomlOps |
145+
|---------|----------------|
146+
| TOML 1.0 | Yes |
147+
| Date/Time | Via String |
148+
| Inline Tables | Yes |
149+
| Arrays of Tables | Yes |
150+
151+
**Recommendation:** `JacksonTomlOps` is the standard choice for TOML support.
152+
153+
### XML
154+
155+
| Feature | JacksonXmlOps |
156+
|---------|---------------|
157+
| Attributes | Via Conventions |
158+
| Namespaces | Limited |
159+
| Mixed Content | Limited |
160+
| Tree Model | JsonNode |
161+
162+
**Recommendation:** `JacksonXmlOps` provides basic XML support. For complex XML with namespaces, consider a dedicated XML library.
163+
164+
## Thread Safety
165+
166+
All singleton instances (`INSTANCE`) are thread-safe and can be shared across threads:
167+
168+
```java
169+
// Safe to use from multiple threads
170+
GsonOps.INSTANCE
171+
JacksonJsonOps.INSTANCE
172+
SnakeYamlOps.INSTANCE
173+
JacksonYamlOps.INSTANCE
174+
JacksonTomlOps.INSTANCE
175+
JacksonXmlOps.INSTANCE
176+
```
177+
178+
Custom instances with custom mappers are thread-safe if the underlying mapper is thread-safe.
179+
180+
## Format Conversion
181+
182+
Convert data between formats using different `DynamicOps`:
183+
184+
```java
185+
// Read YAML
186+
Yaml yaml = new Yaml();
187+
Object yamlData = yaml.load(yamlString);
188+
Dynamic<Object> yamlDynamic = new Dynamic<>(SnakeYamlOps.INSTANCE, yamlData);
189+
190+
// Convert to JSON
191+
Dynamic<JsonElement> jsonDynamic = yamlDynamic.convert(GsonOps.INSTANCE);
192+
193+
// Write JSON
194+
Gson gson = new GsonBuilder().setPrettyPrinting().create();
195+
String jsonString = gson.toJson(jsonDynamic.value());
196+
```
197+
198+
See [Format Conversion](../advanced/format-conversion.md) for advanced techniques.
199+
200+
## Migration Example
201+
202+
Apply the same migration logic to different formats:
203+
204+
```java
205+
public class FormatAgnosticMigrator {
206+
207+
private final AetherDataFixer fixer;
208+
209+
public <T> Dynamic<T> migrate(Dynamic<T> input, DataVersion from, DataVersion to) {
210+
TaggedDynamic<T> tagged = new TaggedDynamic<>(TypeReferences.CONFIG, input);
211+
TaggedDynamic<T> result = fixer.update(tagged, from, to);
212+
return result.value();
213+
}
214+
}
215+
216+
// Use with any format
217+
migrator.migrate(jsonDynamic, v1, v2); // JSON
218+
migrator.migrate(yamlDynamic, v1, v2); // YAML
219+
migrator.migrate(tomlDynamic, v1, v2); // TOML
220+
migrator.migrate(xmlDynamic, v1, v2); // XML
221+
```
222+
223+
## Related Documentation
224+
225+
- [JSON Support](json.md) — GsonOps and JacksonJsonOps details
226+
- [YAML Support](yaml.md) — SnakeYamlOps and JacksonYamlOps details
227+
- [TOML Support](toml.md) — JacksonTomlOps details
228+
- [XML Support](xml.md) — JacksonXmlOps details
229+
- [Dynamic System](../concepts/dynamic-system.md) — Core Dynamic concepts
230+
- [Codec System](../concepts/codec-system.md) — Encoding and decoding
231+
- [Custom DynamicOps](../tutorials/custom-dynamicops.md) — Create your own implementation

0 commit comments

Comments
 (0)