Generalised _get for Karibu used in Java Test

When trying to get generalised Components; say a Grid of Person then i can not do that nicely. My IDE warns me about an unchecked assignment.

Couldn’t you use similar tricks like other libraries. The tricks used by these other libraries enable users to also use generic types.

Mockito uses some magic with Varargs:
https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#54
https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#mock(java.lang.Object[])

Jacksons TypeReference and Guavas TypeToken
https://fasterxml.github.io/jackson-core/javadoc/2.2.0/com/fasterxml/jackson/core/type/TypeReference.html
https://guava.dev/releases/21.0/api/docs/com/google/common/reflect/TypeToken.html

There are probably a lot of other approaches this can be solved, but sadly karibu can not do this today.

2 Likes

Hi Dario,

@SupressWarnings :wink: