Compile-Time generation of gson adapters
 
 
Go to file
Johannes Frohnmeyer 1e45cd9bc2
ci/woodpecker/push/woodpecker Pipeline was successful Details
(maybe) support String2ObjectMap
2 months ago
gson-compile-annotations @With annotation instead of legacy code for @JsonAdapter 4 months ago
gson-compile-core (maybe) support String2ObjectMap 2 months ago
gson-compile-example @With annotation instead of legacy code for @JsonAdapter 4 months ago
gson-compile-example-manifold Support JPMS. 4 months ago
gson-compile-processor (maybe) support String2ObjectMap 2 months ago
gson-compile-processor-core (maybe) support String2ObjectMap 2 months ago
.gitignore Support for 1d classes of primitives 7 months ago
.woodpecker.yml Attempt maven publish 7 months ago
LICENSE.md License 7 months ago
README.md Only generate @Extension once 6 months ago
build.gradle.kts Support JPMS. 4 months ago
settings.gradle.kts Update deps 4 months ago

README.md

Gson-Compile

A java annotation processor implementing automated type adapter generation for gson-comments. The goal of this AP is to

  • Support common features such as getters, setters, fields, constructors
  • Support modern language features such as records
  • Support json5 through gson-comments
  • Be compile-time where possible (ideally compatible with proguard)

Supported types

  • Primitives (and boxes)
  • Records
  • Nested serializable types
  • Arrays
  • Collections (Sets, Lists, Queues, Deques)
  • java.util.Date as iso8601
  • Enums
  • Maps with string, primitive, enum or UUID keys

Used properties

Use @GPrefer to choose one construction method if multiple are available

  • Builders (referenced in @GSerializable)
  • Factory functions
  • Constructors
  • Getters/Setters
  • Direct fields (public non-static only)

Additional features

  • Support for generating Gson adapters to hook into the gson system
  • Optional, strict no-reflection enforcement via -AgsonCompileNoReflect
  • Comments via @GComment
  • Several utility methods in the generated class for reading from/writing to various sources
  • Support for generating extension methods if manifold is present

TODO

  • Support for nested types from libraries
  • Static classes (for configs)

Credit