@@ -39,11 +39,11 @@ public class Parameter<T, P extends PersistentProperty<P>> {
39
39
private final @ Nullable String name ;
40
40
private final TypeInformation <T > type ;
41
41
private final MergedAnnotations annotations ;
42
- private final String key ;
42
+ private final @ Nullable String expression ;
43
43
private final @ Nullable PersistentEntity <T , P > entity ;
44
44
45
45
private final Lazy <Boolean > enclosingClassCache ;
46
- private final Lazy <Boolean > hasSpelExpression ;
46
+ private final Lazy <Boolean > hasExpression ;
47
47
48
48
/**
49
49
* Creates a new {@link Parameter} with the given name, {@link TypeInformation} as well as an array of
@@ -64,7 +64,7 @@ public Parameter(@Nullable String name, TypeInformation<T> type, Annotation[] an
64
64
this .name = name ;
65
65
this .type = type ;
66
66
this .annotations = MergedAnnotations .from (annotations );
67
- this .key = getValue (this .annotations );
67
+ this .expression = getValue (this .annotations );
68
68
this .entity = entity ;
69
69
70
70
this .enclosingClassCache = Lazy .of (() -> {
@@ -77,7 +77,7 @@ public Parameter(@Nullable String name, TypeInformation<T> type, Annotation[] an
77
77
return ClassUtils .isInnerClass (owningType ) && type .getType ().equals (owningType .getEnclosingClass ());
78
78
});
79
79
80
- this .hasSpelExpression = Lazy .of (() -> StringUtils .hasText (getSpelExpression ()));
80
+ this .hasExpression = Lazy .of (() -> StringUtils .hasText (getValueExpression ()));
81
81
}
82
82
83
83
@ Nullable
@@ -128,21 +128,62 @@ public Class<T> getRawType() {
128
128
}
129
129
130
130
/**
131
- * Returns the key to be used when looking up a source data structure to populate the actual parameter value.
131
+ * Returns the expression to be used when looking up a source data structure to populate the actual parameter value.
132
132
*
133
- * @return
133
+ * @return the expression to be used when looking up a source data structure.
134
+ * @deprecated since 3.3, use {@link #getValueExpression()} instead.
134
135
*/
136
+ @ Nullable
135
137
public String getSpelExpression () {
136
- return key ;
138
+ return getValueExpression ();
139
+ }
140
+
141
+ /**
142
+ * Returns the expression to be used when looking up a source data structure to populate the actual parameter value.
143
+ *
144
+ * @return the expression to be used when looking up a source data structure.
145
+ * @since 3.3
146
+ */
147
+ @ Nullable
148
+ public String getValueExpression () {
149
+ return expression ;
150
+ }
151
+
152
+ /**
153
+ * Returns the required expression to be used when looking up a source data structure to populate the actual parameter
154
+ * value or throws {@link IllegalStateException} if there's no expression.
155
+ *
156
+ * @return the expression to be used when looking up a source data structure.
157
+ * @since 3.3
158
+ */
159
+ public String getRequiredValueExpression () {
160
+
161
+ if (!hasValueExpression ()) {
162
+ throw new IllegalStateException ("No expression associated with this parameter" );
163
+ }
164
+
165
+ return getValueExpression ();
137
166
}
138
167
139
168
/**
140
169
* Returns whether the constructor parameter is equipped with a SpEL expression.
141
170
*
142
- * @return
171
+ * @return {@literal true}} if the parameter is equipped with a SpEL expression.
172
+ * @deprecated since 3.3, use {@link #hasValueExpression()} instead.
143
173
*/
174
+ @ Deprecated (since = "3.3" )
144
175
public boolean hasSpelExpression () {
145
- return this .hasSpelExpression .get ();
176
+ return hasValueExpression ();
177
+ }
178
+
179
+ /**
180
+ * Returns whether the constructor parameter is equipped with a value expression.
181
+ *
182
+ * @return {@literal true}} if the parameter is equipped with a value expression.
183
+ * @since 3.3
184
+ */
185
+ public boolean hasValueExpression () {
186
+ return this .hasExpression .get ();
146
187
}
147
188
148
189
@ Override
@@ -157,12 +198,12 @@ public boolean equals(@Nullable Object o) {
157
198
}
158
199
159
200
return Objects .equals (this .name , that .name ) && Objects .equals (this .type , that .type )
160
- && Objects .equals (this .key , that .key ) && Objects .equals (this .entity , that .entity );
201
+ && Objects .equals (this .expression , that .expression ) && Objects .equals (this .entity , that .entity );
161
202
}
162
203
163
204
@ Override
164
205
public int hashCode () {
165
- return Objects .hash (name , type , key , entity );
206
+ return Objects .hash (name , type , expression , entity );
166
207
}
167
208
168
209
/**
0 commit comments