James
James

Reputation: 121

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.

Upvotes: 3

Views: 1582

Answers (1)

James
James

Reputation: 121

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());

Upvotes: 9

Related Questions