当前位置: 首页>>代码示例>>Java>>正文


Java RuleFactory类代码示例

本文整理汇总了Java中org.jsonschema2pojo.rules.RuleFactory的典型用法代码示例。如果您正苦于以下问题:Java RuleFactory类的具体用法?Java RuleFactory怎么用?Java RuleFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RuleFactory类属于org.jsonschema2pojo.rules包,在下文中一共展示了RuleFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCustomRuleFactory

import org.jsonschema2pojo.rules.RuleFactory; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Class<? extends RuleFactory> getCustomRuleFactory() {
    if (isNotBlank(customRuleFactory)) {
        try {
            return (Class<? extends RuleFactory>) Class.forName(customRuleFactory);
        } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException(e);
        }
    } else {
        return RuleFactory.class;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:Jsonschema2PojoMojo.java

示例2: setCustomRuleFactory

import org.jsonschema2pojo.rules.RuleFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void setCustomRuleFactory(String customRuleFactory) {
    if (isNotBlank(customRuleFactory)) {
        try {
            this.customRuleFactory = (Class<? extends RuleFactory>) Class.forName(customRuleFactory);
        } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException(e);
        }
    } else {
        this.customRuleFactory = RuleFactory.class;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:Jsonschema2PojoTask.java

示例3: selfRefWithoutParentFile

import org.jsonschema2pojo.rules.RuleFactory; //导入依赖的package包/类
@Test
public void selfRefWithoutParentFile() throws IOException {
    JCodeModel codeModel = new JCodeModel();
    JsonNode schema = new ObjectMapper().readTree("{\"type\":\"object\", \"properties\":{\"a\":{\"$ref\":\"#/b\"}}, \"b\":\"string\"}");
    
    JPackage p = codeModel._package("com.example");
    new RuleFactory().getSchemaRule().apply("Example", schema, p, new Schema(null, schema, schema));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:FragmentRefIT.java

示例4: refToInnerFragmentThatHasRefToOuterFragmentWithoutParentFile

import org.jsonschema2pojo.rules.RuleFactory; //导入依赖的package包/类
@Test
public void refToInnerFragmentThatHasRefToOuterFragmentWithoutParentFile() throws IOException, ClassNotFoundException {
    JCodeModel codeModel = new JCodeModel();
    JsonNode schema = new ObjectMapper().readTree("{\n" + 
          "    \"type\": \"object\",\n" + 
          "    \"definitions\": {\n" + 
          "        \"location\": {\n" + 
          "            \"type\": \"object\",\n" + 
          "            \"properties\": {\n" + 
          "                \"cat\": {\n" + 
          "                    \"$ref\": \"#/definitions/cat\"\n" + 
          "                }\n" + 
          "            }\n" + 
          "        },\n" + 
          "        \"cat\": {\n" + 
          "            \"type\": \"number\"\n" + 
          "        }\n" + 
          "    },\n" + 
          "    \"properties\": {\n" + 
          "        \"location\": {\n" + 
          "            \"$ref\": \"#/definitions/location\"\n" + 
          "        }\n" + 
          "    }\n" + 
          "}");
    
    JPackage p = codeModel._package("com.example");
    new RuleFactory().getSchemaRule().apply("Example", schema, p, new Schema(null, schema, schema));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:FragmentRefIT.java

示例5: createSchemaMapper

import org.jsonschema2pojo.rules.RuleFactory; //导入依赖的package包/类
private SchemaMapper createSchemaMapper() {
    final RuleFactory ruleFactory = new RuleFactory();
    ruleFactory.setAnnotator(new Jackson2Annotator() {

        @Override
        public boolean isAdditionalPropertiesSupported() {
            return false;
        }
    });
    ruleFactory.setGenerationConfig(config);
    return new SchemaMapper(ruleFactory, new SchemaGenerator());
}
 
开发者ID:fabric8io,项目名称:data-mapper,代码行数:13,代码来源:JsonModelGenerator.java

示例6: getCustomRuleFactory

import org.jsonschema2pojo.rules.RuleFactory; //导入依赖的package包/类
@Override
public Class<? extends RuleFactory> getCustomRuleFactory() {
    return RuleFactory.class;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:DefaultGenerationConfig.java

示例7: main

import org.jsonschema2pojo.rules.RuleFactory; //导入依赖的package包/类
public static void main(String[] args) throws IOException {

        // BEGIN EXAMPLE

        JCodeModel codeModel = new JCodeModel();

        URL source = new URL("file:///path/to/my/schema.json");

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

        SchemaMapper mapper = new SchemaMapper(new RuleFactory(config, new Jackson2Annotator(config), new SchemaStore()), new SchemaGenerator());
        mapper.generate(codeModel, "ClassName", "com.example", source);

        codeModel.build(new File("output"));

        // END EXAMPLE

    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:Example.java

示例8: generateReadsSchemaAsObject

import org.jsonschema2pojo.rules.RuleFactory; //导入依赖的package包/类
@Test
public void generateReadsSchemaAsObject() throws IOException {

    final SchemaRule mockSchemaRule = mock(SchemaRule.class);

    final RuleFactory mockRuleFactory = mock(RuleFactory.class);
    when(mockRuleFactory.getSchemaRule()).thenReturn(mockSchemaRule);
    when(mockRuleFactory.getGenerationConfig()).thenReturn(new DefaultGenerationConfig());

    URL schemaContent = this.getClass().getResource("/schema/address.json");

    new SchemaMapper(mockRuleFactory, new SchemaGenerator()).generate(new JCodeModel(), "Address", "com.example.package", schemaContent);

    ArgumentCaptor<JPackage> capturePackage = ArgumentCaptor.forClass(JPackage.class);
    ArgumentCaptor<JsonNode> captureNode = ArgumentCaptor.forClass(JsonNode.class);

    verify(mockSchemaRule).apply(eq("Address"), captureNode.capture(), capturePackage.capture(), Mockito.isA(Schema.class));

    assertThat(capturePackage.getValue().name(), is("com.example.package"));
    assertThat(captureNode.getValue(), is(notNullValue()));

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:SchemaMapperTest.java

示例9: generateCreatesSchemaFromSchemaAsStringInput

import org.jsonschema2pojo.rules.RuleFactory; //导入依赖的package包/类
@Test
public void generateCreatesSchemaFromSchemaAsStringInput() throws IOException {

    String schemaContent = IOUtils.toString(this.getClass().getResourceAsStream("/schema/address.json"));

    final SchemaRule mockSchemaRule = mock(SchemaRule.class);

    final RuleFactory mockRuleFactory = mock(RuleFactory.class);
    when(mockRuleFactory.getSchemaRule()).thenReturn(mockSchemaRule);
    when(mockRuleFactory.getGenerationConfig()).thenReturn(new DefaultGenerationConfig());

    new SchemaMapper(mockRuleFactory, new SchemaGenerator()).generate(new JCodeModel(), "Address", "com.example.package", schemaContent);

    ArgumentCaptor<JPackage> capturePackage = ArgumentCaptor.forClass(JPackage.class);
    ArgumentCaptor<JsonNode> captureNode = ArgumentCaptor.forClass(JsonNode.class);

    verify(mockSchemaRule).apply(eq("Address"), captureNode.capture(), capturePackage.capture(), Mockito.isA(Schema.class));

    assertThat(capturePackage.getValue().name(), is("com.example.package"));
    assertThat(captureNode.getValue(), is(notNullValue()));

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:SchemaMapperTest.java

示例10: getCustomRuleFactory

import org.jsonschema2pojo.rules.RuleFactory; //导入依赖的package包/类
@Override
public Class<? extends RuleFactory> getCustomRuleFactory() {
    return customRuleFactory;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:Jsonschema2PojoTask.java

示例11: getCodegenModel

import org.jsonschema2pojo.rules.RuleFactory; //导入依赖的package包/类
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;
}
 
开发者ID:wu191287278,项目名称:sc-generator,代码行数:59,代码来源:JsonSchemaController.java

示例12: createModel

import org.jsonschema2pojo.rules.RuleFactory; //导入依赖的package包/类
public void createModel(File jsonFile, String modelName) throws IOException {

        //CapFirst for java classes
        modelName = modelName.substring(0, 1).toUpperCase() + modelName.substring(1);
        System.out.println("Model name :"+modelName);
        JCodeModel codeModel = new JCodeModel();
        GenerationConfig config = new DefaultGenerationConfig() {

            @Override
            public boolean isIncludeConstructors() {
                return true;
            }

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

            @Override
            public boolean isUsePrimitives() {
                return true;
            }

            @Override
            public boolean isIncludeToString() {
                return false;
            }

            @Override
            public boolean isIncludeHashcodeAndEquals() {
                return false;
            }

            @Override
            public boolean isIncludeAdditionalProperties() {
                return false;

            }

            @Override
            public Class<? extends RuleFactory> getCustomRuleFactory() {
                return APXCustomRuleFactory.class;
            }

        };

        

        SchemaMapper mapper = new SchemaMapper(new APXCustomRuleFactory(config, new ORMLiteAnotator(), new SchemaStore()), new SchemaGenerator());

        JType m = mapper.generate(codeModel, modelName, PACKAGE_NAME + ".models", jsonFile.toURI().toURL());

         
        File f = new File(PROJECT_SRC);
        codeModel.build(f);
        System.out.print("Model created at :");
        System.out.println(m.fullName().replace('.', File.separatorChar) + ".java");

    }
 
开发者ID:othreecodes,项目名称:APX,代码行数:60,代码来源:Operations.java

示例13: generate

import org.jsonschema2pojo.rules.RuleFactory; //导入依赖的package包/类
/**
 * Generates classes based on json/jsonschema.
 *
 * @return class name
 * @throws IOException
 */
public String generate() throws IOException {
    String schemaPath = this.config.getJsonSchemaPath();
    if (schemas.containsKey(schemaPath)){
        LOG.info("Schema already exists " + schemaPath);
        return schemas.get(schemaPath);
    }

    JCodeModel codeModel = new JCodeModel();
    URL source = new File(config.getInputPath()).toURI().toURL();
    GenerationConfig generationConfig = new DefaultGenerationConfig() {
        @Override
        public boolean isGenerateBuilders() { // set config option by overriding metho
            return true;
        }

        @Override
        public SourceType getSourceType() {
            if (JsonPath.from(source).get("$schema") != null) {
                return SourceType.JSONSCHEMA;
            }
            return SourceType.JSON;
        }

        @Override
        public boolean isUseLongIntegers() {
            return true;
        }

        @Override
        public boolean isUseCommonsLang3() {
            return true;
        }
    };

    SchemaMapper mapper = new SchemaMapper(
            new RuleFactory(generationConfig, new GsonAnnotator(), new SchemaStore()), new SchemaGenerator());
    mapper.generate(codeModel, getClassName(), config.getPackageName(), source);
    codeModel.build(new File(config.getOutputPath()));

    schemas.put(schemaPath, getClassName());
    return getClassName();
}
 
开发者ID:qameta,项目名称:rarc,代码行数:49,代码来源:JsonCodegen.java

示例14: SoeDefaultRule

import org.jsonschema2pojo.rules.RuleFactory; //导入依赖的package包/类
public SoeDefaultRule(RuleFactory ruleFactory) {
    this.ruleFactory = ruleFactory;
}
 
开发者ID:bacta,项目名称:jsonschema2pojo-bacta,代码行数:4,代码来源:SoeDefaultRule.java

示例15: SoeTypeRule

import org.jsonschema2pojo.rules.RuleFactory; //导入依赖的package包/类
protected SoeTypeRule(RuleFactory ruleFactory) {
    this.ruleFactory = ruleFactory;
}
 
开发者ID:bacta,项目名称:jsonschema2pojo-bacta,代码行数:4,代码来源:SoeTypeRule.java


注:本文中的org.jsonschema2pojo.rules.RuleFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。