@Override
    protected StateFactory init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader,
                                SiddhiQueryContext siddhiQueryContext) {
        if (attributeExpressionExecutors.length != 2) {
            throw new SiddhiAppValidationException("Invalid no of arguments passed to common:cast() function, " +
                    "required 2 parameters, but found " +
                    attributeExpressionExecutors.length);
        }
        if (!(attributeExpressionExecutors[1] instanceof ConstantExpressionExecutor)) {
            throw new SiddhiAppValidationException("The second argument has to be a string constant specifying " +
                    "one of the supported data types "
                    + "(int, long, float, double, string, bool)");
        } else {
            String type = attributeExpressionExecutors[1].execute(null).toString();
            if (type.toLowerCase().equals("int")) {
                returnType = Attribute.Type.INT;
            } else if (type.toLowerCase().equals("long")) {
                returnType = Attribute.Type.LONG;
            } else if (type.toLowerCase().equals("float")) {
                returnType = Attribute.Type.FLOAT;
            } else if (type.toLowerCase().equals("double")) {
                returnType = Attribute.Type.DOUBLE;
            } else if (type.toLowerCase().equals("bool")) {
                returnType = Attribute.Type.BOOL;
            } else if (type.toLowerCase().equals("string")) {
                returnType = Attribute.Type.STRING;
            } else {
                throw new SiddhiAppValidationException("Type must be one of int, long, float, double, bool, " +
                        "string");
            }
        }
        return null;
    }
Executor class for Siddhi cast function. Converts the given parameter according to the castTo parameter.
Incompatible arguments cause {@link ClassCastException} if further processed.
modules/siddhi-core/src/main/java/io/siddhi/core/executor/function/CastFunctionExecutor.java