Skip to content

Conversation

@tiwijo
Copy link

@tiwijo tiwijo commented Dec 12, 2019

This PR adds support for (de)serialization of class hierarchies that contain generics. As long as the root class provides all the context necessary, we should be able to resolve any nested types by propagating type parameters down.

This changes the mapping from class -> handler to type -> handler. The recursion is more streamlined (no more static getUnitializedFieldHandler() method). If handlers are tied to parameteric types, they are cached by class and type arguments to avoid collisions.

This PR is broken in many many small PRs, so it can be reviewed in small steps as well as by just comparing straight to master. Hopefully that is helpful. The unit tests pass at each intermediate commit.

Copy link
Contributor

@bwbeach bwbeach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really nice! Thanks for doing it.

// class Dataset {
// private List<Double> measurements;
// }
if (type instanceof ParameterizedType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type here is from the field, right? It's the List<Double>?

Having the class Dataset in the comment above is a little confusing.

if (typeMap == null) {
throw new RuntimeException("Cannot resolve type " + type + " - the typeMap is empty");
}
return typeMap.get(type.getTypeName());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw if result is null?

@tiwijo tiwijo merged commit f306d4c into master Dec 20, 2019
nbehrens-bz pushed a commit that referenced this pull request May 12, 2025
DP-842 - use venv for b2 upload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants