void (JDefinedClass wrapperClass, Map<String, JClass> types, JsonNode node) { JCodeModel model = wrapperClass.owner(); String comment = "Type: {@code " + types.values().stream().map(it -> it.name()).collect(Collectors.joining(" | ")) + "}"; boolean isIncludeGetters = ruleFactory.getGenerationConfig().isIncludeGetters(); boolean isIncludeSetters = ruleFactory.getGenerationConfig().isIncludeSetters(); int accessModifier = isIncludeGetters || isIncludeSetters ? JMod.PRIVATE : JMod.PUBLIC; JType propertyType = model.ref(Object.class); String propertyName = "value"; JFieldVar field = wrapperClass.field(accessModifier, propertyType, propertyName); field.javadoc().add(comment); if (isIncludeGetters) { JMethod getter = wrapperClass.method(JMod.PUBLIC, propertyType, "getValue"); getter.javadoc().add(comment); JBlock body = getter.body(); body._return(field); } if (isIncludeSetters) { JMethod setter = wrapperClass.method(JMod.PUBLIC, void.class, "setValue"); setter.javadoc().add(comment); JVar param = setter.param(field.type(), field.name()); JBlock body = setter.body(); body.assign(JExpr._this().ref(field), param); } if (ruleFactory.getGenerationConfig().isIncludeToString()) { addToString(wrapperClass); } if (ruleFactory.getGenerationConfig().isIncludeHashcodeAndEquals()) { addHashCode(wrapperClass, node); addEquals(wrapperClass, node); } if (ruleFactory.getGenerationConfig().isSerializable()) { SerializableHelper.addSerializableSupport(wrapperClass); } if (node.has("javaInterfaces")) { addInterfaces(wrapperClass, node.get("javaInterfaces")); } JBlock statements = attachDeserializerTo(wrapperClass); statements.decl(0, wrapperClass, "result", JExpr._new(wrapperClass)); statements.decl(0, model.ref(JsonToken.class), "token", JExpr.invoke(JExpr.ref("parser"), "currentToken")); JBlock block = statements; for (Map.Entry<String, JClass> entry : types.entrySet()) { block = createDeserializeFor(block, entry.getKey(), entry.getValue()); } block.invoke(JExpr.ref("deserializationContext"), "handleUnexpectedToken") .arg(JExpr.dotclass(model.ref(Object.class))) .arg(JExpr.ref("parser")); statements._return(JExpr.ref("result")); }