I'm building a simple multi key hash map in a Java based application which would return a lookup value provided different combinations of keys where all keys and values are vanilla strings. Let's say below is a sample data set.
Key1|Key2|Key3|Key4|Result|
T1 | T2 | T3 | T4 | A1 |
* | * | T3 | T4 | A4 |
T1 | T2 | T3 | * | A2 |
* | T1 | * | T4 | A2 |
where * indicates ANY value.
The hash map will comprise of keys 1-4 and result as it's look up value. The keys will have specific values(such as T1,T2) and it's only the data set that has *(ANY) values. I'm trying to figure out what could be a best possible way to look up the correct value based on the most specific key.
For example a key combination of T1,T2,T3,T4 (from above) should return A1 as the result whereas a key combination of B1,B2,T3,T4 should return A4 as the result.
Any ideas would be really appreciated. The preference is to do it in simple Java without any additional libraries/frameworks but happy to look at them if need be.
Thanks a lot