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

Test case to document behaviour of Record x Single-value Constructor x JsonValue annotation, for #3180 #3738

Merged

Conversation

yihtserns
Copy link
Contributor

@yihtserns yihtserns commented Jan 17, 2023

After I provided update to #3180, I suddenly remembered documentating an observation that Record with 1-arg constructor will produce Properties-based Creator when I was working on #3724, so this shouldn't have worked:

record Watts(@JsonValue double value) {
}

mapper.readValue("123", Watts.class);

But it turns out that:

  1. Record with 1-arg header/constructor:
    • Properties-based creator
  2. Record with N-args header/constructor + 1-arg (alternative/custom) constructor:
    • Properties-based creator (for the canonical constructor)
    • Delegating creator (for the alternative/custom constructor)
  3. Record with 1-arg header/constructor + @JsonValue:
    • Delegating creator

This PR is to add test cases to document (and to catch potential future regression) number 3.

UPDATE: Just found out behaviour number 3 came from #3654. Nice. 👍

@cowtowncoder
Copy link
Member

Ok, rules do get quite complicated. But I agree, better to have tests covering them & working as documentation.

@cowtowncoder cowtowncoder merged commit ae3ca88 into FasterXML:2.15 Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants