void (JDefinedClass jclass, Map<String, JType> subTypes, String propertyName) { JAnnotationUse jsonTypeInfo = jclass.annotate(JsonTypeInfo.class); jsonTypeInfo.param("use", JsonTypeInfo.Id.NAME); jsonTypeInfo.param("property", propertyName); jsonTypeInfo.param("visible", true); JAnnotationUse jsonSubTypes = jclass.annotate(JsonSubTypes.class); JAnnotationArrayMember subTypesList = jsonSubTypes.paramArray("value"); for (Map.Entry<String, JType> entry : subTypes.entrySet()) { JAnnotationUse subtype = subTypesList.annotate(JsonSubTypes.Type.class); subtype.param("name", entry.getKey()); subtype.param("value", entry.getValue()); } }