JInvocation (JClass itemClass) { if (itemClass.getTypeParameters().isEmpty()) { return JExpr.ref("parser").invoke("readValueAs").arg(JExpr.dotclass(itemClass)); } else { JInvocation inv = JExpr.ref("deserializationContext").invoke("getTypeFactory").invoke("constructParametricType") .arg(itemClass.dotclass()); for (JClass param : itemClass.getTypeParameters()) { inv.arg(param.dotclass()); } return JExpr.ref("parser").invoke("getCodec").invoke("readValue").arg(JExpr.ref("parser")).arg(inv); } }