Skip to content

Commit 188f27a

Browse files
committed
remove jetbrains annotations and lock toolbox lib to release candidate version
1 parent 133447f commit 188f27a

5 files changed

Lines changed: 33 additions & 29 deletions

File tree

pom.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<dependency>
2424
<groupId>it.aboutbits</groupId>
2525
<artifactId>spring-boot-toolbox</artifactId>
26-
<version>BUILD-SNAPSHOT</version>
26+
<version>1.0.0-RC1</version>
2727
</dependency>
2828

2929
<dependency>
@@ -38,13 +38,6 @@
3838
<optional>true</optional>
3939
</dependency>
4040

41-
<!-- https://mvnrepository.com/artifact/org.jetbrains/annotations -->
42-
<dependency>
43-
<groupId>org.jetbrains</groupId>
44-
<artifactId>annotations</artifactId>
45-
<version>24.1.0</version>
46-
</dependency>
47-
4841
<!-- Testing -->
4942
<dependency>
5043
<groupId>org.springframework.boot</groupId>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package it.aboutbits.springboot.testing.validation.core;
2+
3+
class RuleValidationException extends RuntimeException {
4+
RuleValidationException(String message) {
5+
super(message);
6+
}
7+
8+
RuleValidationException(String message, Throwable cause) {
9+
super(message, cause);
10+
}
11+
}

src/main/java/it/aboutbits/springboot/testing/validation/core/RuleValidator.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
import jakarta.validation.ValidatorFactory;
77
import lombok.NonNull;
88
import lombok.SneakyThrows;
9-
import org.jetbrains.annotations.NotNull;
10-
import org.jetbrains.annotations.Nullable;
9+
import org.springframework.lang.Nullable;
1110

1211
import java.lang.reflect.Field;
1312
import java.lang.reflect.InvocationTargetException;
@@ -145,7 +144,7 @@ private static <P> void checkIfNestedValidationIsEnabledForNestedRecords(
145144
}
146145
}
147146

148-
@NotNull
147+
@NonNull
149148
@SneakyThrows(ReflectiveOperationException.class)
150149
private static <P> Stream<?> getValues(Rule rule, P parameterUnderTest) {
151150
var source = (ValueSource) rule.getValueSource().getDeclaredConstructors()[0].newInstance();
@@ -204,12 +203,12 @@ private static <T> T createCopyWithAlteredProperty(T original, String property,
204203
// Create a copy with the altered property value
205204
return (T) constructor.newInstance(newPropertyValues);
206205
} catch (NoSuchMethodException e) {
207-
throw new RuntimeException(
206+
throw new RuleValidationException(
208207
"Error creating copy with altered property. Maybe there is no all-args-constructor?",
209208
e
210209
);
211210
} 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);
213212
}
214213
}
215214

@@ -243,14 +242,15 @@ private static boolean hasNullableAnnotation(String propertyName, Object object)
243242
|| field.getAnnotation(jakarta.annotation.Nullable.class) != null;
244243
}
245244

246-
private static @NotNull Field getFieldOrFail(String propertyName, Object object) {
245+
@NonNull
246+
private static Field getFieldOrFail(String propertyName, Object object) {
247247
var clazz = object.getClass();
248248

249249
Field field = null;
250250
try {
251251
field = clazz.getDeclaredField(propertyName);
252252
} catch (NoSuchFieldException e) {
253-
throw new RuntimeException("Property does not exist: " + propertyName, e);
253+
throw new RuleValidationException("Property does not exist: " + propertyName, e);
254254
}
255255
return field;
256256
}

src/main/java/it/aboutbits/springboot/testing/validation/source/BiggerThanValueSource.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import it.aboutbits.springboot.testing.validation.core.ValueSource;
44
import it.aboutbits.springboot.toolbox.type.ScaledBigDecimal;
5-
import org.jetbrains.annotations.NotNull;
5+
import lombok.NonNull;
66

77
import java.math.BigDecimal;
88
import java.util.HashMap;
@@ -47,7 +47,7 @@ public <T> Stream<T> values(Class<T> propertyClass, Object... args) {
4747
throw new IllegalArgumentException("Property class not supported!");
4848
}
4949

50-
@NotNull
50+
@NonNull
5151
private static Stream<Integer> getIntegerStream(Object[] args) {
5252
var minValue = Long.valueOf((long) args[0]).intValue() + 1;
5353
var maxValue = Integer.MAX_VALUE;
@@ -58,7 +58,7 @@ private static Stream<Integer> getIntegerStream(Object[] args) {
5858
);
5959
}
6060

61-
@NotNull
61+
@NonNull
6262
private static Stream<Long> getLongStream(Object[] args) {
6363
var minValue = (long) args[0] + 1;
6464
var maxValue = Long.MAX_VALUE;
@@ -69,7 +69,7 @@ private static Stream<Long> getLongStream(Object[] args) {
6969
);
7070
}
7171

72-
@NotNull
72+
@NonNull
7373
private static Stream<Float> getFloatStream(Object[] args) {
7474
var minValue = Long.valueOf((long) args[0]).floatValue() + 0.1f;
7575
var maxValue = Float.MAX_VALUE;
@@ -82,7 +82,7 @@ private static Stream<Float> getFloatStream(Object[] args) {
8282
);
8383
}
8484

85-
@NotNull
85+
@NonNull
8686
private static Stream<Double> getDoubleStream(Object[] args) {
8787
var minValue = Long.valueOf((long) args[0]).doubleValue() + 0.1d;
8888
var maxValue = Double.MAX_VALUE;
@@ -93,7 +93,7 @@ private static Stream<Double> getDoubleStream(Object[] args) {
9393
);
9494
}
9595

96-
@NotNull
96+
@NonNull
9797
private static Stream<ScaledBigDecimal> getScaledBigDecimalStream(Object[] args) {
9898
var minValue = Long.valueOf((long) args[0]).doubleValue() + 0.1d;
9999
var maxValue = Double.MAX_VALUE;
@@ -104,7 +104,7 @@ private static Stream<ScaledBigDecimal> getScaledBigDecimalStream(Object[] args)
104104
);
105105
}
106106

107-
@NotNull
107+
@NonNull
108108
private static Stream<BigDecimal> getBigDecimalStream(Object[] args) {
109109
var minValue = Long.valueOf((long) args[0]).doubleValue() + 0.1d;
110110
var maxValue = Double.MAX_VALUE;

src/main/java/it/aboutbits/springboot/testing/validation/source/LessThanValueSource.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import it.aboutbits.springboot.testing.validation.core.ValueSource;
44
import it.aboutbits.springboot.toolbox.type.ScaledBigDecimal;
5-
import org.jetbrains.annotations.NotNull;
5+
import lombok.NonNull;
66

77
import java.math.BigDecimal;
88
import java.util.HashMap;
@@ -48,7 +48,7 @@ public <T> Stream<T> values(Class<T> propertyClass, Object... args) {
4848
throw new IllegalArgumentException("Property class not supported!");
4949
}
5050

51-
@NotNull
51+
@NonNull
5252
private static Stream<Integer> getIntegerStream(Object[] args) {
5353
var minValue = Integer.MIN_VALUE;
5454
var maxValue = Long.valueOf((long) args[0]).intValue() - 1;
@@ -59,7 +59,7 @@ private static Stream<Integer> getIntegerStream(Object[] args) {
5959
);
6060
}
6161

62-
@NotNull
62+
@NonNull
6363
private static Stream<Long> getLongStream(Object[] args) {
6464
var minValue = Long.MIN_VALUE;
6565
var maxValue = (long) args[0] - 1;
@@ -70,7 +70,7 @@ private static Stream<Long> getLongStream(Object[] args) {
7070
);
7171
}
7272

73-
@NotNull
73+
@NonNull
7474
private static Stream<Float> getFloatStream(Object[] args) {
7575
var minValue = Float.MAX_VALUE * -1;
7676
var maxValue = Long.valueOf((long) args[0]).floatValue() - 0.1f;
@@ -83,7 +83,7 @@ private static Stream<Float> getFloatStream(Object[] args) {
8383
);
8484
}
8585

86-
@NotNull
86+
@NonNull
8787
private static Stream<Double> getDoubleStream(Object[] args) {
8888
var minValue = Double.MAX_VALUE * -1;
8989
var maxValue = Long.valueOf((long) args[0]).doubleValue() - 0.1d;
@@ -94,7 +94,7 @@ private static Stream<Double> getDoubleStream(Object[] args) {
9494
);
9595
}
9696

97-
@NotNull
97+
@NonNull
9898
private static Stream<BigDecimal> getBigDecimalStream(Object[] args) {
9999
var minValue = Double.MAX_VALUE * -1;
100100
var maxValue = Long.valueOf((long) args[0]).doubleValue() - 0.1d;
@@ -105,7 +105,7 @@ private static Stream<BigDecimal> getBigDecimalStream(Object[] args) {
105105
);
106106
}
107107

108-
@NotNull
108+
@NonNull
109109
private static Stream<ScaledBigDecimal> getScaledBigDecimalStream(Object[] args) {
110110
var minValue = Double.MAX_VALUE * -1;
111111
var maxValue = Long.valueOf((long) args[0]).doubleValue() - 0.1d;

0 commit comments

Comments
 (0)