Gson TypeAdapters for Guava Immutable Objects.
Requires JDK 1.6 or higher (Guava)
http://dampcake.github.io/gson-immutable
<dependency>
<groupId>com.dampcake</groupId>
<artifactId>gson-immutable</artifactId>
<version>1.2</version>
</dependency>compile 'com.dampcake:gson-immutable:1.2'Register Guava Immutable interfaces:
final Gson gson = new GsonBuilder().registerTypeAdapterFactory(ImmutableAdapterFactory.forGuava()).create();Register Java interfaces:
final Gson gson = new GsonBuilder().registerTypeAdapterFactory(ImmutableAdapterFactory.forJava()).create();| Interface | Immutable Version | Supported? |
|---|---|---|
| Collection | ImmutableCollection | ✔️ |
| List | ImmutableList | ✔️ |
| Set | ImmutableSet | ✔️ |
| SortedSet | ImmutableSortedSet | ✔️ |
| NavigableSet | ImmutableSortedSet | ✔️ |
| Map | ImmutableMap | ✔️ |
| SortedMap | ImmutableSortedMap | ✔️ |