下面列出了怎么用org.jsonschema2pojo.Annotator的API类实例代码及写法,或者点击链接到github查看源代码。
private void generateModelSources(JCodeModel codeModel, ApiBodyMetadata body, File rootDir) {
boolean build = false;
if (codeModel == null) {
Annotator annotator = this.useJackson1xCompatibility ? new Jackson1Annotator(this.generationConfig) : null;
this.getLog().info("Generating Model object for: " + body.getName());
build = true;
if (this.generationConfig == null && annotator == null) {
codeModel = body.getCodeModel();
} else {
codeModel = body.getCodeModel(resolvedSchemaLocation, basePackage + NamingHelper.getDefaultModelPackage(), annotator);
}
}
if (build && codeModel != null) {
buildCodeModelToDisk(codeModel, body.getName(), rootDir);
}
}
/**
* Constructor.
*/
public JaxRsRuleFactory(GenerationConfig generationConfig, Annotator annotator, SchemaStore schemaStore) {
super(generationConfig, annotator, schemaStore);
}
@Override
public Class<? extends Annotator> getCustomAnnotator() {
return JuneauPojoAnnotator.class;
}
/**
* Builds a JCodeModel for this body
*
* @param basePackage
* The package we will be using for the domain objects
* @param schemaLocation
* The location of this schema, will be used to create absolute
* URIs for $ref tags eg "classpath:/"
* @param annotator
* JsonSchema2Pojo annotator. if null a default annotator will be
* used
* @return built JCodeModel
*/
public JCodeModel getCodeModel(String basePackage, String schemaLocation, Annotator annotator) {
if (type != null) {
return codeModel;
} else {
return SchemaHelper.buildBodyJCodeModel(schemaLocation, basePackage, name, schema, annotator);
}
}