0

Is there any Map like

MAP < String, FunctionMethod >

library in Java? No, there isn't. Then any external or open source library available?

7
  • Java has some classes for maps, but that's not what you're looking for !? Commented Sep 21, 2011 at 4:29
  • Your question is very confusing to me. What do you mean specifically by MAP library? Commented Sep 21, 2011 at 4:31
  • geotools.org you can always use google maps with java . Commented Sep 21, 2011 at 4:33
  • 1
    @Hovercraft Full Of Eels I'm sorry. I wrote < String, FunctionMethod > without the space and the text processor took it as a tag :D Commented Sep 21, 2011 at 4:34
  • Are you referring to a function pointer as the value in your map? Commented Sep 21, 2011 at 4:35

3 Answers 3

3

Java does not support function pointers. A workaround is using reflection and a Map

Map<String, java.lang.reflect.Method>

and invoke mapped method.

Sign up to request clarification or add additional context in comments.

Comments

3

Another work around is to map a String to an Interface a la the command pattern

Map<String, MyInterface>

Comments

0

I am curious if you are looking for something like guava's MapMaker's makeComputingMap. It takes a (com.google.common.base.)Function that computes the value. I use it in web apps to implement lazy, cached key-value pairs. What do you mean by "FunctionMethod"?

1 Comment

Function/Method, actually. I just need to invoke a method with a given string KEY

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.