Skip to content

Conversation

rob-bygrave
Copy link
Contributor

…able() - To support Guava ImmutableList etc

When using isAssignable(), the specialised collection types like Guava ImmutableList get treated like java.util.List and this means that we don't end up using any Custom JsonAdapter that we define for those special types.

Changing to use equals() means that we really expect the java.util List|Set|Map collection types to be used and no ArrayList, LinkedList etc (which would have kind of worked before but not really in that they all would have ended up as ArrayList, LinkedHashSet, LinkedHashMap. So using equals() here should be ok.

…able() - To support Guava ImmutableList etc

When using isAssignable(), the specialised collection types like Guava ImmutableList get treated like java.util.List
and this means that we don't end up using any Custom JsonAdapter that we define for those special types.

Changing to use equals() means that we really expect the java.util List|Set|Map collection types to be used and
no ArrayList, LinkedList etc (which would have kind of worked before but not really in that they all would have
ended up as ArrayList, LinkedHashSet, LinkedHashMap. So using equals() here should be ok.
@vamega
Copy link
Contributor

vamega commented Aug 12, 2025

I had tried this approach, and ended up with something very similar to what you have. You can see my approach here: main...vamega:avaje-jsonb:varun/collection-without-assignable

Some things I had done differently:

  1. Added a test for the custom adapter for Guava (guava is only added as a dep of the blackbox test)
  2. I had created adapters for ArrayList, HashSet, HashMap

I prefer your approach of doing this in the equality test. I'm not sure if you want to support classes that have fields defined as HashMap in the core library. IME it's pretty common for objects to use HashMap/HashSet concrete class instead of the interface.

Thanks for this. It seems like it will address my original issue in #405

@SentryMan SentryMan merged commit c8066f5 into main Aug 17, 2025
9 checks passed
@SentryMan SentryMan deleted the feature/collection-types-specific branch August 17, 2025 20:47
@SentryMan SentryMan added this to the 3.7 milestone Aug 19, 2025
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.

Is it possible to use this library with the Immutable collections from Guava.
4 participants