Skip to content

Commit 0291018

Browse files
committed
Replace Objects.requireNonNull with Preconditions.checkNotNull across services and components for consistent null checks. Add this references for member variables to improve code clarity.
1 parent b2614dc commit 0291018

9 files changed

Lines changed: 154 additions & 103 deletions

File tree

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public class AetherDataFixersProperties {
165165
* @return {@code true} if auto-configuration is enabled, {@code false} otherwise
166166
*/
167167
public boolean isEnabled() {
168-
return enabled;
168+
return this.enabled;
169169
}
170170

171171
/**
@@ -187,7 +187,7 @@ public void setEnabled(final boolean enabled) {
187187
*/
188188
@NotNull
189189
public DynamicOpsFormat getDefaultFormat() {
190-
return defaultFormat;
190+
return this.defaultFormat;
191191
}
192192

193193
/**
@@ -210,7 +210,7 @@ public void setDefaultFormat(@NotNull final DynamicOpsFormat defaultFormat) {
210210
*/
211211
@Nullable
212212
public Integer getDefaultCurrentVersion() {
213-
return defaultCurrentVersion;
213+
return this.defaultCurrentVersion;
214214
}
215215

216216
/**
@@ -236,7 +236,7 @@ public void setDefaultCurrentVersion(@Nullable final Integer defaultCurrentVersi
236236
*/
237237
@NotNull
238238
public Map<String, DataFixerDomainProperties> getDomains() {
239-
return domains;
239+
return this.domains;
240240
}
241241

242242
/**
@@ -259,7 +259,7 @@ public void setDomains(@NotNull final Map<String, DataFixerDomainProperties> dom
259259
*/
260260
@NotNull
261261
public ActuatorProperties getActuator() {
262-
return actuator;
262+
return this.actuator;
263263
}
264264

265265
/**
@@ -282,7 +282,7 @@ public void setActuator(@NotNull final ActuatorProperties actuator) {
282282
*/
283283
@NotNull
284284
public MetricsProperties getMetrics() {
285-
return metrics;
285+
return this.metrics;
286286
}
287287

288288
/**
@@ -347,7 +347,7 @@ public static class ActuatorProperties {
347347
* @return {@code true} if schema details are included, {@code false} otherwise
348348
*/
349349
public boolean isIncludeSchemaDetails() {
350-
return includeSchemaDetails;
350+
return this.includeSchemaDetails;
351351
}
352352

353353
/**
@@ -369,7 +369,7 @@ public void setIncludeSchemaDetails(final boolean includeSchemaDetails) {
369369
* @return {@code true} if fix details are included, {@code false} otherwise
370370
*/
371371
public boolean isIncludeFixDetails() {
372-
return includeFixDetails;
372+
return this.includeFixDetails;
373373
}
374374

375375
/**
@@ -454,7 +454,7 @@ public static class MetricsProperties {
454454
* @return {@code true} if timing metrics are enabled, {@code false} otherwise
455455
*/
456456
public boolean isTiming() {
457-
return timing;
457+
return this.timing;
458458
}
459459

460460
/**
@@ -475,7 +475,7 @@ public void setTiming(final boolean timing) {
475475
* @return {@code true} if counting metrics are enabled, {@code false} otherwise
476476
*/
477477
public boolean isCounting() {
478-
return counting;
478+
return this.counting;
479479
}
480480

481481
/**
@@ -498,7 +498,7 @@ public void setCounting(final boolean counting) {
498498
*/
499499
@NotNull
500500
public String getDomainTag() {
501-
return domainTag;
501+
return this.domainTag;
502502
}
503503

504504
/**

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
package de.splatgames.aether.datafixers.spring.actuator;
2424

25+
import com.google.common.base.Preconditions;
2526
import de.splatgames.aether.datafixers.core.AetherDataFixer;
2627
import de.splatgames.aether.datafixers.spring.autoconfigure.DataFixerRegistry;
2728
import org.jetbrains.annotations.NotNull;
@@ -32,7 +33,6 @@
3233

3334
import java.util.LinkedHashMap;
3435
import java.util.Map;
35-
import java.util.Objects;
3636

3737
/**
3838
* Custom Spring Boot Actuator endpoint for comprehensive DataFixer management and monitoring.
@@ -170,7 +170,7 @@ public class DataFixerEndpoint {
170170
* @throws NullPointerException if registry is {@code null}
171171
*/
172172
public DataFixerEndpoint(@NotNull final DataFixerRegistry registry) {
173-
this.registry = Objects.requireNonNull(registry, "registry must not be null");
173+
this.registry = Preconditions.checkNotNull(registry, "registry must not be null");
174174
}
175175

176176
/**
@@ -194,7 +194,7 @@ public DataFixerEndpoint(@NotNull final DataFixerRegistry registry) {
194194
public DataFixersSummary summary() {
195195
final Map<String, DomainSummary> domains = new LinkedHashMap<>();
196196

197-
for (final Map.Entry<String, AetherDataFixer> entry : registry.getAll().entrySet()) {
197+
for (final Map.Entry<String, AetherDataFixer> entry : this.registry.getAll().entrySet()) {
198198
final String domain = entry.getKey();
199199
final AetherDataFixer fixer = entry.getValue();
200200

@@ -240,7 +240,7 @@ public DataFixersSummary summary() {
240240
@ReadOperation
241241
@Nullable
242242
public DomainDetails domainDetails(@Selector final String domain) {
243-
final AetherDataFixer fixer = registry.get(domain);
243+
final AetherDataFixer fixer = this.registry.get(domain);
244244
if (fixer == null) {
245245
return null; // Spring will return 404
246246
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222

2323
package de.splatgames.aether.datafixers.spring.actuator;
2424

25+
import com.google.common.base.Preconditions;
2526
import de.splatgames.aether.datafixers.core.AetherDataFixer;
2627
import de.splatgames.aether.datafixers.spring.autoconfigure.DataFixerRegistry;
2728
import org.jetbrains.annotations.NotNull;
2829
import org.springframework.boot.actuate.health.Health;
2930
import org.springframework.boot.actuate.health.HealthIndicator;
3031

3132
import java.util.Map;
32-
import java.util.Objects;
3333

3434
/**
3535
* Spring Boot Actuator health indicator for monitoring DataFixer operational status.
@@ -146,7 +146,7 @@ public class DataFixerHealthIndicator implements HealthIndicator {
146146
* @throws NullPointerException if registry is {@code null}
147147
*/
148148
public DataFixerHealthIndicator(@NotNull final DataFixerRegistry registry) {
149-
this.registry = Objects.requireNonNull(registry, "registry must not be null");
149+
this.registry = Preconditions.checkNotNull(registry, "registry must not be null");
150150
}
151151

152152
/**
@@ -167,7 +167,7 @@ public DataFixerHealthIndicator(@NotNull final DataFixerRegistry registry) {
167167
*/
168168
@Override
169169
public Health health() {
170-
final Map<String, AetherDataFixer> fixers = registry.getAll();
170+
final Map<String, AetherDataFixer> fixers = this.registry.getAll();
171171

172172
if (fixers.isEmpty()) {
173173
return Health.unknown()

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
package de.splatgames.aether.datafixers.spring.actuator;
2424

25+
import com.google.common.base.Preconditions;
2526
import de.splatgames.aether.datafixers.core.AetherDataFixer;
2627
import de.splatgames.aether.datafixers.spring.autoconfigure.DataFixerRegistry;
2728
import org.jetbrains.annotations.NotNull;
@@ -30,7 +31,6 @@
3031

3132
import java.util.LinkedHashMap;
3233
import java.util.Map;
33-
import java.util.Objects;
3434

3535
/**
3636
* Spring Boot Actuator info contributor that adds DataFixer metadata to the info endpoint.
@@ -135,7 +135,7 @@ public class DataFixerInfoContributor implements InfoContributor {
135135
* @throws NullPointerException if registry is {@code null}
136136
*/
137137
public DataFixerInfoContributor(@NotNull final DataFixerRegistry registry) {
138-
this.registry = Objects.requireNonNull(registry, "registry must not be null");
138+
this.registry = Preconditions.checkNotNull(registry, "registry must not be null");
139139
}
140140

141141
/**
@@ -157,7 +157,7 @@ public DataFixerInfoContributor(@NotNull final DataFixerRegistry registry) {
157157
@Override
158158
public void contribute(final Info.Builder builder) {
159159
final Map<String, Object> datafixersInfo = new LinkedHashMap<>();
160-
final Map<String, AetherDataFixer> fixers = registry.getAll();
160+
final Map<String, AetherDataFixer> fixers = this.registry.getAll();
161161

162162
datafixersInfo.put("domains", fixers.size());
163163

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ public class DataFixerRegistry {
148148
* @throws NullPointerException if domain or fixer is {@code null}
149149
*/
150150
public void register(@NotNull final String domain, @NotNull final AetherDataFixer fixer) {
151-
if (fixers.containsKey(domain)) {
151+
if (this.fixers.containsKey(domain)) {
152152
throw new IllegalArgumentException(
153153
"DataFixer already registered for domain: " + domain
154154
);
155155
}
156-
fixers.put(domain, fixer);
156+
this.fixers.put(domain, fixer);
157157
}
158158

159159
/**
@@ -170,7 +170,7 @@ public void register(@NotNull final String domain, @NotNull final AetherDataFixe
170170
*/
171171
@Nullable
172172
public AetherDataFixer get(@NotNull final String domain) {
173-
return fixers.get(domain);
173+
return this.fixers.get(domain);
174174
}
175175

176176
/**
@@ -191,11 +191,11 @@ public AetherDataFixer get(@NotNull final String domain) {
191191
*/
192192
@NotNull
193193
public AetherDataFixer require(@NotNull final String domain) {
194-
final AetherDataFixer fixer = fixers.get(domain);
194+
final AetherDataFixer fixer = this.fixers.get(domain);
195195
if (fixer == null) {
196196
throw new IllegalArgumentException(
197197
"No DataFixer registered for domain: " + domain +
198-
". Available domains: " + fixers.keySet()
198+
". Available domains: " + this.fixers.keySet()
199199
);
200200
}
201201
return fixer;
@@ -213,7 +213,7 @@ public AetherDataFixer require(@NotNull final String domain) {
213213
*/
214214
@Nullable
215215
public AetherDataFixer getDefault() {
216-
return fixers.get(DEFAULT_DOMAIN);
216+
return this.fixers.get(DEFAULT_DOMAIN);
217217
}
218218

219219
/**
@@ -226,7 +226,7 @@ public AetherDataFixer getDefault() {
226226
*/
227227
@NotNull
228228
public Map<String, AetherDataFixer> getAll() {
229-
return Map.copyOf(fixers);
229+
return Map.copyOf(this.fixers);
230230
}
231231

232232
/**
@@ -240,7 +240,7 @@ public Map<String, AetherDataFixer> getAll() {
240240
*/
241241
@NotNull
242242
public Set<String> getDomains() {
243-
return Set.copyOf(fixers.keySet());
243+
return Set.copyOf(this.fixers.keySet());
244244
}
245245

246246
/**
@@ -254,7 +254,7 @@ public Set<String> getDomains() {
254254
* @throws NullPointerException if domain is {@code null}
255255
*/
256256
public boolean contains(@NotNull final String domain) {
257-
return fixers.containsKey(domain);
257+
return this.fixers.containsKey(domain);
258258
}
259259

260260
/**
@@ -265,7 +265,7 @@ public boolean contains(@NotNull final String domain) {
265265
* @return the number of registered fixers, always non-negative
266266
*/
267267
public int size() {
268-
return fixers.size();
268+
return this.fixers.size();
269269
}
270270

271271
/**
@@ -278,6 +278,6 @@ public int size() {
278278
* @return {@code true} if no DataFixers are registered, {@code false} otherwise
279279
*/
280280
public boolean isEmpty() {
281-
return fixers.isEmpty();
281+
return this.fixers.isEmpty();
282282
}
283283
}

aether-datafixers-spring-boot-starter/src/main/java/de/splatgames/aether/datafixers/spring/config/DataFixerDomainProperties.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public class DataFixerDomainProperties {
122122
*/
123123
@Nullable
124124
public Integer getCurrentVersion() {
125-
return currentVersion;
125+
return this.currentVersion;
126126
}
127127

128128
/**
@@ -149,7 +149,7 @@ public void setCurrentVersion(@Nullable final Integer currentVersion) {
149149
* @return {@code true} if this domain is the primary bean, {@code false} otherwise
150150
*/
151151
public boolean isPrimary() {
152-
return primary;
152+
return this.primary;
153153
}
154154

155155
/**
@@ -177,7 +177,7 @@ public void setPrimary(final boolean primary) {
177177
*/
178178
@Nullable
179179
public String getDescription() {
180-
return description;
180+
return this.description;
181181
}
182182

183183
/**

0 commit comments

Comments
 (0)