Skip to content

Commit b8f74b1

Browse files
committed
Add nullability annotations to module/spring-boot-data-rest
See gh-46587
1 parent 594765e commit b8f74b1

File tree

3 files changed

+38
-32
lines changed

3 files changed

+38
-32
lines changed

module/spring-boot-data-rest/src/main/java/org/springframework/boot/data/rest/autoconfigure/RepositoryRestProperties.java

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.boot.data.rest.autoconfigure;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.boot.context.properties.ConfigurationProperties;
2022
import org.springframework.boot.context.properties.PropertyMapper;
2123
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
@@ -34,34 +36,34 @@ public class RepositoryRestProperties {
3436
/**
3537
* Base path to be used by Spring Data REST to expose repository resources.
3638
*/
37-
private String basePath;
39+
private @Nullable String basePath;
3840

3941
/**
4042
* Default size of pages.
4143
*/
42-
private Integer defaultPageSize;
44+
private @Nullable Integer defaultPageSize;
4345

4446
/**
4547
* Maximum size of pages.
4648
*/
47-
private Integer maxPageSize;
49+
private @Nullable Integer maxPageSize;
4850

4951
/**
5052
* Name of the URL query string parameter that indicates what page to return.
5153
*/
52-
private String pageParamName;
54+
private @Nullable String pageParamName;
5355

5456
/**
5557
* Name of the URL query string parameter that indicates how many results to return at
5658
* once.
5759
*/
58-
private String limitParamName;
60+
private @Nullable String limitParamName;
5961

6062
/**
6163
* Name of the URL query string parameter that indicates what direction to sort
6264
* results.
6365
*/
64-
private String sortParamName;
66+
private @Nullable String sortParamName;
6567

6668
/**
6769
* Strategy to use to determine which repositories get exposed.
@@ -71,69 +73,69 @@ public class RepositoryRestProperties {
7173
/**
7274
* Content type to use as a default when none is specified.
7375
*/
74-
private MediaType defaultMediaType;
76+
private @Nullable MediaType defaultMediaType;
7577

7678
/**
7779
* Whether to return a response body after creating an entity.
7880
*/
79-
private Boolean returnBodyOnCreate;
81+
private @Nullable Boolean returnBodyOnCreate;
8082

8183
/**
8284
* Whether to return a response body after updating an entity.
8385
*/
84-
private Boolean returnBodyOnUpdate;
86+
private @Nullable Boolean returnBodyOnUpdate;
8587

8688
/**
8789
* Whether to enable enum value translation through the Spring Data REST default
8890
* resource bundle.
8991
*/
90-
private Boolean enableEnumTranslation;
92+
private @Nullable Boolean enableEnumTranslation;
9193

92-
public String getBasePath() {
94+
public @Nullable String getBasePath() {
9395
return this.basePath;
9496
}
9597

96-
public void setBasePath(String basePath) {
98+
public void setBasePath(@Nullable String basePath) {
9799
this.basePath = basePath;
98100
}
99101

100-
public Integer getDefaultPageSize() {
102+
public @Nullable Integer getDefaultPageSize() {
101103
return this.defaultPageSize;
102104
}
103105

104-
public void setDefaultPageSize(Integer defaultPageSize) {
106+
public void setDefaultPageSize(@Nullable Integer defaultPageSize) {
105107
this.defaultPageSize = defaultPageSize;
106108
}
107109

108-
public Integer getMaxPageSize() {
110+
public @Nullable Integer getMaxPageSize() {
109111
return this.maxPageSize;
110112
}
111113

112-
public void setMaxPageSize(Integer maxPageSize) {
114+
public void setMaxPageSize(@Nullable Integer maxPageSize) {
113115
this.maxPageSize = maxPageSize;
114116
}
115117

116-
public String getPageParamName() {
118+
public @Nullable String getPageParamName() {
117119
return this.pageParamName;
118120
}
119121

120-
public void setPageParamName(String pageParamName) {
122+
public void setPageParamName(@Nullable String pageParamName) {
121123
this.pageParamName = pageParamName;
122124
}
123125

124-
public String getLimitParamName() {
126+
public @Nullable String getLimitParamName() {
125127
return this.limitParamName;
126128
}
127129

128-
public void setLimitParamName(String limitParamName) {
130+
public void setLimitParamName(@Nullable String limitParamName) {
129131
this.limitParamName = limitParamName;
130132
}
131133

132-
public String getSortParamName() {
134+
public @Nullable String getSortParamName() {
133135
return this.sortParamName;
134136
}
135137

136-
public void setSortParamName(String sortParamName) {
138+
public void setSortParamName(@Nullable String sortParamName) {
137139
this.sortParamName = sortParamName;
138140
}
139141

@@ -145,35 +147,35 @@ public void setDetectionStrategy(RepositoryDetectionStrategies detectionStrategy
145147
this.detectionStrategy = detectionStrategy;
146148
}
147149

148-
public MediaType getDefaultMediaType() {
150+
public @Nullable MediaType getDefaultMediaType() {
149151
return this.defaultMediaType;
150152
}
151153

152-
public void setDefaultMediaType(MediaType defaultMediaType) {
154+
public void setDefaultMediaType(@Nullable MediaType defaultMediaType) {
153155
this.defaultMediaType = defaultMediaType;
154156
}
155157

156-
public Boolean getReturnBodyOnCreate() {
158+
public @Nullable Boolean getReturnBodyOnCreate() {
157159
return this.returnBodyOnCreate;
158160
}
159161

160-
public void setReturnBodyOnCreate(Boolean returnBodyOnCreate) {
162+
public void setReturnBodyOnCreate(@Nullable Boolean returnBodyOnCreate) {
161163
this.returnBodyOnCreate = returnBodyOnCreate;
162164
}
163165

164-
public Boolean getReturnBodyOnUpdate() {
166+
public @Nullable Boolean getReturnBodyOnUpdate() {
165167
return this.returnBodyOnUpdate;
166168
}
167169

168-
public void setReturnBodyOnUpdate(Boolean returnBodyOnUpdate) {
170+
public void setReturnBodyOnUpdate(@Nullable Boolean returnBodyOnUpdate) {
169171
this.returnBodyOnUpdate = returnBodyOnUpdate;
170172
}
171173

172-
public Boolean getEnableEnumTranslation() {
174+
public @Nullable Boolean getEnableEnumTranslation() {
173175
return this.enableEnumTranslation;
174176
}
175177

176-
public void setEnableEnumTranslation(Boolean enableEnumTranslation) {
178+
public void setEnableEnumTranslation(@Nullable Boolean enableEnumTranslation) {
177179
this.enableEnumTranslation = enableEnumTranslation;
178180
}
179181

module/spring-boot-data-rest/src/main/java/org/springframework/boot/data/rest/autoconfigure/SpringBootRepositoryRestConfigurer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.boot.data.rest.autoconfigure;
1818

1919
import com.fasterxml.jackson.databind.ObjectMapper;
20+
import org.jspecify.annotations.Nullable;
2021

2122
import org.springframework.core.annotation.Order;
2223
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
@@ -37,11 +38,11 @@
3738
@SuppressWarnings("removal")
3839
class SpringBootRepositoryRestConfigurer implements RepositoryRestConfigurer {
3940

40-
private final Jackson2ObjectMapperBuilder objectMapperBuilder;
41+
private final @Nullable Jackson2ObjectMapperBuilder objectMapperBuilder;
4142

4243
private final RepositoryRestProperties properties;
4344

44-
SpringBootRepositoryRestConfigurer(Jackson2ObjectMapperBuilder objectMapperBuilder,
45+
SpringBootRepositoryRestConfigurer(@Nullable Jackson2ObjectMapperBuilder objectMapperBuilder,
4546
RepositoryRestProperties properties) {
4647
this.objectMapperBuilder = objectMapperBuilder;
4748
this.properties = properties;

module/spring-boot-data-rest/src/main/java/org/springframework/boot/data/rest/autoconfigure/package-info.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@
1717
/**
1818
* Auto-configuration for Spring Data REST.
1919
*/
20+
@NullMarked
2021
package org.springframework.boot.data.rest.autoconfigure;
22+
23+
import org.jspecify.annotations.NullMarked;

0 commit comments

Comments
 (0)