Repository: joelittlejohn/jsonschema2pojo
Pull request #759 (2017-07-18 16:47:35)

Getters and Setters can now be activated independently
Made it possible for getters and setters to be activated independently. I am not sure that I did the dynamic setters/getters correctly, so any feedback will be appreciated. I would also like feedback on the testing.

joelittlejohn: Thanks for submitting this PR @lstav. It looks like you have been very thorough.

One issue here is that you have removed the existing config option, and I can see why - it's not easy to make these play nicely together, particularly considering the default values. We may only be able to include this in a 1.0 release.

I wonder if we can find a way to include this but keep the `includeAccessors` option. We can even deprecate it. 

So, add getters when:

```java
isIncludeAccessors() || isIncludeGetters()
```

And add setters when:

```java
isIncludeAccessors() || isIncludeGetters()
```

This way we maintain the old behaviour but can support your new features too.
lstav: @joelittlejohn Sounds good, I'll add those and update the PR.
lstav: @joelittlejohn Just added the accessor methods again, let me know if this is what you were expecting. Also, I wasn't sure if I should put @Deprecated on the accessor methods, or if we would just add them later.
joelittlejohn: I think includeGetters and includeSetters should be default `false`. This way, users who are currently using includeAccessors=`false` will not have getters/setters appear in their code after this change.
lstav: I agree, that's a good idea, I just pushed the changes.

Patch:
diff --git a/jsonschema2pojo-ant/src/main/java/org/jsonschema2pojo/ant/Jsonschema2PojoTask.java b/jsonschema2pojo-ant/src/main/java/org/jsonschema2pojo/ant/Jsonschema2PojoTask.java
index d90b6e20..ed23a8c7 100644
--- a/jsonschema2pojo-ant/src/main/java/org/jsonschema2pojo/ant/Jsonschema2PojoTask.java
+++ b/jsonschema2pojo-ant/src/main/java/org/jsonschema2pojo/ant/Jsonschema2PojoTask.java
@@ -137,10 +137,20 @@ public class Jsonschema2PojoTask extends Task implements GenerationConfig {
 
     private boolean includeAccessors = true;
 
+    private boolean includeGetters = false;
+
+    private boolean includeSetters = false;
+
     private String targetVersion = "1.6";
 
     private boolean includeDynamicAccessors = false;
 
+    private boolean includeDynamicGetters = false;
+
+    private boolean includeDynamicSetters = false;
+
+    private boolean includeDynamicBuilders = false;
+
     private String dateTimeType;
 
     private String timeType;
@@ -678,6 +688,28 @@ public class Jsonschema2PojoTask extends Task implements GenerationConfig {
         this.includeAccessors = includeAccessors;
     }
 
+    /**
+     * Sets the 'includeGetters' property of this class
+     *
+     * @param includeGetters
+     *            Whether to include getters or to omit these accessor
+     *            methods and create public fields instead.
+     */
+    public void setIncludeGetters(boolean includeGetters) {
+        this.includeGetters = includeGetters;
+    }
+
+    /**
+     * Sets the 'includeSetters' property of this class
+     *
+     * @param includeSetters
+     *            Whether to include setters or to omit these accessor
+     *            methods and create public fields instead.
+     */
+    public void setIncludeSetters(boolean includeSetters) {
+        this.includeSetters = includeSetters;
+    }
+
     /**
      * Sets the 'targetVersion' property of this class
      *
@@ -700,6 +732,36 @@ public class Jsonschema2PojoTask extends Task implements GenerationConfig {
         this.includeDynamicAccessors = includeDynamicAccessors;
     }
 
+    /**
+     * Sets the 'includeDynamicGetters' property of this class
+     *
+     * @param includeDynamicGetters
+     *            Whether to include dynamic getters or to omit these methods.
+     */
+    public void setIncludeDynamicGetters(boolean includeDynamicGetters) {
+        this.includeDynamicGetters = includeDynamicGetters;
+    }
+
+    /**
+     * Sets the 'includeDynamicSetters' property of this class
+     *
+     * @param includeDynamicSetters
+     *            Whether to include dynamic setters or to omit these methods.
+     */
+    public void setIncludeDynamicSetters(boolean includeDynamicSetters) {
+        this.includeDynamicSetters = includeDynamicSetters;
+    }
+
+    /**
+     * Sets the 'includeDynamicBuilders' property of this class
+     *
+     * @param includeDynamicBuilders
+     *            Whether to include dynamic builders or to omit these methods.
+     */
+    public void setIncludeDynamicBuilders(boolean includeDynamicBuilders) {
+        this.includeDynamicBuilders = includeDynamicBuilders;
+    }
+
     /**
      * Sets the 'formatDateTimes' property of this class
      *
@@ -998,6 +1060,16 @@ public class Jsonschema2PojoTask extends Task implements GenerationConfig {
         return includeAccessors;
     }
 
+    @Override
+    public boolean isIncludeGetters() {
+        return includeGetters;
+    }
+
+    @Override
+    public boolean isIncludeSetters() {
+        return includeSetters;
+    }
+
     @Override
     public String getTargetVersion() {
         return targetVersion;
@@ -1008,6 +1080,21 @@ public class Jsonschema2PojoTask extends Task implements GenerationConfig {
         return includeDynamicAccessors;
     }
 
+    @Override
+    public boolean isIncludeDynamicGetters() {
+        return includeDynamicGetters;
+    }
+
+    @Override
+    public boolean isIncludeDynamicSetters() {
+        return includeDynamicSetters;
+    }
+
+    @Override
+    public boolean isIncludeDynamicBuilders() {
+        return includeDynamicBuilders;
+    }
+
     @Override
     public String getDateTimeType() {
         return dateTimeType;
diff --git a/jsonschema2pojo-ant/src/site/Jsonschema2PojoTask.html b/jsonschema2pojo-ant/src/site/Jsonschema2PojoTask.html
index 1ec6833b..b5140ed7 100644
--- a/jsonschema2pojo-ant/src/site/Jsonschema2PojoTask.html
+++ b/jsonschema2pojo-ant/src/site/Jsonschema2PojoTask.html
@@ -158,6 +158,16 @@
         </td>
         <td align="center" valign="top">No (default <code>true</code>)</td>
     </tr>
+    <tr>
+        <td valign="top">includeGetters</td>
+        <td valign="top">Whether to include getters or to omit these accessor methods and create public fields instead.</td>
+        <td align="center" valign="top">No (default <code>false</code>)</td>
+    </tr>
+    <tr>
+        <td valign="top">includeSetters</td>
+        <td valign="top">Whether to include setters or to omit these accessor methods and create public fields instead.</td>
+        <td align="center" valign="top">No (default <code>false</code>)</td>
+    </tr>
     <tr>
         <td valign="top">includeAdditionalProperties</td>
         <td valign="top">Whether to allow 'additional properties' support in objects. Setting this to false will disable
@@ -170,6 +180,21 @@
         <td valign="top">Whether to include dynamic getters, setters, and builders or to omit these methods.</td>
         <td align="center" valign="top">No (default <code>false</code>)</td>
     </tr>
+    <tr>
+        <td valign="top">includeDynamicGetters</td>
+        <td valign="top">Whether to include dynamic getters or to omit these methods.</td>
+        <td align="center" valign="top">No (default <code>false</code>)</td>
+    </tr>
+    <tr>
+        <td valign="top">includeDynamicSetters</td>
+        <td valign="top">Whether to include dynamic setters or to omit these methods.</td>
+        <td align="center" valign="top">No (default <code>false</code>)</td>
+    </tr>
+    <tr>
+        <td valign="top">includeDynamicBuilders</td>
+        <td valign="top">Whether to include dynamic builders or to omit these methods.</td>
+        <td align="center" valign="top">No (default <code>false</code>)</td>
+    </tr>
     <tr>
         <td valign="top">includeConstructors</td>
         <td valign="top">Whether to generate constructors for generated Java types</td>
diff --git a/jsonschema2pojo-cli/src/main/java/org/jsonschema2pojo/cli/Arguments.java b/jsonschema2pojo-cli/src/main/java/org/jsonschema2pojo/cli/Arguments.java
index f8605956..a4e6d3f3 100644
--- a/jsonschema2pojo-cli/src/main/java/org/jsonschema2pojo/cli/Arguments.java
+++ b/jsonschema2pojo-cli/src/main/java/org/jsonschema2pojo/cli/Arguments.java
@@ -164,12 +164,27 @@ public class Arguments implements GenerationConfig {
     @Parameter(names = { "-da", "--disable-accessors" }, description = "Whether to omit getter/setter methods and create public fields instead.")
     private boolean disableAccessors = false;
 
+    @Parameter(names = { "-dg", "--disable-getters" }, description = "Whether to omit getter methods and create public fields instead.")
+    private boolean disableGetters = false;
+
+    @Parameter(names = { "-ds", "--disable-setters" }, description = "Whether to omit setter methods and create public fields instead.")
+    private boolean disableSetters = false;
+
     @Parameter(names = { "-tv", "--target-version" }, description = "The target version for generated source files.")
     private String targetVersion = "1.6";
 
     @Parameter(names = { "-ida", "--include-dynamic-accessors" }, description = "Include dynamic getter, setter, and builder support on generated types.")
     private boolean includeDynamicAccessors = false;
 
+    @Parameter(names = { "-idg", "--include-dynamic-getters" }, description = "Include dynamic getter support on generated types.")
+    private boolean includeDynamicGetters = false;
+
+    @Parameter(names = { "-ids", "--include-dynamic-setters" }, description = "Include dynamic setter support on generated types.")
+    private boolean includeDynamicSetters = false;
+
+    @Parameter(names = { "-idb", "--include-dynamic-builders" }, description = "Include dynamic builder support on generated types.")
+    private boolean includeDynamicBuilders = false;
+
     @Parameter(names = { "-fd", "--format-dates" }, description = "Whether the fields of type `date` are formatted during serialization with a default pattern of `yyyy-MM-dd`")
     private boolean formatDates = false;
 
@@ -409,6 +424,16 @@ public class Arguments implements GenerationConfig {
         return !disableAccessors;
     }
 
+    @Override
+    public boolean isIncludeGetters() {
+        return !disableGetters;
+    }
+
+    @Override
+    public boolean isIncludeSetters() {
+        return !disableSetters;
+    }
+
     @Override
     public String getTargetVersion() {
         return targetVersion;
@@ -419,6 +444,21 @@ public class Arguments implements GenerationConfig {
         return includeDynamicAccessors;
     }
 
+    @Override
+    public boolean isIncludeDynamicGetters() {
+        return includeDynamicGetters;
+    }
+
+    @Override
+    public boolean isIncludeDynamicSetters() {
+        return includeDynamicSetters;
+    }
+
+    @Override
+    public boolean isIncludeDynamicBuilders() {
+        return includeDynamicBuilders;
+    }
+
     @Override
     public String getDateTimeType() {
         return dateTimeType;
diff --git a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/DefaultGenerationConfig.java b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/DefaultGenerationConfig.java
index fa8458f5..a9300ad9 100644
--- a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/DefaultGenerationConfig.java
+++ b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/DefaultGenerationConfig.java
@@ -301,11 +301,26 @@ public class DefaultGenerationConfig implements GenerationConfig {
     /**
      * @return <code>true</code>
      */
-    @Override
     public boolean isIncludeAccessors() {
         return true;
     }
 
+    /**
+     * @return <code>true</code>
+     */
+    @Override
+    public boolean isIncludeGetters() {
+        return false;
+    }
+
+    /**
+     * @return <code>true</code>
+     */
+    @Override
+    public boolean isIncludeSetters() {
+        return false;
+    }
+
     /**
      * @return <code>1.6</code>
      */
@@ -322,6 +337,30 @@ public class DefaultGenerationConfig implements GenerationConfig {
         return false;
     }
 
+    /**
+     * @return <code>false</code>
+     */
+    @Override
+    public boolean isIncludeDynamicGetters() {
+        return false;
+    }
+
+    /**
+     * @return <code>false</code>
+     */
+    @Override
+    public boolean isIncludeDynamicSetters() {
+        return false;
+    }
+
+    /**
+     * @return <code>false</code>
+     */
+    @Override
+    public boolean isIncludeDynamicBuilders() {
+        return false;
+    }
+
     @Override
     public String getDateTimeType() {
         return null;
diff --git a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/GenerationConfig.java b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/GenerationConfig.java
index e60faed0..19cc422d 100644
--- a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/GenerationConfig.java
+++ b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/GenerationConfig.java
@@ -378,6 +378,22 @@ public interface GenerationConfig {
      */
     boolean isIncludeAccessors();
 
+    /**
+     * Gets the 'includeGetters' configuration option.
+     *
+     * @return Whether to include getters or to omit these accessor
+     *         methods and create public fields instead.
+     */
+    boolean isIncludeGetters();
+
+    /**
+     * Gets the 'includeSetters' configuration option.
+     *
+     * @return Whether to include setters or to omit these accessor
+     *         methods and create public fields instead.
+     */
+    boolean isIncludeSetters();
+
     /**
      * Gets the 'targetVersion' configuration option.
      *
@@ -386,13 +402,34 @@ public interface GenerationConfig {
     String getTargetVersion();
 
     /**
-     * Gets the `includeDynamicAccessors` configuraiton option.
+     * Gets the `includeDynamicAccessors` configuration option
      *
      * @return Whether to include dynamic getters, setters, and builders or to
      *         omit these methods.
      */
     boolean isIncludeDynamicAccessors();
 
+    /**
+     * Gets the `includeDynamicGetters` configuration option.
+     *
+     * @return Whether to include dynamic getters or to omit these methods
+     */
+    boolean isIncludeDynamicGetters();
+
+    /**
+     * Gets the `includeDynamicSetters` configuration option.
+     *
+     * @return Whether to include dynamic setters or to omit these methods
+     */
+    boolean isIncludeDynamicSetters();
+
+    /**
+     * Gets the `includeDynamicBuilders` configuration option.
+     *
+     * @return Whether to include dynamic builders or to omit these methods
+     */
+    boolean isIncludeDynamicBuilders();
+
     /**
      * Gets the `dateTimeType` configuration option.
      * <p>
diff --git a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/DynamicPropertiesRule.java b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/DynamicPropertiesRule.java
index 2ff4bf62..4a953896 100644
--- a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/DynamicPropertiesRule.java
+++ b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/DynamicPropertiesRule.java
@@ -91,27 +91,44 @@ public class DynamicPropertiesRule implements Rule<JDefinedClass, JDefinedClass>
      */
     @Override
     public JDefinedClass apply(String nodeName, JsonNode node, JDefinedClass jclass, Schema currentSchema) {
-        if (!ruleFactory.getGenerationConfig().isIncludeDynamicAccessors()) {
+        if (!ruleFactory.getGenerationConfig().isIncludeDynamicAccessors() ||
+                (!ruleFactory.getGenerationConfig().isIncludeDynamicSetters() &&
+                !ruleFactory.getGenerationConfig().isIncludeDynamicGetters() &&
+                !ruleFactory.getGenerationConfig().isIncludeDynamicBuilders())) {
             return jclass;
         }
+        boolean isIncludeAccessors = ruleFactory.getGenerationConfig().isIncludeAccessors();
+        boolean isIncludeGetters = ruleFactory.getGenerationConfig().isIncludeGetters();
+        boolean isIncludeSetters = ruleFactory.getGenerationConfig().isIncludeSetters();
+        boolean isGenerateBuilders = ruleFactory.getGenerationConfig().isGenerateBuilders();
 
-        if (ruleFactory.getGenerationConfig().isIncludeAccessors() ||
-                ruleFactory.getGenerationConfig().isGenerateBuilders()) {
+        if (isIncludeAccessors || isIncludeGetters || isIncludeSetters || isGenerateBuilders) {
             if (LanguageFeatures.canUseJava7(ruleFactory.getGenerationConfig())) {
-                addInternalSetMethodJava7(jclass, node);
-                addInternalGetMethodJava7(jclass, node);
+                if (isIncludeAccessors || isIncludeSetters) {
+                    addInternalSetMethodJava7(jclass, node);
+                }
+                if (isIncludeAccessors || isIncludeGetters) {
+                    addInternalGetMethodJava7(jclass, node);
+                }
             } else {
-                addInternalSetMethodJava6(jclass, node);
-                addInternalGetMethodJava6(jclass, node);
+                if (isIncludeAccessors || isIncludeSetters) {
+                    addInternalSetMethodJava6(jclass, node);
+                }
+                if (isIncludeAccessors || isIncludeGetters) {
+                    addInternalGetMethodJava6(jclass, node);
+                }
             }
         }
 
-        if (ruleFactory.getGenerationConfig().isIncludeAccessors()) {
+        if (isIncludeAccessors || isIncludeGetters) {
             addGetMethods(jclass);
+        }
+
+        if (isIncludeAccessors || isIncludeSetters) {
             addSetMethods(jclass);
         }
 
-        if (ruleFactory.getGenerationConfig().isGenerateBuilders()) {
+        if (isGenerateBuilders) {
             addWithMethods(jclass);
         }
 
diff --git a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/PropertyRule.java b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/PropertyRule.java
index e93446e5..67a9ee7c 100644
--- a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/PropertyRule.java
+++ b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/PropertyRule.java
@@ -74,9 +74,13 @@ public class PropertyRule implements Rule<JDefinedClass, JDefinedClass> {
 
         JType propertyType = ruleFactory.getSchemaRule().apply(nodeName, node, jclass, schema);
 
+        boolean isIncludeAccessors = ruleFactory.getGenerationConfig().isIncludeAccessors();
+        boolean isIncludeGetters = ruleFactory.getGenerationConfig().isIncludeGetters();
+        boolean isIncludeSetters = ruleFactory.getGenerationConfig().isIncludeSetters();
+
         node = resolveRefs(node, schema);
 
-        int accessModifier = ruleFactory.getGenerationConfig().isIncludeAccessors() ? JMod.PRIVATE : JMod.PUBLIC;
+        int accessModifier = isIncludeAccessors || isIncludeGetters || isIncludeSetters ? JMod.PRIVATE : JMod.PUBLIC;
         JFieldVar field = jclass.field(accessModifier, propertyType, propertyName);
 
         propertyAnnotations(nodeName, node, schema, field);
@@ -85,11 +89,13 @@ public class PropertyRule implements Rule<JDefinedClass, JDefinedClass> {
 
         ruleFactory.getAnnotator().propertyField(field, jclass, nodeName, node);
 
-        if (ruleFactory.getGenerationConfig().isIncludeAccessors()) {
+        if (isIncludeAccessors || isIncludeGetters) {
             JMethod getter = addGetter(jclass, field, nodeName, node);
             ruleFactory.getAnnotator().propertyGetter(getter, nodeName);
             propertyAnnotations(nodeName, node, schema, getter);
+        }
 
+        if (isIncludeAccessors || isIncludeSetters) {
             JMethod setter = addSetter(jclass, field, nodeName, node);
             ruleFactory.getAnnotator().propertySetter(setter, nodeName);
             propertyAnnotations(nodeName, node, schema, setter);
diff --git a/jsonschema2pojo-gradle-plugin/README.md b/jsonschema2pojo-gradle-plugin/README.md
index fc7f7ce8..5a3f5074 100644
--- a/jsonschema2pojo-gradle-plugin/README.md
+++ b/jsonschema2pojo-gradle-plugin/README.md
@@ -172,9 +172,24 @@ jsonSchema2Pojo {
   // Whether to include getters/setters or to omit these accessor methods and create public fields instead.
   includeAccessors = true
 
+  // Whether to include getters or to omit these accessor methods and create public fields instead.
+  includeGetters = false
+
+  // Whether to include setters or to omit these accessor methods and create public fields instead.
+  includeSetters = false
+
   // Whether to include dynamic getters, setters, and builders or to omit these methods.
   includeDynamicAccessors = false
 
+  // Whether to include dynamic getters or to omit these methods.
+  includeDynamicGetters = false
+
+  // Whether to include dynamic setters or to omit these methods.
+  includeDynamicSetters = false
+
+  // Whether to include dynamic builders or to omit these methods.
+  includeDynamicBuilders = false
+
   // What type to use instead of string when adding string properties of format "date" to Java types
   dateType = "java.time.LocalDate"
 
diff --git a/jsonschema2pojo-gradle-plugin/src/main/groovy/org/jsonschema2pojo/gradle/JsonSchemaExtension.groovy b/jsonschema2pojo-gradle-plugin/src/main/groovy/org/jsonschema2pojo/gradle/JsonSchemaExtension.groovy
index 362f9fdb..d8ada974 100644
--- a/jsonschema2pojo-gradle-plugin/src/main/groovy/org/jsonschema2pojo/gradle/JsonSchemaExtension.groovy
+++ b/jsonschema2pojo-gradle-plugin/src/main/groovy/org/jsonschema2pojo/gradle/JsonSchemaExtension.groovy
@@ -44,8 +44,13 @@ public class JsonSchemaExtension implements GenerationConfig {
   Class<? extends RuleFactory> customRuleFactory
   boolean generateBuilders
   boolean includeAccessors
+  boolean includeGetters
+  boolean includeSetters
   boolean includeAdditionalProperties
   boolean includeDynamicAccessors
+  boolean includeDynamicGetters
+  boolean includeDynamicSetters
+  boolean includeDynamicBuilders
   boolean includeConstructors
   boolean constructorsRequiredPropertiesOnly
   boolean includeHashcodeAndEquals
@@ -123,8 +128,13 @@ public class JsonSchemaExtension implements GenerationConfig {
     fileExtensions = [] as String[]
     includeAdditionalProperties = true
     includeAccessors = true
+    includeGetters = false
+    includeSetters = false
     targetVersion = '1.6'
     includeDynamicAccessors = false
+    includeDynamicGetters = false
+    includeDynamicSetters = false
+    includeDynamicBuilders = false
     formatDates = false
     formatTimes = false
     formatDateTimes = false
@@ -217,8 +227,13 @@ public class JsonSchemaExtension implements GenerationConfig {
        |classNameSuffix = ${classNameSuffix}
        |fileExtensions = ${Arrays.toString(fileExtensions)}
        |includeAccessors = ${includeAccessors}
+       |includeGetters = ${includeGetters}
+       |includeSetters = ${includeSetters}
        |targetVersion = ${targetVersion}
        |includeDynamicAccessors = ${includeDynamicAccessors}
+       |includeDynamicGetters = ${includeDynamicGetters}
+       |includeDynamicSetters = ${includeDynamicSetters}
+       |includeDynamicBuilders = ${includeDynamicBuilders}
        |formatDates = ${formatDates}
        |formatTimes = ${formatTimes}
        |formatDateTimes = ${formatDateTimes}
diff --git a/jsonschema2pojo-maven-plugin/src/main/java/org/jsonschema2pojo/maven/Jsonschema2PojoMojo.java b/jsonschema2pojo-maven-plugin/src/main/java/org/jsonschema2pojo/maven/Jsonschema2PojoMojo.java
index 28aaab75..95b97e7b 100644
--- a/jsonschema2pojo-maven-plugin/src/main/java/org/jsonschema2pojo/maven/Jsonschema2PojoMojo.java
+++ b/jsonschema2pojo-maven-plugin/src/main/java/org/jsonschema2pojo/maven/Jsonschema2PojoMojo.java
@@ -551,6 +551,24 @@ public class Jsonschema2PojoMojo extends AbstractMojo implements GenerationConfi
      */
     private boolean includeAccessors = true;
 
+    /**
+     * Whether to include getters or to omit this accessor method and
+     * create public fields instead
+     *
+     * @parameter expression="${jsonschema2pojo.includeGetters}"
+     *            default-value="false"
+     */
+    private boolean includeGetters = false;
+
+    /**
+     * Whether to include setters or to omit this accessor method and
+     * create public fields instead
+     *
+     * @parameter expression="${jsonschame2pojo.includeSetters}"
+     *            default-value="false"
+     */
+    private boolean includeSetters = false;
+
     /**
      * The target version for generated source files.
      *
@@ -564,11 +582,34 @@ public class Jsonschema2PojoMojo extends AbstractMojo implements GenerationConfi
      * these methods.
      *
      * @parameter expression="${jsonschema2pojo.includeDynamicAccessors}"
-     *            default-value="false"
      * @since 0.4.17
      */
     private boolean includeDynamicAccessors = false;
 
+    /**
+     * Whether to include dynamic getters or to omit these methods.
+     *
+     * @parameter expression="${jsonschema2pojo.includeDynamicGetters}"
+     *            default-value="false"
+     */
+    private boolean includeDynamicGetters = false;
+
+    /**
+     * Whether to include dynamic setters or to omit these methods.
+     *
+     * @parameter expression="${jsonschema2pojo.includeDynamicSetters}"
+     *            default-value="false"
+     */
+    private boolean includeDynamicSetters = false;
+
+    /**
+     * Whether to include dynamic builders or to omit these methods.
+     *
+     * @parameter expression="${jsonschema2pojo.includeDynamicBuilders}"
+     *            default-value="false"
+     */
+    private boolean includeDynamicBuilders = false;
+
     /**
      * The project being built.
      *
@@ -964,6 +1005,12 @@ public class Jsonschema2PojoMojo extends AbstractMojo implements GenerationConfi
         return includeAccessors;
     }
 
+    @Override
+    public boolean isIncludeGetters() { return includeGetters; }
+
+    @Override
+    public boolean isIncludeSetters() { return includeSetters; }
+
     @Override
     public String getTargetVersion() {
         return targetVersion;
@@ -974,6 +1021,21 @@ public class Jsonschema2PojoMojo extends AbstractMojo implements GenerationConfi
         return includeDynamicAccessors;
     }
 
+    @Override
+    public boolean isIncludeDynamicGetters() {
+        return includeDynamicGetters;
+    }
+
+    @Override
+    public boolean isIncludeDynamicSetters() {
+        return includeDynamicSetters;
+    }
+
+    @Override
+    public boolean isIncludeDynamicBuilders() {
+        return includeDynamicBuilders;
+    }
+
     @Override
     public String getDateTimeType() {
         return dateTimeType;


Test patch:
diff --git a/jsonschema2pojo-cli/src/test/java/org/jsonschema2pojo/cli/ArgumentsTest.java b/jsonschema2pojo-cli/src/test/java/org/jsonschema2pojo/cli/ArgumentsTest.java
index 112de23e..aec1ff72 100644
--- a/jsonschema2pojo-cli/src/test/java/org/jsonschema2pojo/cli/ArgumentsTest.java
+++ b/jsonschema2pojo-cli/src/test/java/org/jsonschema2pojo/cli/ArgumentsTest.java
@@ -53,7 +53,7 @@ public class ArgumentsTest {
         ArgsForTest args = (ArgsForTest) new ArgsForTest().parse(new String[] {
                 "--source", "/home/source", "--target", "/home/target", "--package", "mypackage",
                 "--generate-builders", "--use-primitives", "--omit-hashcode-and-equals", "--omit-tostring", "--include-dynamic-accessors",
-                "--inclusion-level", "ALWAYS"
+                "--include-dynamic-getters", "--include-dynamic-setters", "--include-dynamic-builders", "--inclusion-level", "ALWAYS"
         });
 
         assertThat(args.didExit(), is(false));
@@ -65,13 +65,16 @@ public class ArgumentsTest {
         assertThat(args.isIncludeHashcodeAndEquals(), is(false));
         assertThat(args.isIncludeToString(), is(false));
         assertThat(args.isIncludeDynamicAccessors(), is(true));
+        assertThat(args.isIncludeDynamicGetters(), is(true));
+        assertThat(args.isIncludeDynamicSetters(), is(true));
+        assertThat(args.isIncludeDynamicBuilders(), is(true));
         assertThat(args.getInclusionLevel(), is(InclusionLevel.ALWAYS));
     }
 
     @Test
     public void parseRecognisesShorthandArguments() {
         ArgsForTest args = (ArgsForTest) new ArgsForTest().parse(new String[] {
-                "-s", "/home/source", "-t", "/home/target", "-p", "mypackage", "-b", "-P", "-E", "-S", "-ida", "-il", "ALWAYS"
+                "-s", "/home/source", "-t", "/home/target", "-p", "mypackage", "-b", "-P", "-E", "-S", "-ida", "-idg", "-ids", "-idb", "-il", "ALWAYS"
         });
 
         assertThat(args.didExit(), is(false));
@@ -83,6 +86,9 @@ public class ArgumentsTest {
         assertThat(args.isIncludeHashcodeAndEquals(), is(false));
         assertThat(args.isIncludeToString(), is(false));
         assertThat(args.isIncludeDynamicAccessors(), is(true));
+        assertThat(args.isIncludeDynamicGetters(), is(true));
+        assertThat(args.isIncludeDynamicSetters(), is(true));
+        assertThat(args.isIncludeDynamicBuilders(), is(true));
         assertThat(args.getInclusionLevel(), is(InclusionLevel.ALWAYS));
     }
 
@@ -110,6 +116,9 @@ public class ArgumentsTest {
         assertThat(args.isIncludeHashcodeAndEquals(), is(true));
         assertThat(args.isIncludeToString(), is(true));
         assertThat(args.isIncludeDynamicAccessors(), is(false));
+        assertThat(args.isIncludeDynamicGetters(), is(false));
+        assertThat(args.isIncludeDynamicSetters(), is(false));
+        assertThat(args.isIncludeDynamicBuilders(), is(false));
     }
 
     @Test
diff --git a/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/AdditionalPropertiesIT.java b/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/AdditionalPropertiesIT.java
index ca7df8a7..443f72ca 100644
--- a/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/AdditionalPropertiesIT.java
+++ b/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/AdditionalPropertiesIT.java
@@ -71,7 +71,7 @@ public class AdditionalPropertiesIT {
     @SuppressWarnings("unchecked")
     public void jacksonCanDeserializeOurAdditionalPropertiesWithoutIncludeAccessors() throws ClassNotFoundException, IOException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
 
-        ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/additionalProperties/defaultAdditionalProperties.json", "com.example", config("includeAccessors", false));
+        ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/additionalProperties/defaultAdditionalProperties.json", "com.example", config("includeGetters", false, "includeAccessors", false));
 
         Class<?> classWithAdditionalProperties = resultsClassLoader.loadClass("com.example.DefaultAdditionalProperties");
 
@@ -105,7 +105,7 @@ public class AdditionalPropertiesIT {
     @Test
     public void jacksonCanSerializeOurAdditionalPropertiesWithoutIncludeAccessors() throws ClassNotFoundException, IOException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, InstantiationException {
 
-        ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/additionalProperties/defaultAdditionalProperties.json", "com.example", config("includeAccessors", false));
+        ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/additionalProperties/defaultAdditionalProperties.json", "com.example", config("includeGetters", false, "includeAccessors", false));
 
         Class<?> classWithAdditionalProperties = resultsClassLoader.loadClass("com.example.DefaultAdditionalProperties");
         String jsonWithAdditionalProperties = "{\"a\":1, \"b\":2};";
diff --git a/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/CompilerWarningIT.java b/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/CompilerWarningIT.java
index df427792..978dfcd5 100644
--- a/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/CompilerWarningIT.java
+++ b/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/CompilerWarningIT.java
@@ -68,14 +68,14 @@ public class CompilerWarningIT {
       {
         "includeAccessorsWithSystemJavaCompiler",
         systemJavaCompiler,
-        config("includeDynamicAccessors", true),
+        config("includeDynamicAccessors", true, "includeDynamicGetters", true, "includeDynamicSetters", true, "includeDynamicBuilders", true),
         "/schema/dynamic/parentType.json",
         Matchers.empty()
       },
       {
         "includeAccessorsWithEclipseCompiler",
         eclipseCompiler,
-        config("includeDynamicAccessors", true),
+        config("includeDynamicAccessors", true, "includeDynamicGetters", true, "includeDynamicSetters", true, "includeDynamicBuilders", true),
         "/schema/dynamic/parentType.json",
         onlyCastExceptions()
       }
diff --git a/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/DynamicPropertiesIT.java b/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/DynamicPropertiesIT.java
index 83fd5357..a4081c49 100644
--- a/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/DynamicPropertiesIT.java
+++ b/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/DynamicPropertiesIT.java
@@ -45,7 +45,8 @@ public class DynamicPropertiesIT {
     @Test
     public void shouldSetStringFieldJava7() throws Throwable {
         setDeclaredPropertyTest(
-                config("includeDynamicAccessors", true, "targetVersion", "1.7"),
+                config("includeDynamicAccessors", true, "includeDynamicGetters", true,
+                    "includeDynamicSetters", true, "includeDynamicBuilders", true, "targetVersion", "1.7"),
                 "/schema/dynamic/parentType.json",
                 "ParentType",
                 String.class,
@@ -172,7 +173,7 @@ public class DynamicPropertiesIT {
 
     @Test
     public void shouldSetAdditionalProperty() throws Exception {
-        ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/dynamic/parentType.json", "com.example", config("includeDynamicAccessors", true));
+        ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/dynamic/parentType.json", "com.example", config("includeDynamicAccessors", true, "includeDynamicGetters", true, "includeDynamicSetters", true, "includeDynamicBuilders", true));
 
         Class<?> parentType = resultsClassLoader.loadClass("com.example.ParentType");
         Object instance = parentType.newInstance();
@@ -192,7 +193,7 @@ public class DynamicPropertiesIT {
 
     @Test
     public void shouldGetAdditionalProperty() throws Exception {
-        ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/dynamic/parentType.json", "com.example", config("includeDynamicAccessors", true));
+        ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/dynamic/parentType.json", "com.example", config("includeDynamicAccessors", true, "includeDynamicGetters", true, "includeDynamicSetters", true, "includeDynamicBuilders", true));
 
         Class<?> parentType = resultsClassLoader.loadClass("com.example.ParentType");
         Object instance = parentType.newInstance();
@@ -213,7 +214,8 @@ public class DynamicPropertiesIT {
     }
 
     public void setDeclaredPropertyTest(String schemaLocation, String typeName, Class<?> fieldType, String fieldName, String fieldGetter, Object value) throws Throwable {
-        setDeclaredPropertyTest(config("includeDynamicAccessors", true), schemaLocation, typeName, fieldType, fieldName, fieldGetter, value);
+        setDeclaredPropertyTest(config("includeDynamicAccessors", true, "includeDynamicGetters", true, "includeDynamicSetters", true, "includeDynamicBuilders", true),
+            schemaLocation, typeName, fieldType, fieldName, fieldGetter, value);
     }
 
     public void setDeclaredPropertyTest(Map<String, Object> config, String schemaLocation, String typeName, Class<?> fieldType, String fieldName, String fieldGetter, Object value) throws Throwable {
@@ -238,7 +240,7 @@ public class DynamicPropertiesIT {
 
     public void withDeclaredPropertyTest(String schemaLocation, String typeName, Class<?> fieldType, String fieldName, String fieldGetter, Object value) throws Throwable {
         ClassLoader resultsClassLoader =
-                schemaRule.generateAndCompile(schemaLocation, "com.example", config("includeDynamicAccessors", true, "generateBuilders", true));
+                schemaRule.generateAndCompile(schemaLocation, "com.example", config("includeDynamicAccessors", true, "includeDynamicGetters", true, "includeDynamicSetters", true, "includeDynamicBuilders", true, "generateBuilders", true));
 
         Class<?> type = resultsClassLoader.loadClass("com.example." + typeName);
         Object instance = type.newInstance();
@@ -260,7 +262,7 @@ public class DynamicPropertiesIT {
     }
 
     public void getDeclaredPropertyTest(String schemaLocation, String typeName, Class<?> fieldType, String fieldName, String fieldSetter, Object value) throws Throwable {
-        ClassLoader resultsClassLoader = schemaRule.generateAndCompile(schemaLocation, "com.example", config("includeDynamicAccessors", true));
+        ClassLoader resultsClassLoader = schemaRule.generateAndCompile(schemaLocation, "com.example", config("includeDynamicAccessors", true, "includeDynamicGetters", true, "includeDynamicSetters", true, "includeDynamicBuilders", true));
 
         Class<?> parentType = resultsClassLoader.loadClass("com.example." + typeName);
         Object instance = parentType.newInstance();
@@ -279,7 +281,7 @@ public class DynamicPropertiesIT {
     }
 
     public void setAdditionalPropertyTest(String schemaLocation, String typeName, Class<?> fieldType, String fieldName, Object value) throws Throwable {
-        ClassLoader resultsClassLoader = schemaRule.generateAndCompile(schemaLocation, "com.example", config("includeDynamicAccessors", true));
+        ClassLoader resultsClassLoader = schemaRule.generateAndCompile(schemaLocation, "com.example", config("includeDynamicAccessors", true, "includeDynamicGetters", true, "includeDynamicSetters", true, "includeDynamicBuilders", true));
 
         Class<?> parentType = resultsClassLoader.loadClass("com.example." + typeName);
         Object instance = parentType.newInstance();
@@ -302,7 +304,7 @@ public class DynamicPropertiesIT {
     }
 
     public void setPropertyTest(String schemaLocation, String typeName, String fieldName, Object value) throws Throwable {
-        ClassLoader resultsClassLoader = schemaRule.generateAndCompile(schemaLocation, "com.example", config("includeDynamicAccessors", true));
+        ClassLoader resultsClassLoader = schemaRule.generateAndCompile(schemaLocation, "com.example", config("includeDynamicAccessors", true, "includeDynamicGetters", true, "includeDynamicSetters", true, "includeDynamicBuilders", true));
 
         Class<?> type = resultsClassLoader.loadClass("com.example." + typeName);
         Object instance = type.newInstance();
@@ -316,7 +318,7 @@ public class DynamicPropertiesIT {
     }
 
     public void getPropertyTest(String schemaLocation, String typeName, String fieldName) throws Throwable {
-        ClassLoader resultsClassLoader = schemaRule.generateAndCompile(schemaLocation, "com.example", config("includeDynamicAccessors", true));
+        ClassLoader resultsClassLoader = schemaRule.generateAndCompile(schemaLocation, "com.example", config("includeDynamicAccessors", true, "includeDynamicGetters", true, "includeDynamicSetters", true, "includeDynamicBuilders", true));
 
         Class<?> type = resultsClassLoader.loadClass("com.example." + typeName);
         Object instance = type.newInstance();
diff --git a/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/config/IncludeAccessorsIT.java b/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/config/IncludeAccessorsIT.java
index 74e668b6..9e4306c4 100644
--- a/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/config/IncludeAccessorsIT.java
+++ b/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/config/IncludeAccessorsIT.java
@@ -50,7 +50,7 @@ public class IncludeAccessorsIT {
     @Test
     public void beansOmitGettersAndSettersWhenAccessorsAreDisabled() throws ClassNotFoundException, SecurityException, NoSuchMethodException, NoSuchFieldException {
 
-        ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/properties/primitiveProperties.json", "com.example", config("includeAccessors", false));
+        ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/properties/primitiveProperties.json", "com.example", config("includeAccessors", false, "includeGetters", false, "includeSetters", false));
 
         Class generatedType = resultsClassLoader.loadClass("com.example.PrimitiveProperties");
 
@@ -62,7 +62,7 @@ public class IncludeAccessorsIT {
 
         try {
             generatedType.getDeclaredMethod("setA", Integer.class);
-            fail("Disabled accessors but getter was generated");
+            fail("Disabled accessors but setter was generated");
         } catch (NoSuchMethodException e) {
         }
 
@@ -73,7 +73,7 @@ public class IncludeAccessorsIT {
     @Test
     public void beansWithoutAccessorsRoundTripJsonCorrectly() throws ClassNotFoundException, SecurityException, NoSuchMethodException, NoSuchFieldException, InstantiationException, IllegalAccessException, IOException {
 
-        ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/properties/primitiveProperties.json", "com.example", config("includeAccessors", false));
+        ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/properties/primitiveProperties.json", "com.example", config("includeAccessors", false, "includeGetters", false, "includeSetters", false));
 
         Class generatedType = resultsClassLoader.loadClass("com.example.PrimitiveProperties");
 
diff --git a/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/config/IncludeAccessorsPropertiesIT.java b/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/config/IncludeAccessorsPropertiesIT.java
index b134a631..88c783f1 100644
--- a/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/config/IncludeAccessorsPropertiesIT.java
+++ b/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/config/IncludeAccessorsPropertiesIT.java
@@ -110,6 +110,8 @@ public class IncludeAccessorsPropertiesIT {
     private static Map<String, Object> configWithIncludeAccessors(Map<String, Object> template, boolean includeAccessors) {
         Map<String, Object> config = new HashMap<String, Object>(template);
         config.put("includeAccessors", includeAccessors);
+        config.put("includeGetters", includeAccessors);
+        config.put("includeSetters", includeAccessors);
         return config;
     }