简体   繁体   中英

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.

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

JClass temp = codeModel.ref(Class.class).narrow(codeModel.ref(Serializable.class).wildcard());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM