Package org.apache.johnzon.maven.plugin
Class ExampleToModelMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.johnzon.maven.plugin.ExampleToModelMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@Mojo(name="example-to-model", defaultPhase=GENERATE_SOURCES) public class ExampleToModelMojo extends org.apache.maven.plugin.AbstractMojo
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static interface
ExampleToModelMojo.Visitor
-
Field Summary
Fields Modifier and Type Field Description protected boolean
attach
private static List<Character>
FORBIDDEN_JAVA_NAMES
protected String
header
protected boolean
ignoreNull
protected String
packageBase
protected org.apache.maven.project.MavenProject
project
protected File
source
protected File
target
protected boolean
useJsonb
protected boolean
useRecord
-
Constructor Summary
Constructors Constructor Description ExampleToModelMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private String
buildArrayType(int arrayLevel, String type)
private String
buildValidFieldName(String jsonField)
private String
capitalize(String str)
void
execute()
private void
fieldGetSetMethods(Writer writer, String jsonField, String field, String type, String prefix, int arrayLevel, Collection<String> imports, boolean last)
private void
generate(jakarta.json.JsonReaderFactory readerFactory, File source, Writer writer, String javaName)
private void
generateFieldsAndMethods(StringWriter writer, jakarta.json.JsonObject object, String prefix, Collection<String> imports)
private void
generateFile(jakarta.json.JsonReaderFactory readerFactory, File source)
private void
handleArray(Writer writer, String prefix, Map<String,jakarta.json.JsonObject> nestedTypes, jakarta.json.JsonValue value, String jsonField, String fieldName, int arrayLevel, Collection<String> imports, boolean last)
private String
toJavaFieldName(String key)
private String
toJavaName(String file)
private void
visit(jakarta.json.JsonStructure structure, ExampleToModelMojo.Visitor visitor)
-
-
-
Field Detail
-
source
@Parameter(property="johnzon.source", defaultValue="${project.basedir}/src/main/johnzon") protected File source
-
target
@Parameter(property="johnzon.target", defaultValue="${project.build.directory}/generated-sources/johnzon") protected File target
-
packageBase
@Parameter(property="johnzon.package", defaultValue="com.johnzon.generated") protected String packageBase
-
header
@Parameter protected String header
-
project
@Parameter(defaultValue="${project}", readonly=true) protected org.apache.maven.project.MavenProject project
-
attach
@Parameter(property="johnzon.attach", defaultValue="true") protected boolean attach
-
useRecord
@Parameter(property="johnzon.useRecord", defaultValue="false") protected boolean useRecord
-
useJsonb
@Parameter(property="johnzon.useJsonb", defaultValue="false") protected boolean useJsonb
-
ignoreNull
@Parameter(property="johnzon.ignoreNull", defaultValue="false") protected boolean ignoreNull
-
-
Method Detail
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
generate
private void generate(jakarta.json.JsonReaderFactory readerFactory, File source, Writer writer, String javaName) throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
generateFieldsAndMethods
private void generateFieldsAndMethods(StringWriter writer, jakarta.json.JsonObject object, String prefix, Collection<String> imports) throws IOException
- Throws:
IOException
-
handleArray
private void handleArray(Writer writer, String prefix, Map<String,jakarta.json.JsonObject> nestedTypes, jakarta.json.JsonValue value, String jsonField, String fieldName, int arrayLevel, Collection<String> imports, boolean last) throws IOException
- Throws:
IOException
-
fieldGetSetMethods
private void fieldGetSetMethods(Writer writer, String jsonField, String field, String type, String prefix, int arrayLevel, Collection<String> imports, boolean last) throws IOException
- Throws:
IOException
-
visit
private void visit(jakarta.json.JsonStructure structure, ExampleToModelMojo.Visitor visitor)
-
generateFile
private void generateFile(jakarta.json.JsonReaderFactory readerFactory, File source) throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
-