Skip to content

Commit 5d13ef1

Browse files
committed
Refactor formatting for method signatures and annotations across modules
Signed-off-by: Erik Pförtner <splatcrafter@splatgames.de>
1 parent 41d7d8c commit 5d13ef1

9 files changed

Lines changed: 144 additions & 181 deletions

File tree

aether-datafixers-cli/src/main/java/de/splatgames/aether/datafixers/cli/command/MigrateCommand.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import java.nio.file.Files;
5151
import java.nio.file.Path;
5252
import java.nio.file.StandardCopyOption;
53+
import java.nio.file.StandardOpenOption;
5354
import java.time.Duration;
5455
import java.time.Instant;
5556
import java.time.ZoneOffset;
@@ -546,8 +547,8 @@ public Integer call() {
546547
if (this.reportFile != null) {
547548
Files.writeString(this.reportFile.toPath(), diagnosticContent,
548549
StandardCharsets.UTF_8,
549-
java.nio.file.StandardOpenOption.CREATE,
550-
java.nio.file.StandardOpenOption.APPEND);
550+
StandardOpenOption.CREATE,
551+
StandardOpenOption.APPEND);
551552
} else {
552553
System.err.println(diagnosticContent);
553554
}

aether-datafixers-cli/src/main/java/de/splatgames/aether/datafixers/cli/report/JsonReportFormatter.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,11 @@ public class JsonReportFormatter implements ReportFormatter {
107107
*/
108108
@Override
109109
@NotNull
110-
public String formatSimple(
111-
@NotNull final String fileName,
112-
@NotNull final String type,
113-
final int fromVersion,
114-
final int toVersion,
115-
@NotNull final Duration duration
116-
) {
110+
public String formatSimple(@NotNull final String fileName,
111+
@NotNull final String type,
112+
final int fromVersion,
113+
final int toVersion,
114+
@NotNull final Duration duration) {
117115
Preconditions.checkNotNull(fileName, "fileName must not be null");
118116
Preconditions.checkNotNull(type, "type must not be null");
119117
Preconditions.checkNotNull(duration, "duration must not be null");
@@ -172,14 +170,13 @@ public String formatSimple(
172170
* @param type the type reference ID (e.g., "player", "world")
173171
* @param report the diagnostic migration report containing fix and field operation details
174172
* @return a pretty-printed JSON string representing the diagnostic report
173+
* @since 1.0.0
175174
*/
176175
@Override
177176
@NotNull
178-
public String formatDiagnostic(
179-
@NotNull final String fileName,
180-
@NotNull final String type,
181-
@NotNull final MigrationReport report
182-
) {
177+
public String formatDiagnostic(@NotNull final String fileName,
178+
@NotNull final String type,
179+
@NotNull final MigrationReport report) {
183180
Preconditions.checkNotNull(fileName, "fileName must not be null");
184181
Preconditions.checkNotNull(type, "type must not be null");
185182
Preconditions.checkNotNull(report, "report must not be null");

aether-datafixers-cli/src/main/java/de/splatgames/aether/datafixers/cli/report/ReportFormatter.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,11 @@ public interface ReportFormatter {
6565
* @return the formatted report string
6666
*/
6767
@NotNull
68-
String formatSimple(
69-
@NotNull String fileName,
70-
@NotNull String type,
71-
int fromVersion,
72-
int toVersion,
73-
@NotNull Duration duration
74-
);
68+
String formatSimple(@NotNull final String fileName,
69+
@NotNull final String type,
70+
final int fromVersion,
71+
final int toVersion,
72+
@NotNull final Duration duration);
7573

7674
/**
7775
* Formats a diagnostic migration report including field-level operation details.
@@ -84,13 +82,11 @@ String formatSimple(
8482
* @param type the type reference ID
8583
* @param report the diagnostic migration report
8684
* @return the formatted diagnostic report string
85+
* @since 0.1.0
8786
*/
8887
@NotNull
89-
String formatDiagnostic(
90-
@NotNull String fileName,
91-
@NotNull String type,
92-
@NotNull MigrationReport report
93-
);
88+
String formatDiagnostic(@NotNull final String fileName,
89+
@NotNull final String type, @NotNull final MigrationReport report);
9490

9591
/**
9692
* Gets a formatter by format name.
@@ -102,9 +98,10 @@ String formatDiagnostic(
10298
static ReportFormatter forFormat(@NotNull final String format) {
10399
Preconditions.checkNotNull(format, "format must not be null");
104100

105-
return switch (format.toLowerCase()) {
106-
case "json" -> new JsonReportFormatter();
107-
default -> new TextReportFormatter();
108-
};
101+
if (format.equalsIgnoreCase("json")) {
102+
return new JsonReportFormatter();
103+
} else {
104+
return new TextReportFormatter();
105+
}
109106
}
110107
}

aether-datafixers-cli/src/main/java/de/splatgames/aether/datafixers/cli/report/TextReportFormatter.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,11 @@ public class TextReportFormatter implements ReportFormatter {
7575
*/
7676
@Override
7777
@NotNull
78-
public String formatSimple(
79-
@NotNull final String fileName,
80-
@NotNull final String type,
81-
final int fromVersion,
82-
final int toVersion,
83-
@NotNull final Duration duration
84-
) {
78+
public String formatSimple(@NotNull final String fileName,
79+
@NotNull final String type,
80+
final int fromVersion,
81+
final int toVersion,
82+
@NotNull final Duration duration) {
8583
Preconditions.checkNotNull(fileName, "fileName must not be null");
8684
Preconditions.checkNotNull(type, "type must not be null");
8785
Preconditions.checkNotNull(duration, "duration must not be null");
@@ -116,14 +114,13 @@ public String formatSimple(
116114
* @param type the type reference ID (e.g., "player", "world")
117115
* @param report the diagnostic migration report containing fix and field operation details
118116
* @return a multi-line formatted diagnostic report string
117+
* @since 1.0.0
119118
*/
120119
@Override
121120
@NotNull
122-
public String formatDiagnostic(
123-
@NotNull final String fileName,
124-
@NotNull final String type,
125-
@NotNull final MigrationReport report
126-
) {
121+
public String formatDiagnostic(@NotNull final String fileName,
122+
@NotNull final String type,
123+
@NotNull final MigrationReport report) {
127124
Preconditions.checkNotNull(fileName, "fileName must not be null");
128125
Preconditions.checkNotNull(type, "type must not be null");
129126
Preconditions.checkNotNull(report, "report must not be null");

aether-datafixers-core/src/main/java/de/splatgames/aether/datafixers/core/AetherDataFixer.java

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
* High-level facade for the Aether DataFixers system.
4343
*
4444
* <p>{@code AetherDataFixer} provides a unified interface for encoding, decoding,
45-
* and migrating data across versions. It combines a {@link SchemaRegistry} for
46-
* type definitions with a {@link DataFixer} for version migrations.</p>
45+
* and migrating data across versions. It combines a {@link SchemaRegistry} for type definitions with a
46+
* {@link DataFixer} for version migrations.</p>
4747
*
4848
* <h2>Core Operations</h2>
4949
* <ul>
@@ -87,9 +87,19 @@
8787
* @since 0.1.0
8888
*/
8989
public final class AetherDataFixer {
90-
90+
/**
91+
* The current (latest) data version. This is used as the default target version for encoding and can be used to
92+
* determine the latest schema for decoding. It should be set to the highest version number that has a registered
93+
* schema in the SchemaRegistry.
94+
*/
9195
private final DataVersion currentVersion;
96+
/**
97+
* The schema registry containing all schemas and type definitions.
98+
*/
9299
private final SchemaRegistry schemaRegistry;
100+
/**
101+
* The underlying data fixer responsible for applying registered fixes during updates.
102+
*/
93103
private final DataFixer dataFixer;
94104

95105
/**
@@ -100,11 +110,9 @@ public final class AetherDataFixer {
100110
* @param dataFixer the underlying data fixer for migrations, must not be {@code null}
101111
* @throws NullPointerException if any argument is {@code null}
102112
*/
103-
public AetherDataFixer(
104-
@NotNull final DataVersion currentVersion,
105-
@NotNull final SchemaRegistry schemaRegistry,
106-
@NotNull final DataFixer dataFixer
107-
) {
113+
public AetherDataFixer(@NotNull final DataVersion currentVersion,
114+
@NotNull final SchemaRegistry schemaRegistry,
115+
@NotNull final DataFixer dataFixer) {
108116
Preconditions.checkNotNull(currentVersion, "currentVersion must not be null");
109117
Preconditions.checkNotNull(schemaRegistry, "schemaRegistry must not be null");
110118
Preconditions.checkNotNull(dataFixer, "dataFixer must not be null");
@@ -141,12 +149,10 @@ public DataVersion currentVersion() {
141149
* @throws NullPointerException if any argument is {@code null}
142150
*/
143151
@NotNull
144-
public <A, T> TaggedDynamic encode(
145-
@NotNull final DataVersion targetVersion,
146-
@NotNull final TypeReference typeRef,
147-
@NotNull final A value,
148-
@NotNull final DynamicOps<T> ops
149-
) {
152+
public <A, T> TaggedDynamic encode(@NotNull final DataVersion targetVersion,
153+
@NotNull final TypeReference typeRef,
154+
@NotNull final A value,
155+
@NotNull final DynamicOps<T> ops) {
150156
Preconditions.checkNotNull(targetVersion, "targetVersion must not be null");
151157
Preconditions.checkNotNull(typeRef, "typeRef must not be null");
152158
Preconditions.checkNotNull(value, "value must not be null");
@@ -174,11 +180,9 @@ public <A, T> TaggedDynamic encode(
174180
* @throws NullPointerException if any argument is {@code null}
175181
*/
176182
@NotNull
177-
public TaggedDynamic update(
178-
@NotNull final TaggedDynamic input,
179-
@NotNull final DataVersion fromVersion,
180-
@NotNull final DataVersion toVersion
181-
) {
183+
public TaggedDynamic update(@NotNull final TaggedDynamic input,
184+
@NotNull final DataVersion fromVersion,
185+
@NotNull final DataVersion toVersion) {
182186
Preconditions.checkNotNull(input, "input must not be null");
183187
Preconditions.checkNotNull(fromVersion, "fromVersion must not be null");
184188
Preconditions.checkNotNull(toVersion, "toVersion must not be null");
@@ -199,10 +203,9 @@ public TaggedDynamic update(
199203
* Updates data from one version to another using the specified context.
200204
*
201205
* <p>Applies all registered fixes between the source and target versions
202-
* to migrate the data. The provided {@link DataFixerContext} controls
203-
* logging and diagnostic behavior during migration. Pass a
204-
* {@link de.splatgames.aether.datafixers.api.diagnostic.DiagnosticContext}
205-
* to capture detailed migration diagnostics including field-level operations.</p>
206+
* to migrate the data. The provided {@link DataFixerContext} controls logging and diagnostic behavior during
207+
* migration. Pass a {@link de.splatgames.aether.datafixers.api.diagnostic.DiagnosticContext} to capture detailed
208+
* migration diagnostics including field-level operations.</p>
206209
*
207210
* @param input the tagged dynamic data to update, must not be {@code null}
208211
* @param fromVersion the source version of the data, must not be {@code null}
@@ -213,12 +216,10 @@ public TaggedDynamic update(
213216
* @since 1.0.0
214217
*/
215218
@NotNull
216-
public TaggedDynamic update(
217-
@NotNull final TaggedDynamic input,
218-
@NotNull final DataVersion fromVersion,
219-
@NotNull final DataVersion toVersion,
220-
@NotNull final DataFixerContext context
221-
) {
219+
public TaggedDynamic update(@NotNull final TaggedDynamic input,
220+
@NotNull final DataVersion fromVersion,
221+
@NotNull final DataVersion toVersion,
222+
@NotNull final DataFixerContext context) {
222223
Preconditions.checkNotNull(input, "input must not be null");
223224
Preconditions.checkNotNull(fromVersion, "fromVersion must not be null");
224225
Preconditions.checkNotNull(toVersion, "toVersion must not be null");
@@ -250,10 +251,8 @@ public TaggedDynamic update(
250251
* @throws NullPointerException if any argument is {@code null}
251252
*/
252253
@NotNull
253-
public <A> A decode(
254-
@NotNull final DataVersion sourceVersion,
255-
@NotNull final TaggedDynamic input
256-
) {
254+
public <A> A decode(@NotNull final DataVersion sourceVersion,
255+
@NotNull final TaggedDynamic input) {
257256
Preconditions.checkNotNull(sourceVersion, "sourceVersion must not be null");
258257
Preconditions.checkNotNull(input, "input must not be null");
259258

aether-datafixers-spring-boot-starter/src/main/java/de/splatgames/aether/datafixers/spring/actuator/DataFixerEndpoint.java

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,8 @@ public DataFixerEndpoint(@NotNull final DataFixerRegistry registry) {
202202
* @throws NullPointerException if registry is {@code null}
203203
* @since 1.0.0
204204
*/
205-
public DataFixerEndpoint(
206-
@NotNull final DataFixerRegistry registry,
207-
@Nullable final DiagnosticReportStore diagnosticReportStore
208-
) {
205+
public DataFixerEndpoint(@NotNull final DataFixerRegistry registry,
206+
@Nullable final DiagnosticReportStore diagnosticReportStore) {
209207
this.registry = Preconditions.checkNotNull(registry, "registry must not be null");
210208
this.diagnosticReportStore = diagnosticReportStore;
211209
}
@@ -320,9 +318,7 @@ public DomainDetails domainDetails(@Selector final String domain) {
320318
* @return the field diagnostics summary
321319
*/
322320
@NotNull
323-
private static FieldDiagnosticsSummary buildFieldDiagnosticsSummary(
324-
@NotNull final MigrationReport report
325-
) {
321+
private static FieldDiagnosticsSummary buildFieldDiagnosticsSummary(@NotNull final MigrationReport report) {
326322
final List<FieldOperationSummary> operations = report.fixExecutions().stream()
327323
.flatMap(fix -> fix.allFieldOperations().stream()
328324
.map(op -> new FieldOperationSummary(
@@ -439,12 +435,11 @@ public record DomainSummary(int currentVersion, String status, @Nullable String
439435
* @author Erik Pförtner
440436
* @since 0.4.0
441437
*/
442-
public record DomainDetails(
443-
String domain,
444-
int currentVersion,
445-
String status,
446-
@Nullable String error,
447-
@Nullable FieldDiagnosticsSummary lastDiagnostics
438+
public record DomainDetails(String domain,
439+
int currentVersion,
440+
String status,
441+
@Nullable String error,
442+
@Nullable FieldDiagnosticsSummary lastDiagnostics
448443
) {
449444
}
450445

@@ -463,13 +458,12 @@ public record DomainDetails(
463458
* @author Erik Pförtner
464459
* @since 1.0.0
465460
*/
466-
public record FieldDiagnosticsSummary(
467-
int fromVersion,
468-
int toVersion,
469-
long durationMs,
470-
int fixCount,
471-
int fieldOperationCount,
472-
List<FieldOperationSummary> fieldOperations
461+
public record FieldDiagnosticsSummary(int fromVersion,
462+
int toVersion,
463+
long durationMs,
464+
int fixCount,
465+
int fieldOperationCount,
466+
List<FieldOperationSummary> fieldOperations
473467
) {
474468

475469
/**
@@ -490,11 +484,10 @@ public record FieldDiagnosticsSummary(
490484
* @author Erik Pförtner
491485
* @since 1.0.0
492486
*/
493-
public record FieldOperationSummary(
494-
String type,
495-
String field,
496-
@Nullable String target,
497-
@Nullable String description
487+
public record FieldOperationSummary(String type,
488+
String field,
489+
@Nullable String target,
490+
@Nullable String description
498491
) {
499492
}
500493
}

aether-datafixers-spring-boot-starter/src/main/java/de/splatgames/aether/datafixers/spring/autoconfigure/ActuatorAutoConfiguration.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import de.splatgames.aether.datafixers.spring.service.DefaultMigrationService;
3131
import de.splatgames.aether.datafixers.spring.service.DiagnosticReportStore;
3232
import io.micrometer.core.instrument.MeterRegistry;
33+
import org.springframework.beans.factory.annotation.Autowired;
3334
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
3435
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
3536
import org.springframework.boot.actuate.autoconfigure.info.ConditionalOnEnabledInfoContributor;
@@ -186,9 +187,7 @@ static class HealthIndicatorConfiguration {
186187
*/
187188
@Bean
188189
@ConditionalOnMissingBean(name = "dataFixerHealthIndicator")
189-
public DataFixerHealthIndicator dataFixerHealthIndicator(
190-
final DataFixerRegistry registry
191-
) {
190+
public DataFixerHealthIndicator dataFixerHealthIndicator(final DataFixerRegistry registry) {
192191
return new DataFixerHealthIndicator(registry);
193192
}
194193
}
@@ -217,9 +216,7 @@ static class InfoContributorConfiguration {
217216
*/
218217
@Bean
219218
@ConditionalOnMissingBean(name = "dataFixerInfoContributor")
220-
public DataFixerInfoContributor dataFixerInfoContributor(
221-
final DataFixerRegistry registry
222-
) {
219+
public DataFixerInfoContributor dataFixerInfoContributor(final DataFixerRegistry registry) {
223220
return new DataFixerInfoContributor(registry);
224221
}
225222
}
@@ -254,10 +251,9 @@ static class EndpointConfiguration {
254251
*/
255252
@Bean
256253
@ConditionalOnMissingBean
257-
public DataFixerEndpoint dataFixerEndpoint(
258-
final DataFixerRegistry registry,
259-
@org.springframework.beans.factory.annotation.Autowired(required = false)
260-
final DefaultMigrationService migrationService
254+
public DataFixerEndpoint dataFixerEndpoint(final DataFixerRegistry registry,
255+
@Autowired(required = false)
256+
final DefaultMigrationService migrationService
261257
) {
262258
final DiagnosticReportStore store = migrationService != null
263259
? migrationService.getDiagnosticReportStore()

0 commit comments

Comments
 (0)