cognitect / transit-java

transit-format implementation for Java
Apache License 2.0
62 stars 21 forks source link

Default Writer #19

Closed AlexanderMann closed 7 years ago

AlexanderMann commented 8 years ago

Request

When specifying a writer for the transit java library, allow for a default writer to be passed in.

Motivation

I've recently run into wanting to have the ability to have a default writer for transit. Presently, there is a concept of a default reader (https://github.com/cognitect/transit-java/blob/master/src/main/java/com/cognitect/transit/DefaultReadHandler.java) but for writing the ability to override objects at a base level isn't quite as straightforward.

Since finding a write handler works by first traversing the object inheritance then the abstracts implemented, you cannot use an Object or Serializable default writer. You almost have to have the ability to specify a default writer somewhere around here: https://github.com/cognitect/transit-java/blob/master/src/main/java/com/cognitect/transit/impl/WriteHandlerMap.java#L137


Happy to implement this as a library on top of transit-java or even as a fork if that's the best path forward here. I'm using the transit-clj library and have found it to be pretty excellent.

dchelimsky commented 7 years ago

Fixed in 0588d87.

Released in transit-java-0.8.327.