I would like a library that works just like servlet mappings, without the servlet container. It should support concepts such as this:
/* maps the default value
/exact maps exact path maps
/prefix maps any path that begins with "/prefix"
*.suffix maps any paths that end with "suffix".
Imagine something like a Map that accepts string paths to fetch values. The library should also support some concept of priority, so if I add an exact path before a prefix, the test is against the exact, before checking the prefix paths. Naturally, I could write my own, but a boring linear search seems a bit dumb, especially as most paths will be exact patterns.
Does anyone know of a library that does something like this?
I ended up righting my own little package that uses the chain of responsbility pattern. It groups exact matches that were added consecutively into a single link(not sure what eacch element in a cor is called) in the chain. All other types of mapping are single “links”. The search invokes the chain until a value is returned ignoring the remainder of the chain.