public Builder gson(Gson gson) {
      checkNotNull(gson, "gson");

      Gson newGson = GsonCodecs.newGsonWithBsonSupport(gson);

      // expose new Gson as CodecRegistry. Using fromRegistries() for caching
      CodecRegistry codecRegistry = CodecRegistries.fromRegistries(GsonCodecs.codecRegistryFromGson(newGson));

      return codecRegistry(codecRegistry, new GsonNamingStrategy(gson));
    }
Configures current repository setup with {@link Gson} serialization.

<p>
You could use service providers for {@link TypeAdapterFactory} interface to register type
adapters. This mechanism, while optional, used a lot in immutables and allows for easy
registration if launched in a simple flat classpath.

<pre>
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapterFactory(new TypeAdapters()); // BSON specific type adapters
...
for (TypeAdapterFactory factory : ServiceLoader.load(TypeAdapterFactory)) {
  gsonBuilder.registerTypeAdapterFactory(factory);
}
Gson gson = gsonBuilder.create();
</pre>

The factory registration shown above is done by default when using
{@link RepositorySetup#forUri(String)} to create setup.
@param gson configured {@link Gson} instance
@see #codecRegistry(CodecRegistry) for other serialization options
@return {@code this}
mongo/src/org/immutables/mongo/repository/RepositorySetup.java