Reputation: 46836
In Freemarker, I have a Map<Long, ...>
(the keys are Long
).
Freemarker's map[key]
only supports string keys. So I have tried map?api.get(0)
but that behaves like the value is not there. Yet if I do
<#list statsForThisBox as projID, val>
Project #${projID?c} has value: <b>${val???c}</b>
</#list>
Then I see that the entries are there.
Project #64256 has value: true Project #0 has value: true
Is there a way to query a Map
for a Long
key? (Other than creating a special function in Java.)
Edit: I am thinking of something like
map?api.get("java.util.Long"?new(123))
Upvotes: 0
Views: 138
Reputation: 31152
As the Map.get(Object)
signature doesn't help FreeMarker to choose the right numerical type (and because Java equals
is false
among different Number
subclasses, even if their values are really the same), you have to tell FreeMarker what type you want: map?api.get(123?long)
.
Upvotes: 1