This works for me:
#set ($firstName = ${lead.FirstName})
#if ($firstName == "")
#set($temp1 = "Hello,")
#elseif ($firstName.contains(" "))
#set($temp1 = "Hello,")
#elseif ($firstName.length() == 1)
#set($temp1 = "Hello,")
#else
#set($temp1 = "Hello " + $firstName + ",")
#end
${temp1}