@SuppressWarnings("unchecked")
    @Override
    public Object read(Gson gson, Type type, InputStream stream) throws IOException {
      @Nullable JsonReader reader = null;
      try {
        reader = createJsonReader(new BufferedReader(new InputStreamReader(stream, CHARSET_NAME)));
        options.setReaderOptions(reader);

        return gson.getAdapter((TypeToken<Object>) TypeToken.get(type)).read(reader);
      } catch (IOException ex) {
        throw ex;
      } catch (Exception ex) {
        throw new IOException(ex);
      }
    }
Creates new provider with flexible setup.
@param options options for provider
gson/src/org/immutables/gson/stream/GsonMessageBodyProvider.java