20
20
21
21
import com .mongodb .ConnectionString ;
22
22
import org .bson .UuidRepresentation ;
23
+ import org .jspecify .annotations .Nullable ;
23
24
24
25
import org .springframework .boot .context .properties .ConfigurationProperties ;
25
26
@@ -59,56 +60,56 @@ public class MongoProperties {
59
60
/**
60
61
* Mongo server host. Ignored if 'uri' is set.
61
62
*/
62
- private String host ;
63
+ private @ Nullable String host ;
63
64
64
65
/**
65
66
* Mongo server port. Ignored if 'uri' is set.
66
67
*/
67
- private Integer port = null ;
68
+ private @ Nullable Integer port ;
68
69
69
70
/**
70
71
* Additional server hosts. Ignored if 'uri' is set or if 'host' is omitted.
71
72
* Additional hosts will use the default mongo port of 27017. If you want to use a
72
73
* different port you can use the "host:port" syntax.
73
74
*/
74
- private List <String > additionalHosts ;
75
+ private @ Nullable List <String > additionalHosts ;
75
76
76
77
/**
77
78
* Mongo database URI. Overrides host, port, username, and password.
78
79
*/
79
- private String uri ;
80
+ private @ Nullable String uri ;
80
81
81
82
/**
82
83
* Database name. Overrides database in URI.
83
84
*/
84
- private String database ;
85
+ private @ Nullable String database ;
85
86
86
87
/**
87
88
* Authentication database name.
88
89
*/
89
- private String authenticationDatabase ;
90
+ private @ Nullable String authenticationDatabase ;
90
91
91
92
private final Gridfs gridfs = new Gridfs ();
92
93
93
94
/**
94
95
* Login user of the mongo server. Ignored if 'uri' is set.
95
96
*/
96
- private String username ;
97
+ private @ Nullable String username ;
97
98
98
99
/**
99
100
* Login password of the mongo server. Ignored if 'uri' is set.
100
101
*/
101
- private char [] password ;
102
+ private char @ Nullable [] password ;
102
103
103
104
/**
104
105
* Required replica set name for the cluster. Ignored if 'uri' is set.
105
106
*/
106
- private String replicaSetName ;
107
+ private @ Nullable String replicaSetName ;
107
108
108
109
/**
109
110
* Fully qualified name of the FieldNamingStrategy to use.
110
111
*/
111
- private Class <?> fieldNamingStrategy ;
112
+ private @ Nullable Class <?> fieldNamingStrategy ;
112
113
113
114
/**
114
115
* Representation to use when converting a UUID to a BSON binary value.
@@ -120,7 +121,7 @@ public class MongoProperties {
120
121
/**
121
122
* Whether to enable auto-index creation.
122
123
*/
123
- private Boolean autoIndexCreation ;
124
+ private @ Nullable Boolean autoIndexCreation ;
124
125
125
126
public void setProtocol (String protocol ) {
126
127
this .protocol = protocol ;
@@ -130,59 +131,59 @@ public String getProtocol() {
130
131
return this .protocol ;
131
132
}
132
133
133
- public String getHost () {
134
+ public @ Nullable String getHost () {
134
135
return this .host ;
135
136
}
136
137
137
- public void setHost (String host ) {
138
+ public void setHost (@ Nullable String host ) {
138
139
this .host = host ;
139
140
}
140
141
141
- public String getDatabase () {
142
+ public @ Nullable String getDatabase () {
142
143
return this .database ;
143
144
}
144
145
145
- public void setDatabase (String database ) {
146
+ public void setDatabase (@ Nullable String database ) {
146
147
this .database = database ;
147
148
}
148
149
149
- public String getAuthenticationDatabase () {
150
+ public @ Nullable String getAuthenticationDatabase () {
150
151
return this .authenticationDatabase ;
151
152
}
152
153
153
- public void setAuthenticationDatabase (String authenticationDatabase ) {
154
+ public void setAuthenticationDatabase (@ Nullable String authenticationDatabase ) {
154
155
this .authenticationDatabase = authenticationDatabase ;
155
156
}
156
157
157
- public String getUsername () {
158
+ public @ Nullable String getUsername () {
158
159
return this .username ;
159
160
}
160
161
161
- public void setUsername (String username ) {
162
+ public void setUsername (@ Nullable String username ) {
162
163
this .username = username ;
163
164
}
164
165
165
- public char [] getPassword () {
166
+ public char @ Nullable [] getPassword () {
166
167
return this .password ;
167
168
}
168
169
169
- public void setPassword (char [] password ) {
170
+ public void setPassword (char @ Nullable [] password ) {
170
171
this .password = password ;
171
172
}
172
173
173
- public String getReplicaSetName () {
174
+ public @ Nullable String getReplicaSetName () {
174
175
return this .replicaSetName ;
175
176
}
176
177
177
- public void setReplicaSetName (String replicaSetName ) {
178
+ public void setReplicaSetName (@ Nullable String replicaSetName ) {
178
179
this .replicaSetName = replicaSetName ;
179
180
}
180
181
181
- public Class <?> getFieldNamingStrategy () {
182
+ public @ Nullable Class <?> getFieldNamingStrategy () {
182
183
return this .fieldNamingStrategy ;
183
184
}
184
185
185
- public void setFieldNamingStrategy (Class <?> fieldNamingStrategy ) {
186
+ public void setFieldNamingStrategy (@ Nullable Class <?> fieldNamingStrategy ) {
186
187
this .fieldNamingStrategy = fieldNamingStrategy ;
187
188
}
188
189
@@ -194,50 +195,50 @@ public void setUuidRepresentation(UuidRepresentation uuidRepresentation) {
194
195
this .uuidRepresentation = uuidRepresentation ;
195
196
}
196
197
197
- public String getUri () {
198
+ public @ Nullable String getUri () {
198
199
return this .uri ;
199
200
}
200
201
201
202
public String determineUri () {
202
203
return (this .uri != null ) ? this .uri : DEFAULT_URI ;
203
204
}
204
205
205
- public void setUri (String uri ) {
206
+ public void setUri (@ Nullable String uri ) {
206
207
this .uri = uri ;
207
208
}
208
209
209
- public Integer getPort () {
210
+ public @ Nullable Integer getPort () {
210
211
return this .port ;
211
212
}
212
213
213
- public void setPort (Integer port ) {
214
+ public void setPort (@ Nullable Integer port ) {
214
215
this .port = port ;
215
216
}
216
217
217
218
public Gridfs getGridfs () {
218
219
return this .gridfs ;
219
220
}
220
221
221
- public String getMongoClientDatabase () {
222
+ public @ Nullable String getMongoClientDatabase () {
222
223
if (this .database != null ) {
223
224
return this .database ;
224
225
}
225
226
return new ConnectionString (determineUri ()).getDatabase ();
226
227
}
227
228
228
- public Boolean isAutoIndexCreation () {
229
+ public @ Nullable Boolean isAutoIndexCreation () {
229
230
return this .autoIndexCreation ;
230
231
}
231
232
232
- public void setAutoIndexCreation (Boolean autoIndexCreation ) {
233
+ public void setAutoIndexCreation (@ Nullable Boolean autoIndexCreation ) {
233
234
this .autoIndexCreation = autoIndexCreation ;
234
235
}
235
236
236
- public List <String > getAdditionalHosts () {
237
+ public @ Nullable List <String > getAdditionalHosts () {
237
238
return this .additionalHosts ;
238
239
}
239
240
240
- public void setAdditionalHosts (List <String > additionalHosts ) {
241
+ public void setAdditionalHosts (@ Nullable List <String > additionalHosts ) {
241
242
this .additionalHosts = additionalHosts ;
242
243
}
243
244
@@ -250,26 +251,26 @@ public static class Gridfs {
250
251
/**
251
252
* GridFS database name.
252
253
*/
253
- private String database ;
254
+ private @ Nullable String database ;
254
255
255
256
/**
256
257
* GridFS bucket name.
257
258
*/
258
- private String bucket ;
259
+ private @ Nullable String bucket ;
259
260
260
- public String getDatabase () {
261
+ public @ Nullable String getDatabase () {
261
262
return this .database ;
262
263
}
263
264
264
- public void setDatabase (String database ) {
265
+ public void setDatabase (@ Nullable String database ) {
265
266
this .database = database ;
266
267
}
267
268
268
- public String getBucket () {
269
+ public @ Nullable String getBucket () {
269
270
return this .bucket ;
270
271
}
271
272
272
- public void setBucket (String bucket ) {
273
+ public void setBucket (@ Nullable String bucket ) {
273
274
this .bucket = bucket ;
274
275
}
275
276
@@ -281,12 +282,12 @@ public static class Ssl {
281
282
* Whether to enable SSL support. Enabled automatically if "bundle" is provided
282
283
* unless specified otherwise.
283
284
*/
284
- private Boolean enabled ;
285
+ private @ Nullable Boolean enabled ;
285
286
286
287
/**
287
288
* SSL bundle name.
288
289
*/
289
- private String bundle ;
290
+ private @ Nullable String bundle ;
290
291
291
292
public boolean isEnabled () {
292
293
return (this .enabled != null ) ? this .enabled : this .bundle != null ;
@@ -296,11 +297,11 @@ public void setEnabled(boolean enabled) {
296
297
this .enabled = enabled ;
297
298
}
298
299
299
- public String getBundle () {
300
+ public @ Nullable String getBundle () {
300
301
return this .bundle ;
301
302
}
302
303
303
- public void setBundle (String bundle ) {
304
+ public void setBundle (@ Nullable String bundle ) {
304
305
this .bundle = bundle ;
305
306
}
306
307
0 commit comments