It's 5am and I'm a bit asleep, so that may be it (also I'm relatively new with Java). But I don't see why this code generates Null Exception with this code. The map should be initialized by then, shouldn't it?
private static final Map<String, Integer> CONDS_MAP =
Collections.unmodifiableMap
(
new HashMap<String, Integer>()
{{
put("null", 0);
put("false", 0);
put("true", 1);
put("numElems.lt", 2);
put("NELT", 2);
put("numElems.gt", 3);
put("NEGT", 3);
}}
);
private int getCodeInt(Object code)
{
if (code.getClass() == String.class)
{
return CONDS_MAP.get((String)code); // Null Exception here
}
else
// (... etc etc)
}
Thanks! and sorry it it is too trivial...
code.getClass() == String.classshould becode instanceof String(easier to read, faster to type, avoids possible NPE).