https://kotlinlang.org logo
#konsist
Title
# konsist
y

Yonatan Karp-Rudin

10/10/2023, 9:36 AM
Hi, I just noticed that I need the validation
hasAnyAnnotationsOf()
for this test example:
Copy code
Konsist
    .scopeFromProject()
    .classes()
    .properties()
    .assertFalse { it.hasAnyAnnotationsOf(Autowired::class, Inject::class) }
The main reason here is that spring supports both the
@Autowired
and
@Inject
annotation for DI.
i

igor.wojda

10/10/2023, 10:53 AM
Use
hasAnnotationOf
- works like
Any
- "Determines whether the declaration has at least one annotation of the specified
KClass
type"
😅 1
y

Yonatan Karp-Rudin

10/12/2023, 8:22 PM
Oh the name was a bit misleading - I kinda assume that it accepts only 1 annotation 🤔
i

igor.wojda

10/13/2023, 12:21 AM
I am not sure if there is a perfect name here - most times devs will check one thing. So Name with
s
may be also confusing
2 Views