Skip to content

Commit

Permalink
Improve interaction between -da, -dg and -ds flags
Browse files Browse the repository at this point in the history
Fixes #790
  • Loading branch information
joelittlejohn committed Feb 18, 2018
1 parent f19633d commit 24e1ab8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -430,7 +430,11 @@ public boolean isIncludeAdditionalProperties() {

@Override
public boolean isIncludeAccessors() {
return !disableAccessors;
if (disableGetters || disableSetters) {
return false;
} else {
return !disableAccessors;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
});
Expand All @@ -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));
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 24e1ab8

Please sign in to comment.