Thoughts on Path Fragments - microbean/microbean-settings GitHub Wiki
Maybe a Path
as currently defined is too flexible and hence too complicated.
The complexity comes from having qualifiers at every node in the path. How do you apply matching algorithms to them in an additive fashion? I'm not smart enough to do that.
Let's separate the notion of qualifiers from paths for a moment.
What if instead we have PathFragment
s and Accessor
s?
Let's say a PathFragment
is a List
of Accessor
s terminating in a Type
. An Accessor
at its simplest is a name. An Accessor
can also have parameters (a List<Class<?>>
) and corresponding arguments of the appropriate type (a List<?>
). So an Accessor
can represent a kind of "typeless" "getter method" invocation or array access.
So a PathFragment
is never absolute. It just represents, e.g. getDrivetrain/getEngine/getCylinders:List<Cylinder>
. Note that getDrivetrain
is not "anchored" with Car
.
Or we could allow it to have a source, intermediate and target type, all optional (except for the target), separated by accessors.
So that would let you say :Car/getDrivetrain/getEngine:Engine/getCylinders:List<Cylinder>
.
Then you could join them: getDailyDriver:Car
+ :Car/getDrivetrain/getEngine:Engine/getCylinders:List<Cylinder>
= getDailyDriver:Car/getDrivetrain/getEngine:Engine/getCylinders:List<Cylinder>
. Since the intermediate type is optional, you can now build arbitrary path fragments.
Then a full Path
is a PathFragment
with a source type of :RootType
and no accessors or target type, plus another PathFragment
with no source type, an optional list of accessors and a target type.
Now you can match Provider
path fragments against "rooted" context paths (you'll always be looking for "ends with").