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 interfaceExampleToModelMojo.Visitor
-
Field Summary
Fields Modifier and Type Field Description protected booleanattachprivate static List<Character>FORBIDDEN_JAVA_NAMESprotected Stringheaderprotected booleanignoreNullprotected StringpackageBaseprotected org.apache.maven.project.MavenProjectprojectprotected Filesourceprotected Filetargetprotected booleanuseJsonbprotected booleanuseRecord
-
Constructor Summary
Constructors Constructor Description ExampleToModelMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private StringbuildArrayType(int arrayLevel, String type)private StringbuildValidFieldName(String jsonField)private Stringcapitalize(String str)voidexecute()private voidfieldGetSetMethods(Writer writer, String jsonField, String field, String type, String prefix, int arrayLevel, Collection<String> imports, boolean last)private voidgenerate(jakarta.json.JsonReaderFactory readerFactory, File source, Writer writer, String javaName)private voidgenerateFieldsAndMethods(StringWriter writer, jakarta.json.JsonObject object, String prefix, Collection<String> imports)private voidgenerateFile(jakarta.json.JsonReaderFactory readerFactory, File source)private voidhandleArray(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 StringtoJavaFieldName(String key)private StringtoJavaName(String file)private voidvisit(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
-
-