Following up some more:
Comparing the performance of these options depends on a number of variables, especially: how many choices are there, and are the numeric values of the coices close together, or widely spaced? Most statements about speed which we might make here can turn out to be false in some other circumstances. However, in general, for a large number of options, if/elseif is pretty bad. A hashmap is usually much better, but a switch statement can often be faster yet (especially if the options are closely-spaced). However the fastest option may be to use an array instead:
In some cases you can speed this further. If you are certain that this method is never called with an out-of-range value or a value for which h is null, you can skip those checks. This
may well be the best option for you - I'd say it's worth a try.
Now if the number of choices is very
small, the performance of a HashMap and the array solutions will probably remain exactly the same as above, but the if-else will get much better,
maybe enough to justify using it. And the performance of the switch statement may improve, if the values are widely spaced. So for a very small number of choices, HashMap becomes the worst choice, and the other three are pretty close to each other. (Well, if/elseif doesn't become competitive until the nubmer of choices is two or maybe three.)
One minor advantage that the switch and (to a lesser extent) if/elseif have is that it's possible to in-line the method calls, manually or just letting the JVM do it. (I recommend the latter, as the JVM usually does a more reliable job.) In some situations this may be enough to make switch faster than an array.
With all of this, you really need to
test the options yourself to find out for sure. And be aware that a different JVM on a different machine may give different results. However, for what you've described, I'm guessing best options are either a switch statement or an array.