@Override
    protected StateFactory init(ExpressionExecutor[] attributeExpressionExecutors,
                                ConfigReader configReader, SiddhiQueryContext siddhiQueryContext) {
        if (attributeExpressionExecutors.length != 2) {
            // check whether all the arguments passed
            throw new SiddhiAppValidationException("Invalid no of parameters passed to default() function, " +
                    "it require only 2 (attribute, default value) , "
                    + "but found "
                    + attributeExpressionExecutors.length);
        } else if (!(attributeExpressionExecutors[1] instanceof ConstantExpressionExecutor)) {
            throw new SiddhiAppValidationException("Invalid parameter passed to default() function, " +
                    "this only consumes constants, but found "
                    + attributeExpressionExecutors[1].getClass().getName());

        } else if ((attributeExpressionExecutors[0].getReturnType() != attributeExpressionExecutors[1]
                .getReturnType())) {
            throw new SiddhiAppValidationException("Both attribute and default value parameters need to be of "
                    + "same return type but they are of " +
                    attributeExpressionExecutors[0].getReturnType() + "and" +
                    attributeExpressionExecutors[1].getReturnType());
        }
        returnType = attributeExpressionExecutors[0].getReturnType();
        return null;
    }
Executor class for default function. Function execution sets the default value assigned by the user when attribute
value is null.
modules/siddhi-core/src/main/java/io/siddhi/core/executor/function/DefaultFunctionExecutor.java