Building context with flexible adapters significantly reduces coding time. The goal is to do the mappings only and retain lazy value fetching.
Following excerpts are taken from Hyperon Motor-Insurance Demo App.
Path argument of get method is divided into tokens ('.' delimited). Based on first token's value the proper adapter is chosen and remaining tokens (subpath) are passed to it.
These are sample adapters:
The role of the getMapping() is to match single token extracted from path to final value e.g.
or next adapter in chain e.g.
The subsequent adapter that is called will do exactly the same. This way the entire path is readily covered.
Having context implemented in such way, we can query for all valid paths: