org.jsonschema2pojo.GenerationConfig Java Examples
The following examples show how to use
org.jsonschema2pojo.GenerationConfig.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IstioTypeAnnotator.java From istio-java-api with Apache License 2.0 | 5 votes |
public IstioTypeAnnotator(GenerationConfig generationConfig) { super(generationConfig); String className = DONEABLE_CLASS_NAME; try { doneableClass = new JCodeModel()._class(className); className = OBJECT_META_CLASS_NAME; objectMetaClass = new JCodeModel()._class(className); } catch (JClassAlreadyExistsException e) { throw new IllegalStateException("Couldn't load " + className); } }
Example #2
Source File: CustomTypeAnnotator.java From raml-module-builder with Apache License 2.0 | 5 votes |
public CustomTypeAnnotator(GenerationConfig generationConfig) { //called once for each json schema defined super(generationConfig); //load into a table the custom json schema fields for (int j = 0; j < schemaCustomFields.length; j++) { JsonObject jo = new JsonObject(schemaCustomFields[j]); String fieldName = jo.getString("fieldname"); Object fieldValue = jo.getValue("fieldvalue"); JsonObject annotation = jo.getJsonObject("annotation"); if(annotationLookUp.get(fieldName, fieldValue) == null){ annotationLookUp.put(fieldName , fieldValue, annotation); log.info("Loading custom field " + fieldName + " with value " + fieldValue + " with annotation " + annotation.encode()); } } }
Example #3
Source File: KubernetesTypeAnnotator.java From enmasse with Apache License 2.0 | 4 votes |
public KubernetesTypeAnnotator(GenerationConfig generationConfig) { super(generationConfig); }
Example #4
Source File: OpenApi2JaxRs.java From apicurio-studio with Apache License 2.0 | 4 votes |
/** * Generates a Java Bean class for the given bean info. The bean info should * have a name, package, and JSON Schema. This information will be used to * generate a POJO. * @param bean * @param info * @param codeWriter * @throws IOException */ private void generateJavaBean(CodegenJavaBean bean, CodegenInfo info, IndexedCodeWriter codeWriter) throws IOException { JCodeModel codeModel = new JCodeModel(); GenerationConfig config = new DefaultGenerationConfig() { @Override public boolean isUsePrimitives() { return false; } @Override public boolean isIncludeHashcodeAndEquals() { return false; } @Override public boolean isIncludeAdditionalProperties() { return false; } @Override public boolean isIncludeToString() { return false; } }; SchemaMapper schemaMapper = new SchemaMapper( new JaxRsRuleFactory(config, new Jackson2Annotator(config), new SchemaStore() { @Override public Schema create(Schema parent, String path, String refFragmentPathDelimiters) { String beanClassname = schemaRefToFQCN(path); for (CodegenJavaBean cgBean : info.getBeans()) { String cgBeanFQCN = cgBean.getPackage() + "." + StringUtils.capitalize(cgBean.getName()); if (beanClassname.equals(cgBeanFQCN)) { Schema schema = new Schema(classnameToUri(beanClassname), cgBean.get$schema(), null); JType jclass = codeModel._getClass(beanClassname); if (jclass == null) { jclass = codeModel.directClass(beanClassname); } schema.setJavaType(jclass); return schema; } } System.out.println("!!!!! :: " + beanClassname); // TODO if we get here, we probably want to return an empty schema return super.create(parent, path, refFragmentPathDelimiters); } }), new SchemaGenerator()); String source = mapper.writeValueAsString(bean.get$schema()); schemaMapper.generate(codeModel, bean.getName(), bean.getPackage(), source); codeModel.build(codeWriter); }
Example #5
Source File: OpenApi2JaxRs.java From apicurio-studio with Apache License 2.0 | 4 votes |
/** * Constructor. */ public JaxRsRuleFactory(GenerationConfig generationConfig, Annotator annotator, SchemaStore schemaStore) { super(generationConfig, annotator, schemaStore); }
Example #6
Source File: SchemaHelper.java From springmvc-raml-plugin with Apache License 2.0 | 4 votes |
/** * Returns a generation config with the supplied parameters. If any of these * parameters are supplied null, it will use the value defined in the * default configuration * * @param generateBuilders * Enables or disables * {@link GenerationConfig#isGenerateBuilders()} * @param includeAdditionalProperties * Enables or disables * {@link GenerationConfig#isIncludeAdditionalProperties()} * @param includeDynamicAccessors * Enables or disables * {@link GenerationConfig#isIncludeDynamicAccessors()} * @param useLongIntegers * Enables or disables * {@link GenerationConfig#isUseLongIntegers()} * @return The GenerationConfig */ public static GenerationConfig getGenerationConfig(Boolean generateBuilders, Boolean includeAdditionalProperties, Boolean includeDynamicAccessors, Boolean useLongIntegers) { return new DefaultGenerationConfig() { @Override public boolean isGenerateBuilders() { // set config option by // overriding method if (generateBuilders != null) { return generateBuilders; } else { return true; } } @Override public boolean isIncludeAdditionalProperties() { if (includeAdditionalProperties != null) { return includeAdditionalProperties; } else { return false; } } @Override public boolean isIncludeDynamicAccessors() { if (includeDynamicAccessors != null) { return includeDynamicAccessors; } else { return false; } } @Override public boolean isUseLongIntegers() { if (useLongIntegers != null) { return useLongIntegers; } else { return super.isUseLongIntegers(); } } }; }
Example #7
Source File: SchemaHelper.java From springmvc-raml-plugin with Apache License 2.0 | 2 votes |
/** * Returns a configuration for the JSON Schema 2 POJO that is in line with * the defaults used in the plugin so far * * @return Default Generation Config */ public static GenerationConfig getDefaultGenerationConfig() { return getGenerationConfig(true, false, false, false); }