private void appendListenerHandler(final CharSequence handler, final JSONObject attributesJson,
final String propertyName, final String functionTemplate) throws JSONException
{
if (Strings.isEmpty(handler) == false)
{
final JsonFunction function;
if (handler instanceof JsonFunction)
{
function = (JsonFunction)handler;
}
else
{
String func = String.format(functionTemplate, handler);
function = new JsonFunction(func);
}
attributesJson.append(propertyName, function);
}
}