@@ -29,14 +29,13 @@ abstract class AbstractJreRangeCondition<A extends Annotation> extends BooleanEx
29
29
private static final JRE DEFAULT_MINIMUM_JRE = JRE .JAVA_17 ;
30
30
private static final JRE DEFAULT_MAXIMUM_JRE = JRE .OTHER ;
31
31
32
- private final String annotationName ;
33
-
34
32
AbstractJreRangeCondition (Class <A > annotationType , Function <A , String > customDisabledReason ) {
35
33
super (annotationType , ENABLED_ON_CURRENT_JRE , DISABLED_ON_CURRENT_JRE , customDisabledReason );
36
- this .annotationName = annotationType .getSimpleName ();
37
34
}
38
35
39
36
protected final boolean isCurrentVersionWithinRange (JRE minJre , JRE maxJre , int minVersion , int maxVersion ) {
37
+ String annotationName = super .annotationType .getSimpleName ();
38
+
40
39
boolean minJreSet = minJre != JRE .UNDEFINED ;
41
40
boolean maxJreSet = maxJre != JRE .UNDEFINED ;
42
41
boolean minVersionSet = minVersion != JRE .UNDEFINED_VERSION ;
@@ -45,17 +44,17 @@ protected final boolean isCurrentVersionWithinRange(JRE minJre, JRE maxJre, int
45
44
// Users must choose between JRE enum constants and version numbers.
46
45
Preconditions .condition (!minJreSet || !minVersionSet ,
47
46
() -> "@%s's minimum value must be configured with either a JRE enum constant or numeric version, but not both" .formatted (
48
- this . annotationName ));
47
+ annotationName ));
49
48
Preconditions .condition (!maxJreSet || !maxVersionSet ,
50
49
() -> "@%s's maximum value must be configured with either a JRE enum constant or numeric version, but not both" .formatted (
51
- this . annotationName ));
50
+ annotationName ));
52
51
53
52
// Users must supply valid values for minVersion and maxVersion.
54
53
Preconditions .condition (!minVersionSet || (minVersion >= JRE .MINIMUM_VERSION ),
55
- () -> "@%s's minVersion [%d] must be greater than or equal to %d" .formatted (this . annotationName , minVersion ,
54
+ () -> "@%s's minVersion [%d] must be greater than or equal to %d" .formatted (annotationName , minVersion ,
56
55
JRE .MINIMUM_VERSION ));
57
56
Preconditions .condition (!maxVersionSet || (maxVersion >= JRE .MINIMUM_VERSION ),
58
- () -> "@%s's maxVersion [%d] must be greater than or equal to %d" .formatted (this . annotationName , maxVersion ,
57
+ () -> "@%s's maxVersion [%d] must be greater than or equal to %d" .formatted (annotationName , maxVersion ,
59
58
JRE .MINIMUM_VERSION ));
60
59
61
60
// Now that we have checked the basic preconditions, we need to ensure that we are
@@ -72,10 +71,10 @@ protected final boolean isCurrentVersionWithinRange(JRE minJre, JRE maxJre, int
72
71
73
72
// Finally, we need to validate the effective minimum and maximum values.
74
73
Preconditions .condition ((min != DEFAULT_MINIMUM_JRE .version () || max != DEFAULT_MAXIMUM_JRE .version ()),
75
- () -> "You must declare a non-default value for the minimum or maximum value in @" + this . annotationName );
74
+ () -> "You must declare a non-default value for the minimum or maximum value in @" + annotationName );
76
75
Preconditions .condition (min <= max ,
77
76
() -> "@%s's minimum value [%d] must be less than or equal to its maximum value [%d]" .formatted (
78
- this . annotationName , min , max ));
77
+ annotationName , min , max ));
79
78
80
79
return JRE .isCurrentVersionWithinRange (min , max );
81
80
}
0 commit comments