|
6 | 6 | import jakarta.validation.ValidatorFactory; |
7 | 7 | import lombok.NonNull; |
8 | 8 | import lombok.SneakyThrows; |
9 | | -import org.jetbrains.annotations.NotNull; |
10 | | -import org.jetbrains.annotations.Nullable; |
| 9 | +import org.springframework.lang.Nullable; |
11 | 10 |
|
12 | 11 | import java.lang.reflect.Field; |
13 | 12 | import java.lang.reflect.InvocationTargetException; |
@@ -145,7 +144,7 @@ private static <P> void checkIfNestedValidationIsEnabledForNestedRecords( |
145 | 144 | } |
146 | 145 | } |
147 | 146 |
|
148 | | - @NotNull |
| 147 | + @NonNull |
149 | 148 | @SneakyThrows(ReflectiveOperationException.class) |
150 | 149 | private static <P> Stream<?> getValues(Rule rule, P parameterUnderTest) { |
151 | 150 | var source = (ValueSource) rule.getValueSource().getDeclaredConstructors()[0].newInstance(); |
@@ -204,12 +203,12 @@ private static <T> T createCopyWithAlteredProperty(T original, String property, |
204 | 203 | // Create a copy with the altered property value |
205 | 204 | return (T) constructor.newInstance(newPropertyValues); |
206 | 205 | } catch (NoSuchMethodException e) { |
207 | | - throw new RuntimeException( |
| 206 | + throw new RuleValidationException( |
208 | 207 | "Error creating copy with altered property. Maybe there is no all-args-constructor?", |
209 | 208 | e |
210 | 209 | ); |
211 | 210 | } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) { |
212 | | - throw new RuntimeException("Error creating copy with altered property: " + property, e); |
| 211 | + throw new RuleValidationException("Error creating copy with altered property: " + property, e); |
213 | 212 | } |
214 | 213 | } |
215 | 214 |
|
@@ -243,14 +242,15 @@ private static boolean hasNullableAnnotation(String propertyName, Object object) |
243 | 242 | || field.getAnnotation(jakarta.annotation.Nullable.class) != null; |
244 | 243 | } |
245 | 244 |
|
246 | | - private static @NotNull Field getFieldOrFail(String propertyName, Object object) { |
| 245 | + @NonNull |
| 246 | + private static Field getFieldOrFail(String propertyName, Object object) { |
247 | 247 | var clazz = object.getClass(); |
248 | 248 |
|
249 | 249 | Field field = null; |
250 | 250 | try { |
251 | 251 | field = clazz.getDeclaredField(propertyName); |
252 | 252 | } catch (NoSuchFieldException e) { |
253 | | - throw new RuntimeException("Property does not exist: " + propertyName, e); |
| 253 | + throw new RuleValidationException("Property does not exist: " + propertyName, e); |
254 | 254 | } |
255 | 255 | return field; |
256 | 256 | } |
|
0 commit comments