Unknowns as first class and support for deeper types
Pre-release
Pre-release
akshaisarma
released this
30 Jul 17:23
·
10 commits
to master
since this release
This release changes:
- The
TypedObject(Type, Serializable)
constructor now figures out the type if the passed in type wasType#UNKNOWN
- The behavior of Type discovery in
Type#getType(Object)
is changed. For container of containers (e.g.INTEGER_MAP_LIST
orSTRING_MAP_MAP
), the discovered type can now beUNKNOWN_MAP
,UNKNOWN_LIST
,UNKNOWN_MAP_MAP
,UNKNOWN_MAP_LIST
in many more cases. Previously, this code looked for the first type that we support in these containers. Now, unless all the types in the container match this one type, the corresponding UNKNOWN container type is returned instead. This also has the behavior that maps inside containers whose types can't be discovered (if they're empty or only contain null values) cause the entire collection to discovered as the UNKNOWN container type. This differs from before where the discovery would skip these objects whose type can't be discovered and seek for the first valid one.
These two changes basically make UNKNOWN containers usable in Bullet. The use-case for this is sticking objects into a BulletRecord that nest deeper than the types we support. Bullet itself will recognize them appropriately as UNKNOWN_MAP_MAP
or UNKNOWN_MAP_LIST
and will let you extract fields up to the level we do recognize. If those extracted fields are types we support, then Bullet can still operate on them! The change in 1 above causes these extracted UNKNOWNs to have their Type discovered and fix itself.
This change will affect both TypedBulletRecord
and UntypedBulletRecord
as BulletRecord#typedGet
will now discover types for UNKNOWN containers