Hi,
I don't think we need it. I use anonymous adapers as follows:
jsonb = JsonbBuilder.create(new JsonbConfig().withAdapters(new JsonbAdapter<Box, Crate>() {
@Override public CrateadaptFrom(Box box) {
...}
@Override public BoxadaptTo(Crate crate) {
...}
}));
A compile time generic information of type arguments From and To would
is still available in case of anonymous class. You are right it isnt
clear from javadoc which type of From and To stands for which object.
"From" is for type that we would like to adapt. "To" is for type into
which adaptation is done. But it is a "two way" process, which is always
dependant on context - marshalling / unmarshalling. During marshalling
we convert From to To and than serialize To. During unmarshalling we
first deserialize into To, cibvert To to From which is set thereafter in
resultin business model. Would it be any more clear if we rename methods
"adaptFrom" and "adaptTo" to "adaptMarshalling" and
"adaptUnmarshalling"? Regards, Roman
On 01/29/2016 07:10 PM, Romain Manni-Bucau wrote:
> do we add a withAdapter(from, to, adapter) method to JsonbConfig?
> it would allow anonymous adapters to work instead of having to create
> a class.
> Also the javadoc should be updated since to and from method have the
> same and we don't know if the json type should be from or to - I'd
> assume from but would be good to make it clear. Or do we support auto
> detection (ie <A, B> = <B, A> for the runtime? this would prevent
> custom logic in one particular way if so)
> Romain Manni-Bucau
> @rmannibucau
> http://www.tomitribe.com
> http://rmannibucau.wordpress.com
> https://github.com/rmannibucau