'In java map, I want to assign the repository functions as value like Map<key, function(>
I Want to call the JPA repository functions to access the data from the database based on the String value passed.
So I want to make the string as the key and the reposetory function as Value so that I could call the function like:
map.set("id":repository.findById())
map.set("name":repository.findByName())
To access the result I just pass the string(str) value as "id" or "name" and get the result. call map.get(str);
I got a solution Maps : In Java Maps can I assign a function to the value in the <K,V> pair?, But it's looking old approach, do we have any other new/better approach...?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|