Posts

Showing posts with the label classes

Boon JSON Custom object serializer now works with super classes and interfaces Example of using Guava HashCode

Boon JSON Custom object serializer now works with super classes and interfaces Example of using Guava HashCode related to https://github.com/RichardHightower/boon/issues/242 https://github.com/RichardHightower/boon/issues/231 Boon JSON: Custom object serializer works with super classes, and interfaces (and example of using HashCodeGuava).  Lets say you want to write a custom object serializer to work with Guava HashCode thingy or whatever else you need. public static String toJson ( Object obj ) { return createSerializer (). serialize ( obj ). toString (); } private static JsonSerializer createSerializer () { JsonSerializerFactory factory = new JsonSerializerFactory () . addTypeSerializer ( HashCode . class , new HashCodeSerializer () ); return factory . create (); } private static class HashCodeSerializer implements CustomObjectSerializer < HashCode > { @Override public Class < HashCode > type () { return HashCode . class ; } @...