File tree Expand file tree Collapse file tree 5 files changed +21
-2
lines changed
main/java/io/avaje/validation/generator
test/java/io/avaje/validation/generator Expand file tree Collapse file tree 5 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ static ElementAnnotationContainer create(Element element) {
50
50
51
51
final var annotations =
52
52
element .getAnnotationMirrors ().stream ()
53
+ .filter (m -> !hasValid && !ValidPrism .isInstance (m ))
53
54
.collect (
54
55
toMap (
55
56
a -> GenericType .parse (a .getAnnotationType ().toString ()),
@@ -95,4 +96,8 @@ public void addImports(Set<String> importTypes) {
95
96
typeUse1 .keySet ().forEach (t -> t .addImports (importTypes ));
96
97
typeUse2 .keySet ().forEach (t -> t .addImports (importTypes ));
97
98
}
99
+
100
+ boolean isEmpty () {
101
+ return annotations .isEmpty () && typeUse1 .isEmpty () && typeUse2 .isEmpty ();
102
+ }
98
103
}
Original file line number Diff line number Diff line change @@ -175,4 +175,8 @@ public void writeConstructor(Append writer) {
175
175
public boolean isClassLvl () {
176
176
return classLevel ;
177
177
}
178
+
179
+ public boolean hasAnnotations () {
180
+ return !elementAnnotations .isEmpty ();
181
+ }
178
182
}
Original file line number Diff line number Diff line change @@ -58,7 +58,10 @@ void read(TypeElement type) {
58
58
}
59
59
}
60
60
61
- localFields .add (new FieldReader (type , genericTypeParams ));
61
+ final var classAdapter = new FieldReader (type , genericTypeParams );
62
+ if (classAdapter .hasAnnotations ()) {
63
+ localFields .add (classAdapter );
64
+ }
62
65
63
66
for (final FieldReader localField : localFields ) {
64
67
allFields .add (localField );
Original file line number Diff line number Diff line change 1
1
package io .avaje .validation .generator ;
2
2
3
+ import javax .lang .model .element .AnnotationMirror ;
3
4
import javax .lang .model .element .Element ;
4
5
5
6
public interface ValidPrism {
@@ -10,4 +11,11 @@ static boolean isPresent(Element e) {
10
11
|| JavaxValidPrism .isPresent (e )
11
12
|| HttpValidPrism .isPresent (e );
12
13
}
14
+
15
+ static boolean isInstance (AnnotationMirror e ) {
16
+ return AvajeValidPrism .getInstance (e ) != null
17
+ || JakartaValidPrism .getInstance (e ) != null
18
+ || JavaxValidPrism .getInstance (e ) != null
19
+ || HttpValidPrism .getInstance (e ) != null ;
20
+ }
13
21
}
Original file line number Diff line number Diff line change 22
22
import javax .tools .ToolProvider ;
23
23
24
24
import org .junit .jupiter .api .AfterEach ;
25
- import org .junit .jupiter .api .Disabled ;
26
25
import org .junit .jupiter .api .Test ;
27
26
28
27
class ValidatorProcessorTest {
You can’t perform that action at this time.
0 commit comments