From 24e1ab86799aa2c13317c03e01f0b4d7cdae6b39 Mon Sep 17 00:00:00 2001 From: Joe Littlejohn Date: Sun, 18 Feb 2018 21:44:50 +0000 Subject: [PATCH] Improve interaction between -da, -dg and -ds flags Fixes #790 --- .../src/main/java/org/jsonschema2pojo/cli/Arguments.java | 8 ++++++-- .../test/java/org/jsonschema2pojo/cli/ArgumentsTest.java | 8 +++++++- 2 files changed, 13 insertions(+), 3 deletions(-) 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 348133eec..4b22b67e5 100644 --- a/jsonschema2pojo-cli/src/main/java/org/jsonschema2pojo/cli/Arguments.java +++ b/jsonschema2pojo-cli/src/main/java/org/jsonschema2pojo/cli/Arguments.java @@ -16,7 +16,7 @@ package org.jsonschema2pojo.cli; -import static org.apache.commons.lang3.StringUtils.defaultString; +import static org.apache.commons.lang3.StringUtils.*; import java.io.File; import java.io.FileFilter; @@ -430,7 +430,11 @@ public boolean isIncludeAdditionalProperties() { @Override public boolean isIncludeAccessors() { - return !disableAccessors; + if (disableGetters || disableSetters) { + return false; + } else { + return !disableAccessors; + } } @Override 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 aec1ff72b..c96399905 100644 --- a/jsonschema2pojo-cli/src/test/java/org/jsonschema2pojo/cli/ArgumentsTest.java +++ b/jsonschema2pojo-cli/src/test/java/org/jsonschema2pojo/cli/ArgumentsTest.java @@ -51,7 +51,7 @@ public void tearDown() { @Test public void parseRecognisesValidArguments() { ArgsForTest args = (ArgsForTest) new ArgsForTest().parse(new String[] { - "--source", "/home/source", "--target", "/home/target", "--package", "mypackage", + "--source", "/home/source", "--target", "/home/target", "--disable-getters", "--package", "mypackage", "--generate-builders", "--use-primitives", "--omit-hashcode-and-equals", "--omit-tostring", "--include-dynamic-accessors", "--include-dynamic-getters", "--include-dynamic-setters", "--include-dynamic-builders", "--inclusion-level", "ALWAYS" }); @@ -64,6 +64,9 @@ public void parseRecognisesValidArguments() { assertThat(args.isUsePrimitives(), is(true)); assertThat(args.isIncludeHashcodeAndEquals(), is(false)); assertThat(args.isIncludeToString(), is(false)); + assertThat(args.isIncludeAccessors(), is(false)); + assertThat(args.isIncludeGetters(), is(false)); + assertThat(args.isIncludeSetters(), is(true)); assertThat(args.isIncludeDynamicAccessors(), is(true)); assertThat(args.isIncludeDynamicGetters(), is(true)); assertThat(args.isIncludeDynamicSetters(), is(true)); @@ -115,6 +118,9 @@ public void allOptionalArgsCanBeOmittedAndDefaultsPrevail() { assertThat(args.isUsePrimitives(), is(false)); assertThat(args.isIncludeHashcodeAndEquals(), is(true)); assertThat(args.isIncludeToString(), is(true)); + assertThat(args.isIncludeAccessors(), is(true)); + assertThat(args.isIncludeGetters(), is(true)); + assertThat(args.isIncludeSetters(), is(true)); assertThat(args.isIncludeDynamicAccessors(), is(false)); assertThat(args.isIncludeDynamicGetters(), is(false)); assertThat(args.isIncludeDynamicSetters(), is(false));