@@ -185,9 +185,36 @@ public SimpleTypeHolder getSimpleTypeHolder() {
185
185
*/
186
186
public boolean hasValueConverter (PersistentProperty <?> property ) {
187
187
188
- PropertyValueConversions propertyValueConversions = getPropertyValueConversions ();
188
+ PropertyValueConversions pvc = getPropertyValueConversions ();
189
189
190
- return propertyValueConversions != null && propertyValueConversions .hasValueConverter (property );
190
+ return pvc != null && pvc .hasValueConverter (property );
191
+ }
192
+
193
+ /**
194
+ * Returns the required {@link PropertyValueConverter} for the given {@link PersistentProperty} or throws
195
+ * {@link IllegalStateException} if no converter is available. This is a convenience method for
196
+ * {@code getPropertyValueConversions().getValueConverter(...)} enforcing non-null constraints.
197
+ * <p>
198
+ * Prior to calling this method you should verify a converter is available using
199
+ * {@link #hasValueConverter(PersistentProperty)}.
200
+ *
201
+ * @param property {@link PersistentProperty} to evaluate; must not be {@literal null}.
202
+ * @return the required {@link PropertyValueConverter}
203
+ * @throws IllegalStateException if no converter is available.
204
+ * @since 4.0
205
+ * @see #hasValueConverter(PersistentProperty)
206
+ */
207
+ public <DV , SV , P extends PersistentProperty <P >, VCC extends ValueConversionContext <P >> PropertyValueConverter <DV , SV , VCC > getRequiredValueConverter (
208
+ P property ) {
209
+
210
+ PropertyValueConversions pvc = getPropertyValueConversions ();
211
+ PropertyValueConverter <DV , SV , VCC > converter = pvc != null ? pvc .getValueConverter (property ) : null ;
212
+
213
+ if (converter == null ) {
214
+ throw new IllegalStateException ("No value converter registered for property %s" .formatted (property .getName ()));
215
+ }
216
+
217
+ return converter ;
191
218
}
192
219
193
220
/**
0 commit comments