Skip to content

Conversation

rbygrave
Copy link
Contributor

@rbygrave rbygrave commented Mar 4, 2025

Instead they have getter methods that initialise the collection like:

  public List<String> getTags() {
    if (tags == null) {
      tags = new ArrayList<>();
    }
    return tags;
  }

This change detects the case when a field does not have any matching constructor or setter, and it's a collection type (List,Set,Collection), then we assume it follows JAX-B style and the getter will initialise the collection.

We then generate code that uses the getter + addAll() ... instead of failing with the error:

"Non public field org.example.MyJaxbType tags with no matching setter or constructor?"

rbygrave added 2 commits March 4, 2025 13:23
Instead they have getter methods that initialise the collection like:

  public List<String> getTags() {
    if (tags == null) {
      tags = new ArrayList<>();
    }
    return tags;
  }

This change detects the case when a field does not have any matching constructor or setter, and it's a collection type (List,Set,Collection), then we assume it follows JAX-B style and the getter will initialise the collection.

We then generate code that uses the getter + addAll()
... instead of failing with the error:

"Non public field org.example.MyJaxbType tags with no matching setter or constructor?"
@rbygrave rbygrave requested a review from SentryMan March 4, 2025 00:26
@rbygrave rbygrave self-assigned this Mar 4, 2025
@rbygrave rbygrave added this to the 3.1 milestone Mar 4, 2025
@rbygrave rbygrave merged commit 47068fc into main Mar 4, 2025
9 checks passed
@rbygrave rbygrave deleted the feature/support-jaxb-style-collections branch March 4, 2025 04:42
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.

2 participants