Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create <? extends subtype> with JCodeModel?

I've used JClass.narrow on JCodeModel to create the necessary generics for types, but I can't figure out how to generate something like this.

private Class<? extends Serializable> dataType;

How does one generate the ? extends part?

Any help would be welcome.

like image 324
James Avatar asked Dec 05 '25 19:12

James


1 Answers

Figured it out. Here is an example of obtaining a JClass reference to Class<? extends Serializable>. Hope it helps someone.

JClass temp = codeModel.ref(Class.class).narrow(codeModel.ref(Serializable.class).wildcard());
like image 197
James Avatar answered Dec 08 '25 10:12

James



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!