I want to create a mapping that takes a String
as the key and a primitive as the value. I was looking at the Java docs and did not see that Primitive was a class type, or that they shared some kind of wrapping class.
How can I constrain the value to be a primitive?
Map<String, Primitive> map = new HashMap<String, Primitive>();
If you need the value to be a primitive for performance reasons, you can use TObjectIntHashMap or similar.
e.g.
One difference with Map<String, Integer> is that the values are of type int primitive rather than Integer object.