9

I put a list strings as validTypes in velocity. When I do :

#if (${validTypes}.contains("aaa"))
  // do something
#end

it throws an error. But when I do :

#foreach (${validType} in ${validTypes})
   ${validType}
#end

it works fine. Do I need to use velocity tools for this? How do I use it in an eclipse plugin? Are there any work around without using velocity tools?

fastcodejava
  • 39,895
  • 28
  • 133
  • 186

2 Answers2

21

The problem here is in curly brackets. Just use

#if (${validTypes.contains("aaa")})

or

#if ($validTypes.contains("aaa"))

instead.

serg
  • 109,619
  • 77
  • 317
  • 330
2

For those who concern, this is how to write if not,

#if (!$validTypes.contains("aaa"))
Ishan Liyanage
  • 2,237
  • 1
  • 26
  • 25