本文整理汇总了Java中org.jsonschema2pojo.GenerationConfig类的典型用法代码示例。如果您正苦于以下问题:Java GenerationConfig类的具体用法?Java GenerationConfig怎么用?Java GenerationConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GenerationConfig类属于org.jsonschema2pojo包,在下文中一共展示了GenerationConfig类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: unboxIfNecessary
import org.jsonschema2pojo.GenerationConfig; //导入依赖的package包/类
private JType unboxIfNecessary(JType type, GenerationConfig config) {
if (config.isUsePrimitives()) {
return type.unboxify();
} else {
return type;
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:FormatRule.java
示例2: getIntegerType
import org.jsonschema2pojo.GenerationConfig; //导入依赖的package包/类
/**
* Returns the JType for an integer field. Handles type lookup and unboxing.
*/
private JType getIntegerType(JCodeModel owner, JsonNode node, GenerationConfig config) {
if (config.isUseBigIntegers()) {
return unboxIfNecessary(owner.ref(BigInteger.class), config);
} else if (config.isUseLongIntegers() ||
node.has("minimum") && node.get("minimum").isLong() ||
node.has("maximum") && node.get("maximum").isLong()) {
return unboxIfNecessary(owner.ref(Long.class), config);
} else {
return unboxIfNecessary(owner.ref(Integer.class), config);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:TypeRule.java
示例3: getNumberType
import org.jsonschema2pojo.GenerationConfig; //导入依赖的package包/类
/**
* Returns the JType for a number field. Handles type lookup and unboxing.
*/
private JType getNumberType(JCodeModel owner, GenerationConfig config) {
if (config.isUseBigDecimals()) {
return unboxIfNecessary(owner.ref(BigDecimal.class), config);
} else if (config.isUseDoubleNumbers()) {
return unboxIfNecessary(owner.ref(Double.class), config);
} else {
return unboxIfNecessary(owner.ref(Float.class), config);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:TypeRule.java
示例4: setupRuleFactoryToIncludeJsr303
import org.jsonschema2pojo.GenerationConfig; //导入依赖的package包/类
private void setupRuleFactoryToIncludeJsr303() {
GenerationConfig config = mock(GenerationConfig.class);
when(config.getPropertyWordDelimiters()).thenReturn(new char[] { '-', ' ', '_' });
RuleFactory ruleFactory = new RuleFactory();
ruleFactory.setGenerationConfig(config);
rule = new RequiredArrayRule(ruleFactory);
when(config.isIncludeJsr303Annotations()).thenReturn(true);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:RequiredArrayRuleTest.java
示例5: Context
import org.jsonschema2pojo.GenerationConfig; //导入依赖的package包/类
/**
* <p>Constructor for Context.</p>
*
* @param configuration a {@link org.raml.jaxrs.codegen.core.Configuration} object.
* @param raml a {@link org.aml.apimodel.Api} object.
* @throws java.io.IOException if any.
*/
public Context(final Configuration configuration, final Api raml) throws IOException
{
Validate.notNull(configuration, "configuration can't be null");
Validate.notNull(raml, "raml can't be null");
this.configuration = configuration;
writer=new JavaWriter();
codeModel = writer.getModel();
writer.getConfig().setJacksonSupport(true);
writer.getConfig().setJaxbSupport(true);
writer.setDefaultPackageName(configuration.getBasePackageName()+"."+configuration.getModelPackageName());
resourcesMethods = new HashMap<String, Set<String>>();
// prime the HTTP method annotation cache
httpMethodAnnotations = new HashMap<String, Object>();
for (final Class<? extends Annotation> clazz : JAXRS_HTTP_METHODS)
{
httpMethodAnnotations.put(clazz.getSimpleName(), clazz);
}
// configure the JSON -> POJO generator
final GenerationConfig jsonSchemaGenerationConfig = configuration.createJsonSchemaGenerationConfig();
// schemaMapper = new SchemaMapper(new RuleFactory(jsonSchemaGenerationConfig, getAnnotator(jsonSchemaGenerationConfig),
// new SchemaStore()), new SchemaGenerator());
}
开发者ID:OnPositive,项目名称:aml,代码行数:36,代码来源:Context.java
示例6: getAnnotator
import org.jsonschema2pojo.GenerationConfig; //导入依赖的package包/类
/**
*
* @param config
* @return
*/
private static Annotator getAnnotator(GenerationConfig config) {
Annotator coreAnnotator = new AnnotatorFactory().getAnnotator(config.getAnnotationStyle());
if(config.getCustomAnnotator() != null){
Annotator customAnnotator = new AnnotatorFactory().getAnnotator(config.getCustomAnnotator());
return new CompositeAnnotator(coreAnnotator, customAnnotator);
}
return coreAnnotator;
}
开发者ID:OnPositive,项目名称:aml,代码行数:14,代码来源:Context.java
示例7: getIntegerType
import org.jsonschema2pojo.GenerationConfig; //导入依赖的package包/类
private JType getIntegerType(JCodeModel owner, GenerationConfig config) {
if (config.isUseLongIntegers()) {
return owner.ref(Long.class);
} else {
return owner.ref(Integer.class);
}
}
开发者ID:bacta,项目名称:jsonschema2pojo-bacta,代码行数:8,代码来源:SoeTypeRule.java
示例8: getNumberType
import org.jsonschema2pojo.GenerationConfig; //导入依赖的package包/类
private JType getNumberType(JCodeModel owner, GenerationConfig config) {
if (config.isUseDoubleNumbers()) {
return owner.ref(Double.class);
} else {
return owner.ref(Float.class);
}
}
开发者ID:bacta,项目名称:jsonschema2pojo-bacta,代码行数:8,代码来源:SoeTypeRule.java
示例9: generateModelSources
import org.jsonschema2pojo.GenerationConfig; //导入依赖的package包/类
private void generateModelSources(JCodeModel codeModel, ApiBodyMetadata body, File rootDir, GenerationConfig config, Annotator annotator) {
boolean build = false;
if (codeModel == null) {
this.getLog().info("Generating Model object for: " + body.getName());
build = true;
if (config == null && annotator == null) {
codeModel = body.getCodeModel();
} else {
codeModel = body.getCodeModel(resolvedSchemaLocation, basePackage + NamingHelper.getDefaultModelPackage(), config, annotator);
}
}
if (build && codeModel != null) {
buildCodeModelToDisk(codeModel, body.getName(), rootDir);
}
}
开发者ID:phoenixnap,项目名称:springmvc-raml-plugin,代码行数:16,代码来源:SpringMvcEndpointGeneratorMojo.java
示例10: apply
import org.jsonschema2pojo.GenerationConfig; //导入依赖的package包/类
/**
* Applies a JSONSchema2Pojo config to this config
*
* @param generationConfig the config from which values will be pulled
*/
public void apply(GenerationConfig generationConfig) {
this
.withLongIntegers(generationConfig.isUseLongIntegers())
.withCommonsLang3(generationConfig.isUseCommonsLang3())
.withBigDecimals(generationConfig.isUseBigDecimals())
.withBigIntegers(generationConfig.isUseBigIntegers())
.withJSR303Annotations(generationConfig.isIncludeJsr303Annotations())
.withHashcodeEqualsToString((generationConfig.isIncludeHashcodeAndEquals() && generationConfig.isIncludeToString()))
.withGenerateBuilderMethods(generationConfig.isGenerateBuilders());
}
开发者ID:phoenixnap,项目名称:springmvc-raml-plugin,代码行数:16,代码来源:PojoGenerationConfig.java
示例11: canUseJava7
import org.jsonschema2pojo.GenerationConfig; //导入依赖的package包/类
public static boolean canUseJava7(GenerationConfig config) {
return !LESS_THAN_7.contains(config.getTargetVersion());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:LanguageFeatures.java
示例12: canUseJava8
import org.jsonschema2pojo.GenerationConfig; //导入依赖的package包/类
public static boolean canUseJava8(GenerationConfig config) {
return !LESS_THAN_8.contains(config.getTargetVersion());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:LanguageFeatures.java
示例13: NameHelper
import org.jsonschema2pojo.GenerationConfig; //导入依赖的package包/类
public NameHelper(GenerationConfig generationConfig) {
this.generationConfig = generationConfig;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:NameHelper.java
示例14: main
import org.jsonschema2pojo.GenerationConfig; //导入依赖的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
示例15: existingTypeIsUsedWhenTypeIsAlreadyGenerated
import org.jsonschema2pojo.GenerationConfig; //导入依赖的package包/类
@Test
public void existingTypeIsUsedWhenTypeIsAlreadyGenerated() throws URISyntaxException {
JType previouslyGeneratedType = mock(JType.class);
URI schemaUri = getClass().getResource("/schema/address.json").toURI();
SchemaStore schemaStore = new SchemaStore();
Schema schema = schemaStore.create(schemaUri, "#/.");
schema.setJavaType(previouslyGeneratedType);
final GenerationConfig mockGenerationConfig = mock(GenerationConfig.class);
when(mockGenerationConfig.getRefFragmentPathDelimiters()).thenReturn("#/.");
when(mockRuleFactory.getSchemaStore()).thenReturn(schemaStore);
when(mockRuleFactory.getGenerationConfig()).thenReturn(mockGenerationConfig);
ObjectNode schemaNode = new ObjectMapper().createObjectNode();
schemaNode.put("$ref", schemaUri.toString());
JType result = rule.apply(NODE_NAME, schemaNode, null, schema);
assertThat(result, is(sameInstance(previouslyGeneratedType)));
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:SchemaRuleTest.java
示例16: mockConfig
import org.jsonschema2pojo.GenerationConfig; //导入依赖的package包/类
public static GenerationConfig mockConfig(String version) {
GenerationConfig config = mock(GenerationConfig.class);
when(config.getTargetVersion()).thenReturn(version);
return config;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:LanguageFeaturesTest.java
示例17: createModel
import org.jsonschema2pojo.GenerationConfig; //导入依赖的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
示例18: APXCustomRuleFactory
import org.jsonschema2pojo.GenerationConfig; //导入依赖的package包/类
public APXCustomRuleFactory(GenerationConfig generationConfig, Annotator annotator, SchemaStore schemaStore) {
super(generationConfig, annotator, schemaStore);
}
开发者ID:othreecodes,项目名称:APX,代码行数:4,代码来源:APXCustomRuleFactory.java
示例19: generate
import org.jsonschema2pojo.GenerationConfig; //导入依赖的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
示例20: getGenerationConfig
import org.jsonschema2pojo.GenerationConfig; //导入依赖的package包/类
/**
* 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();
}
}
};
}
开发者ID:phoenixnap,项目名称:springmvc-raml-plugin,代码行数:63,代码来源:SchemaHelper.java
注:本文中的org.jsonschema2pojo.GenerationConfig类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论