20
20
import org .bson .Document ;
21
21
import org .bson .codecs .DocumentCodec ;
22
22
import org .bson .codecs .configuration .CodecRegistry ;
23
+ import org .jspecify .annotations .Nullable ;
23
24
import org .springframework .data .mongodb .util .json .ParameterBindingDocumentCodec ;
24
25
import org .springframework .data .util .Lazy ;
25
- import org .springframework .lang .Nullable ;
26
+ import org .springframework .lang .Contract ;
26
27
import org .springframework .util .Assert ;
27
28
import org .springframework .util .ObjectUtils ;
28
29
import org .springframework .util .StringUtils ;
31
32
* A {@link MongoExpression} using the {@link ParameterBindingDocumentCodec} for parsing a raw ({@literal json})
32
33
* expression. The expression will be wrapped within <code>{ ... }</code> if necessary. The actual parsing and parameter
33
34
* binding of placeholders like {@code ?0} is delayed upon first call on the target {@link Document} via
34
- * {@link #toDocument()}.
35
- * <br />
35
+ * {@link #toDocument()}. <br />
36
36
*
37
37
* <pre class="code">
38
38
* $toUpper : $name -> { '$toUpper' : '$name' }
@@ -55,17 +55,17 @@ public class BindableMongoExpression implements MongoExpression {
55
55
56
56
private final @ Nullable CodecRegistryProvider codecRegistryProvider ;
57
57
58
- private final @ Nullable Object [] args ;
58
+ private final Object @ Nullable [] args ;
59
59
60
60
private final Lazy <Document > target ;
61
61
62
62
/**
63
63
* Create a new instance of {@link BindableMongoExpression}.
64
64
*
65
65
* @param expression must not be {@literal null}.
66
- * @param args can be {@literal null}.
66
+ * @param args must not be {@literal null} but may contain {@literal null} elements .
67
67
*/
68
- public BindableMongoExpression (String expression , @ Nullable Object [] args ) {
68
+ public BindableMongoExpression (String expression , Object @ Nullable [] args ) {
69
69
this (expression , null , args );
70
70
}
71
71
@@ -74,10 +74,10 @@ public BindableMongoExpression(String expression, @Nullable Object[] args) {
74
74
*
75
75
* @param expression must not be {@literal null}.
76
76
* @param codecRegistryProvider can be {@literal null}.
77
- * @param args can be {@literal null}.
77
+ * @param args must not be {@literal null} but may contain {@literal null} elements .
78
78
*/
79
79
public BindableMongoExpression (String expression , @ Nullable CodecRegistryProvider codecRegistryProvider ,
80
- @ Nullable Object [] args ) {
80
+ Object @ Nullable [] args ) {
81
81
82
82
Assert .notNull (expression , "Expression must not be null" );
83
83
@@ -93,6 +93,7 @@ public BindableMongoExpression(String expression, @Nullable CodecRegistryProvide
93
93
* @param codecRegistry must not be {@literal null}.
94
94
* @return new instance of {@link BindableMongoExpression}.
95
95
*/
96
+ @ Contract ("_ -> new" )
96
97
public BindableMongoExpression withCodecRegistry (CodecRegistry codecRegistry ) {
97
98
return new BindableMongoExpression (expressionString , () -> codecRegistry , args );
98
99
}
@@ -103,6 +104,7 @@ public BindableMongoExpression withCodecRegistry(CodecRegistry codecRegistry) {
103
104
* @param args must not be {@literal null}.
104
105
* @return new instance of {@link BindableMongoExpression}.
105
106
*/
107
+ @ Contract ("_ -> new" )
106
108
public BindableMongoExpression bind (Object ... args ) {
107
109
return new BindableMongoExpression (expressionString , codecRegistryProvider , args );
108
110
}
@@ -139,7 +141,7 @@ private Document parse() {
139
141
140
142
private static String wrapJsonIfNecessary (String json ) {
141
143
142
- if (!StringUtils .hasText (json )) {
144
+ if (!StringUtils .hasText (json )) {
143
145
return json ;
144
146
}
145
147
0 commit comments