vendredi 23 février 2018

Translate between KType and AnnotatedType

I have a simple TYPE_USE annotation:

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
public @interface Cool {
}

And the following sample Kotlin class:

class Item(
        id: Long? = null,
        var names: List<@Cool String> = emptyList())

Is there any way to extract the annotation using Java reflection?

Item.class.getMethod("getName").getAnnotatedReturnType() loses the annotations, same with getting the field.





Aucun commentaire:

Enregistrer un commentaire