mvel equals operator doesn't work as expected with char operand

1.3k views Asked by At

Is mvel equals operator doesn't work as expected with char operand or am I missing something?
It throws NumberFormatException: For input string: "E" I would expect false in system output.
Is there any 'configuration option' for MVEL that fits here? Or any idea how to make lovely workaround?
Please note, I can't change parameters as they are composed at runtime.

    System.out.println(MVEL.eval("arg1 == arg2", new HashMap<String, Object>() {{
        put("arg1", "5");
        put("arg2", 'E');
    }}));
2

There are 2 answers

0
Mike On

It works as expected with String operand, so the best workaround I came up with is this

arg1 == arg2.toString()
1
Dave Newton On

You're adding E as a character, not a string. If you want it as a string then make it a string. They're not even the same type, let alone the same value.