-
Notifications
You must be signed in to change notification settings - Fork 22
Add general generics support to B2Json. #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…on for different Type implementations.
This allows removal of the static getUnitializedFieldHandler method, which means simplifies the code paths taken during recursive handler generation.
…Make resolution by type private.
…d of getHandledClass method.
bwbeach
left a comment
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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?
DP-842 - use venv for b2 upload
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
staticgetUnitializedFieldHandler()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.