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

Taking control of code generation

Sam Bosley edited this page Sep 17, 2015 · 9 revisions

SquiDB provides various options and APIs to give you a greater degree of control over the code generation process. There are compile-time flags you can set in your build.gradle to disable some default behaviors, or you can write plugins to generate additional code for an even greater degree of control.

Compile-time options

SquiDB supports the following options to alter the default code generation behavior:

  • disableDefaultConstructors: this option disables the four default constructors generated in each model class
  • disableImplements: this option disables processing of the @Implements annotation
  • disableModelMethod: this option disables processing of the @ModelMethod implementation, as well as the copying of instance and static methods from the model spec to the generated model class
  • disableConstantCopying: this option disables the copying of unhandled public static final fields from the model spec to the generated model as constants
  • disableDefaultContentValues: this option disables the in-memory default content values used as for fallback values in empty models
  • disableGettersAndSetters: this option disables the default getters and setters that are generated for each column in the model

Most users will not need to use these options unless they are specifically concerned with keeping their method count down or if they want to reimplement similar functionality using their own plugins.

Writing code generation plugins

Users can also write plugins that add to the code generation process. Plugins are implemented as small jar files containing a subclass of Plugin, and can add code before, during, or after any of the several phases that code generation goes through. Plugins are also given an opportunity to handle fields declared in model specs if they want to define custom logic for property generation.