Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Plugins

Shaun Francis edited this page Sep 15, 2017 · 7 revisions

Introduction

Plugins provide a means to change the Java Classes that are generated. There are three different types of plugin that can be added to the generator: ClassModifyingPlugin, TypeModifyPlugin and NameGeneratablePlugin. Each type works on a different stage of the generation process.

ClassModifyingPlugin

This works by applying changes to the Java Poet TypeSpec.Builder, before generation is completed. Two default plugins are setup: AddFieldsAndMethodsToClassPlugin, GenerateBuilderForClassPlugin.

TypeModifyingPlugin

Each field of a schema is represented by a Definition, and each type of Definition needs to converted into a Java Poet TypeName. The TypeModifyingPlugin receives the default or already modified TypeName, which can then be modified or a completely different TypeName can be returned.

NameGeneratablePlugin

There can only be one NameGeneratablePlugin present, it will decide the field name for the root schema, which will ultimately be used to generate the Class name of the root. There is a default plugin provided that uses the file name to construct the field name for the root. By adding a user defined plugin to the plugins list, this default plugin will be overridden.

Usage

Clone this wiki locally