hollow icon indicating copy to clipboard operation
hollow copied to clipboard

Provide POJO delegate type

Open DanielThomas opened this issue 6 years ago • 3 comments

Writing tests and adapting a legacy model to Hollow exposed a few cases where a plain POJO delegate for a HollowObject would be beneficial. For ergnomics, if there was a way of instantiating the POJO delegate from a overloaded constructor to static factory that'd be ideal, as it hides the specifics of the POJO delegate.

Legacy Model

When adapting a legacy model to Hollow there are often intermediate collaborators in your application that take the model in their API or places where the model class needs to be created at runtime as a result of some logic. Those objects need to be created at runtime because they can't be pushed into the producer, or at least a phased migration is necessary.

Serialization Frameworks

Allow other serialization frameworks to deserialize to objects that satisfy the API.

That would allow https://github.com/Netflix/hollow/pull/298 to provide a deserializer that could provide an instance HollowObject with a POJO delegate.

In our case, it'd allow to replace our model end-to-end from request to response with the Hollow generated model.

Unit Tests

The current hollow-test infrastructure works great for instances where you're need to work with an whole consumer, but for unit tests it'd be great to avoid that overhead and be able to produce HollowObject instances directly.

DanielThomas avatar Nov 15 '18 19:11 DanielThomas

Interesting idea, thanks. FWIW you can simplify that a bit by using a HollowReadStateEngineBuilder, something like

new AstridAPI(new HollowReadStateEngineBuilder().add(obj).build())

akhaku avatar Nov 15 '18 21:11 akhaku

Ah, that's really useful - I didn't realise you could go straight to a read state like that.

DanielThomas avatar Nov 15 '18 21:11 DanielThomas

@akhaku I realized this has more utility than just unit tests, so I updated the description.

DanielThomas avatar Nov 27 '18 00:11 DanielThomas