I have a situation where many many keys are pointing to a single value. The situation arises from a service locator pattern that I am implementing such that -
- each method in an interface is represented as a signature string
- All such signatures of a single interface are used as keys
- The value being the full canonical name of the implementation class
Thus my need is to retrieve a single value when user requests any of the matching keys.
In a sense I need an opposite of MultiMap from Guava .
I am looking for the most optimized solution there is since my keys are very similar though unique for a specific value and I am not sure if using a generic Map implementation like HashMap is efficient enough to handle this case.
e.g. all the below signatures
==============
_org.appops.server.core.service.mocks.MockTestService_testOperationThree _org.appops.server.core.service.mocks.MockTestService_getService _org.appops.server.core.service.mocks.MockTestService_start _org.appops.server.core.service.mocks.MockTestService_testOperationTwo_String_int _org.appops.server.core.service.mocks.MockTestService_getName _org.appops.server.core.service.mocks.MockTestService_shutdown _org.appops.server.core.service.mocks.MockTestService_testOperationOne_String
=======
Point to a single class i.e. org.appops.server.core.service.mocks.MockTestServiceImpl and I am anticipating hundreds of such classes (values) and thousands of such similar signatures (keys) .
In case there is no optimized way I could always use a HashMap with replicated values for each group of keys which I would like to avoid.
Ideally I would like to use a ready utility from Guava.