Java 类org.jsonschema2pojo.SourceType 实例源码

项目:GitHub    文件:Jsonschema2PojoMojo.java   
@Override
public SourceType getSourceType() {
    return SourceType.valueOf(sourceType.toUpperCase());
}
项目:GitHub    文件:Jsonschema2PojoTask.java   
@Override
public SourceType getSourceType() {
    return sourceType;
}
项目:GitHub    文件:Arguments.java   
@Override
public SourceType getSourceType() {
    return sourceType;
}
项目:rarc    文件:JsonCodegen.java   
/**
 * 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();
}
项目:data-mapper    文件:JsonGenerationConfig.java   
@Override
public SourceType getSourceType() {
    return sourceType;
}
项目:data-mapper    文件:JsonGenerationConfig.java   
public JsonGenerationConfig setSourceType(SourceType sourceType) {
    this.sourceType = sourceType;
    return this;
}
项目:data-mapper    文件:JsonModelGenerator.java   
/**
 * Generates Java classes in targetPath directory given a JSON instance
 * document.
 * 
 * @param className name of the top-level class used for the generated model
 * @param packageName package name for generated model classes
 * @param instanceUrl url for the JSON message containing instance data
 * @param targetPath directory where class source will be generated
 * @throws Exception failure during model generation
 */
public JCodeModel generateFromInstance(final String className, final String packageName,
        final URL instanceUrl, final File targetPath) throws Exception {

    config.setSourceType(SourceType.JSON);
    return generate(className, packageName, instanceUrl, targetPath);
}
项目:GitHub    文件:Jsonschema2PojoTask.java   
/**
 * Sets the 'sourceType' property of this class
 *
 * @param sourceType
 *            The type of input documents that will be read
 *            <p>
 *            Supported values:
 *            <ul>
 *            <li><code>jsonschema</code></li>
 *            <li><code>json</code></li>
 *            <li><code>yamlschema</code></li>
 *            <li><code>yaml</code></li>
 *            </ul>
 */
public void setSourceType(SourceType sourceType) {
    this.sourceType = sourceType;
}