private void addJsonTypeInfoAnnotation(JDefinedClass jclass, JsonNode node) { if (ruleFactory.getGenerationConfig().getAnnotationStyle() == AnnotationStyle.JACKSON2) { String annotationName = node.get("deserializationClassProperty").asText(); JAnnotationUse jsonTypeInfo = jclass.annotate(JsonTypeInfo.class); jsonTypeInfo.param("use", JsonTypeInfo.Id.CLASS); jsonTypeInfo.param("include", JsonTypeInfo.As.PROPERTY); jsonTypeInfo.param("property", annotationName); } }
private List<String> getAnnotationStyleRealm(){ ArrayList<String> result= new ArrayList<String>(Arrays.asList( AnnotationStyle.GSON.name(), AnnotationStyle.JACKSON.name(), AnnotationStyle.JACKSON1.name(), AnnotationStyle.JACKSON2.name(), AnnotationStyle.NONE.name() )); return result; }
private Configuration prepareConfiguraton(UIConfiguration uiConfig) { IContainer srcFolder = uiConfig.getSrcFolder(); if(srcFolder == null){ srcFolder = uiConfig.getRamlFile().getParent(); } File srcOSFolder = srcFolder.getLocation().toFile(); File dstOSFolder = uiConfig.getDstFolder().getLocation().toFile(); Configuration configuration = new Configuration(); configuration.setOutputDirectory(dstOSFolder); configuration.setSourceDirectory(srcOSFolder); configuration.setBasePackageName(uiConfig.getBasePackageName()); configuration.setGenerateClientInterface(uiConfig.getGenerateClientProxy()); JaxrsVersion jaxrsVersion = JaxrsVersion.valueOf(uiConfig.getJaxrsVersion()); if(jaxrsVersion!=null){ configuration.setJaxrsVersion(jaxrsVersion); } AnnotationStyle jsonMapper = AnnotationStyle.valueOf(uiConfig.getJsonMapper()); if(jsonMapper!=null){ configuration.setJsonMapper(jsonMapper); } configuration.setUseJsr303Annotations(uiConfig.getUseJsr303Annotations()); configuration.setEmptyResponseReturnVoid(uiConfig.getEmptyResponseUsesVoid()); return configuration; }
/** * Create a GenerateRunner for a specific target directory. * <p> * The output directory of the .java client is * <code>src/main/java/org/folio/rest/client</code>, * the output directory of the .java pojos is * <code>src/main/java/org/folio/rest/jaxrs/model</code>, * the output directory of the RAML and dereferenced schema files is * <code>target/classes</code>; they are relative to the parameter * <code>outputDirectory</code>. * * @param outputDirectory where to write the files to */ public GenerateRunner(String outputDirectory) { this.outputDirectory = outputDirectory; outputDirectoryWithPackage = outputDirectory + PACKAGE_DEFAULT.replace('.', '/'); modelDirectory = outputDirectory + MODEL_PACKAGE_DEFAULT.replace('.', '/'); List<GeneratorExtension> extensions = new ArrayList<>(); extensions.add(new Raml2Java()); configuration = new Configuration(); configuration.setJaxrsVersion(JaxrsVersion.JAXRS_2_0); configuration.setUseJsr303Annotations(true); configuration.setJsonMapper(AnnotationStyle.JACKSON2); configuration.setBasePackageName(PACKAGE_DEFAULT); configuration.setExtensions(extensions); }
@Override public AnnotationStyle getAnnotationStyle() { return AnnotationStyle.valueOf(annotationStyle.toUpperCase()); }
private boolean usesPolymorphicDeserialization(JsonNode node) { if (ruleFactory.getGenerationConfig().getAnnotationStyle() == AnnotationStyle.JACKSON2) { return node.has("deserializationClassProperty"); } return false; }
@Override public AnnotationStyle getAnnotationStyle() { return annotationStyle; }
private static Annotator requireAnnotator(AnnotationStyle annotationStyle) { checkState(ANNOTATOR_SUPPLIER_INDEX.containsKey(annotationStyle), "Illegal annotation style: %s", annotationStyle); return ANNOTATOR_SUPPLIER_INDEX.get(annotationStyle).get(); }
@Override public AnnotationStyle getAnnotationStyle() { return firstNonNull(config.getAnnotationStyle(), super.getAnnotationStyle()); }
public AnnotationStyle getAnnotationStyle() { return annotationStyle; }
/** * Sets the 'annotationStyle' property of this class * * @param annotationStyle * The style of annotations to use in the generated Java types. */ public void setAnnotationStyle(AnnotationStyle annotationStyle) { this.annotationStyle = annotationStyle; }
/** * <p>Getter for the field <code>jsonMapper</code>.</p> * * @return a {@link org.jsonschema2pojo.AnnotationStyle} object. */ public AnnotationStyle getJsonMapper() { return jsonMapper; }
/** * <p>Setter for the field <code>jsonMapper</code>.</p> * * @param jsonMapper a {@link org.jsonschema2pojo.AnnotationStyle} object. */ public void setJsonMapper(final AnnotationStyle jsonMapper) { this.jsonMapper = jsonMapper; }