org.jsonschema2pojo.rules.RuleFactory Java Examples

The following examples show how to use org.jsonschema2pojo.rules.RuleFactory. 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: JsonSchemaController.java    From sc-generator with Apache License 2.0 4 votes vote down vote up
protected JCodeModel getCodegenModel(String schema,
                                     String targetpackage,
                                     final String sourcetype,
                                     final String annotationstyle,
                                     final boolean usedoublenumbers,
                                     final boolean includeaccessors,
                                     final boolean includeadditionalproperties,
                                     final String propertyworddelimiters,
                                     String classname) throws IOException {

    JCodeModel codeModel = new JCodeModel();

    GenerationConfig config = new DefaultGenerationConfig() {
        @Override
        public boolean isGenerateBuilders() { // set config option by overriding method
            return true;
        }

        @Override
        public SourceType getSourceType() {
            return SourceType.valueOf(sourcetype.toUpperCase());
        }

        @Override
        public AnnotationStyle getAnnotationStyle() {
            return AnnotationStyle.valueOf(annotationstyle.toUpperCase());
        }

        @Override
        public boolean isUseDoubleNumbers() {
            return usedoublenumbers;
        }

        @Override
        public boolean isIncludeAccessors() {
            return includeaccessors;
        }

        @Override
        public boolean isIncludeAdditionalProperties() {
            return includeadditionalproperties;
        }

        @Override
        public char[] getPropertyWordDelimiters() {
            return propertyworddelimiters.replace(" ", "").toCharArray();
        }


    };


    AnnotatorFactory factory = new AnnotatorFactory(config);
    CompositeAnnotator annotator = factory.getAnnotator(factory.getAnnotator(config.getAnnotationStyle()), factory.getAnnotator(config.getCustomAnnotator()));
    SchemaMapper mapper = new SchemaMapper(new RuleFactory(config, annotator, new SchemaStore()), new SchemaGenerator());
    mapper.generate(codeModel, classname, targetpackage, schema);
    return codeModel;
}
 
Example #2
Source File: JaxRsEnumRule.java    From apicurio-studio with Apache License 2.0 4 votes vote down vote up
protected JaxRsEnumRule(RuleFactory ruleFactory) {
    this.ruleFactory = ruleFactory;
}
 
Example #3
Source File: RamlJavaClientGenerator.java    From raml-java-client-generator with Apache License 2.0 4 votes vote down vote up
private RuleFactory getRuleFactory(final SourceType sourceType, CodeGenConfig codeGenConfig) {
    final DefaultGenerationConfig generationConfig = new JsonSchemaGeneratorConfiguration(sourceType, codeGenConfig);

    return new RuleFactory(generationConfig, new Jackson2Annotator(generationConfig), new SchemaStore());
}