/**
 *
 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either 
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public 
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 * 
 **/
/**
 * Implements the CFML Function iscustomfunction
 */
package lucee.runtime.functions.decision;

import lucee.runtime.PageContext;
import lucee.runtime.ext.function.Function;
import lucee.runtime.op.Decision;
import lucee.runtime.type.ObjectWrap;

public final class IsCustomFunction implements Function {

	private static final long serialVersionUID = 1578909692090122692L;

	public static boolean call(PageContext pc , Object object) {
		if(object instanceof ObjectWrap) {
        	return call(pc,((ObjectWrap)object).getEmbededObject(null));
        }
		return Decision.isUserDefinedFunction(object) && !Decision.isClosure(object);
	}
}
@@ -869,27 +869,109 @@
 cee.
-runtime.PageContext
+commons.lang.StringUtil;%0Aimport lucee.runtime.PageContext;%0Aimport lucee.runtime.exp.FunctionException
 ;%0Aim
@@ -1272,16 +1272,177 @@
  object)
+ throws FunctionException %7B%0A%09%09return call(pc,object,null);%0A%09%7D%0A%09%0A%09public static boolean call(PageContext pc , Object object, String type) throws FunctionException
  %7B%0A%09%09if(
@@ -1473,24 +1473,18 @@
 Wrap) %7B%0A
-        
+%09%09
 %09return 
@@ -1538,100 +1538,586 @@
 ull)
-);%0A        %7D%0A%09%09return Decision.isUserDefinedFunction(object) && !Decision.isClosure(object);
+,type);%0A%09%09%7D%0A%09%09if(!Decision.isUserDefinedFunction(object)) return false;%0A%09%09%0A%09%09if(StringUtil.isEmpty(type,true)) return true;%0A%09%09%0A%09%09// check type%0A%09%09type=type.trim();%0A%09%09if(%22closure%22.equalsIgnoreCase(type)) return Decision.isClosure(object);%0A%09%09if(%22lambda%22.equalsIgnoreCase(type)) return Decision.isLambda(object);%0A%09%09if(%22udf%22.equalsIgnoreCase(type)) return !Decision.isLambda(object) && !Decision.isClosure(object);%0A%09%09%0A%09%09throw new FunctionException(pc, %22IsCustomFunction%22, 2, %22type%22, %22function type %5B%22+type+%22%5D is invalid, only the following values are valid %5Bclosure,lambda,udf%5D%22);%0A%09%09
 %0A%09%7D%0A

improve testcase for function IsCustomFunction