feat: collapsable inner records for to(Class) access#95
Merged
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



API Changes
These changes were made to provide a more versatile API while at the same time have less specialized methods and avoid unnecessary re-wrapping or API elevation on the caller side as in case of
Iterator=>Stream.Backwards incompatible changes:
keys()now returnsStreamable.Sizedentries()now returnsStreamable.Sizedvalues()is obsolete asentries()is identical (values()for objects needed to be removed as it otherwise would have clashed with newly added method of same name for arrays asJsonMixedextends both)listValues,streamValuesandvalues(Function)which all can done viavaluesBackwards compatible changes (apart from potential name clashes in extending types):
values()allows array element access asStreamable.Sized<JsonMixed>(enables use in for-each while also provide stream access)values(Index)(same as above but with control over index behaviour)values(Class)(same as above but with included access as a "mapped" type, e.g. arecord)JsonMixednow extendsJsonPrimitiveas wellJsonNode#membersnow returnsStreamable.Sized(notStreamable)JsonNode#pathsnow returnsStreamable.Sized(notStreamable)JsonNode#elementsnow returnsStreamable.Sized(notStreamable)JsonNode#valuesnow returnsStreamable.Sized(notStreamable)Compose
to-targets using@Collapsedinner recordsrecordtypes the records now can have components that are annotated with new annotation@Collapsedto map a "flat" JSON object to a structured Java composition of components from different types. This is quite essential forrecordtypes as inheritance as a means of composition is not possible. With this feature records can now achieve the equivalent of multiple-inheritance by composing multiple inner@Collapsedrecords within a root or parentrecordtype.JsonObject#collapsedPropertiesto get a types properties with@Collapsedinner properties flattened into the listNote that inner records are never
nullwhen accessed viatoeven if all of their properties are not present in the input JSON. This is so there is a simple, clear contract that avoids NPEs and is easy to implement.Other Improvements
Numberof a JSON number value with numeric zero value having0decimal digit(s) does not result inTextualNumberbut aDoubleStreamable.Sizednow hasmapandtoList(like aStream) which often avoid the need to even elevate to aStreamso that iteration occurs directly on a mappedIteratorClassproperties are now automatically considered string propertiesBugfixes
.where wrongly considered zero byTextualNumber#isNumericZeroAutomatic Testing
TextualNumber@Collapsedinnerrecords