Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for char fields #26

Closed
apenlor opened this issue Nov 9, 2023 · 4 comments · Fixed by #32
Closed

Support for char fields #26

apenlor opened this issue Nov 9, 2023 · 4 comments · Fixed by #32
Assignees
Labels
bug Something isn't working

Comments

@apenlor
Copy link
Contributor

apenlor commented Nov 9, 2023

Both char or char[] fields are causing failures during the compilation.

For char
java: incompatible types: java.lang.String cannot be converted to char

For char[]
java: java.lang.NullPointerException: Cannot invoke "Object.toString()" because "o" is null

@apenlor apenlor added the bug Something isn't working label Nov 9, 2023
@tfdsimoes tfdsimoes self-assigned this Nov 16, 2023
@tfdsimoes tfdsimoes linked a pull request Nov 16, 2023 that will close this issue
@tfdsimoes
Copy link
Collaborator

CharType does not exist in Pact, so I change to be a StringType

  @Example("a")
  private char aChar1;

  private char aChar2;

Code generated

          String aChar1 = "a";

          String aChar2 = "g";
;

      public DemoClassBuilder setAChar1(final String aChar1) {
    this.aChar1 = aChar1;
    return this;
  }
      public DemoClassBuilder setAChar2(final String aChar2) {
    this.aChar2 = aChar2;
    return this;
  }

    public DslPart build() {
        PactDslJsonBody pactDslJsonBody = new PactDslJsonBody();
      if (Objects.nonNull(aChar1)) {
          pactDslJsonBody.stringType("aChar1", aChar1);
      }
      if (Objects.nonNull(aChar2)) {
          pactDslJsonBody.stringType("aChar2", aChar2);
      }

        return pactDslJsonBody;
    }

@apenlor apenlor moved this from Todo to In Progress in PactDslBuilder - annotation processor Nov 16, 2023
@apenlor apenlor reopened this Nov 16, 2023
@apenlor
Copy link
Contributor Author

apenlor commented Nov 16, 2023

Support for char[] is still pending

java: java.lang.NullPointerException: Cannot invoke "Object.toString()" because "o" is null

@apenlor apenlor moved this from Done to In Progress in PactDslBuilder - annotation processor Nov 16, 2023
@tfdsimoes
Copy link
Collaborator

tfdsimoes commented Nov 19, 2023

@apenlor the problem you reported happens in every type of Array
It should be treat as a new issue in my point of view

@apenlor
Copy link
Contributor Author

apenlor commented Nov 20, 2023

Makes sense :)
#39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

2 participants