• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RuleFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: generateCreatesSchemaFromExampleJsonWhenInJsonMode

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

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

    ObjectNode schemaNode = JsonNodeFactory.instance.objectNode();

    final SchemaRule mockSchemaRule = mock(SchemaRule.class);

    final GenerationConfig mockGenerationConfig = mock(GenerationConfig.class);
    when(mockGenerationConfig.getSourceType()).thenReturn(SourceType.JSON);

    final SchemaGenerator mockSchemaGenerator = mock(SchemaGenerator.class);
    when(mockSchemaGenerator.schemaFromExample(schemaContent)).thenReturn(schemaNode);

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

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

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

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

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

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


示例17: generateCreatesSchemaFromExampleJSONAsStringInput

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

    String jsonContent = IOUtils.toString(this.getClass().getResourceAsStream("/example-json/user.json"));

    ObjectNode schemaNode = JsonNodeFactory.instance.objectNode();

    final SchemaRule mockSchemaRule = mock(SchemaRule.class);

    final GenerationConfig mockGenerationConfig = mock(GenerationConfig.class);
    when(mockGenerationConfig.getSourceType()).thenReturn(SourceType.JSON);

    final SchemaGenerator mockSchemaGenerator = mock(SchemaGenerator.class);
    when(mockSchemaGenerator.schemaFromExample(new ObjectMapper().readTree(jsonContent))).thenReturn(schemaNode);

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

    new SchemaMapper(mockRuleFactory, mockSchemaGenerator).generate(new JCodeModel(), "User", "com.example.package", jsonContent);

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

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

    assertThat(capturePackage.getValue().name(), is("com.example.package"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:SchemaMapperTest.java


示例18: getCustomRuleFactory

import org.jsonschema2pojo.rules.RuleFactory; //导入依赖的package包/类
/**
 * Gets the 'customRuleFactory' configuration option.
 *
 * @return An Rule Factory that will be used for the creation of generation
 *         rules.
 */
Class<? extends RuleFactory> getCustomRuleFactory();
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:GenerationConfig.java


示例19: SchemaMapper

import org.jsonschema2pojo.rules.RuleFactory; //导入依赖的package包/类
/**
 * Create a schema mapper with the given {@link RuleFactory}.
 *
 * @param ruleFactory
 *            A factory used by this mapper to create Java type generation
 *            rules.
 * @param schemaGenerator
 *            the generator that this mapper will use if the config dictates
 *            that the input documents are plain json (not json schema)
 */
public SchemaMapper(RuleFactory ruleFactory, SchemaGenerator schemaGenerator) {
    this.ruleFactory = ruleFactory;
    this.schemaGenerator = schemaGenerator;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:SchemaMapper.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OAuth2Parameters类代码示例发布时间:2022-05-22
下一篇:
Java CaseResult类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap