Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot configure default GsonSupport #386

Open
musiy opened this issue Mar 9, 2023 · 0 comments
Open

Cannot configure default GsonSupport #386

musiy opened this issue Mar 9, 2023 · 0 comments

Comments

@musiy
Copy link

musiy commented Mar 9, 2023

The default JsonSupport comes with GsonSupport class with predefined configuration:

  private static class GsonCompressedHolder {

    private static final Gson INSTANCE = new GsonBuilder()
        .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
        .registerTypeAdapter(OFFSET_DATE_TIME_TYPE, new OffsetDateTimeSerdes())
        .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
        .create();
  }

  private static class GsonHolder {

    private static final Gson INSTANCE = new GsonBuilder()
        .setPrettyPrinting()
        .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
        .registerTypeAdapter(OFFSET_DATE_TIME_TYPE, new OffsetDateTimeSerdes())
        .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
        .create();
  }

It's pretty common case that we need to specify another parameters for Gson INSTANCE - for example, field naming policy. The decision for now is to define our own JsonSupport implementation and specify Gson as we need it. But it seems to me that it can be more easy to support this feature in nakadi-java: provide your own Gson object or parameters to create Gson objectn during creation of NakadiClient.

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

No branches or pull requests

1 participant