protected Object execute(Object[] obj, State state) {
        Object data = obj[0];
        if (data != null) {
            try {
                switch (returnType) {
                    case STRING:
                        if (inputType == Attribute.Type.OBJECT) {
                            if (data instanceof Throwable) {
                                String message = "message : " + ((Throwable) data).getMessage();
                                String cause = "\n cause :" + ((Throwable) data).getCause();
                                return message + cause;
                            } else if (data instanceof Object[]) {
                                return Arrays.deepToString((Object[]) data);
                            }
                            return data.toString();
                        }
                        return data.toString();
                    case INT:
                        switch (inputType) {
                            case STRING:
                                return Integer.parseInt((String) data);
                            case INT:
                                return data;
                            case LONG:
                                return ((Long) data).intValue();
                            case FLOAT:
                                return ((Float) data).intValue();
                            case DOUBLE:
                                return ((Double) data).intValue();
                            case BOOL:
                                return ((Boolean) data) ? 1 : 0;
                            case OBJECT:
                                return null;
                        }
                        break;
                    case LONG:
                        switch (inputType) {
                            case STRING:
                                return Long.parseLong((String) data);
                            case INT:
                                return ((Integer) data).longValue();
                            case LONG:
                                return data;
                            case FLOAT:
                                return ((Float) data).longValue();
                            case DOUBLE:
                                return ((Double) data).longValue();
                            case BOOL:
                                return ((Boolean) data) ? 1L : 0L;
                            case OBJECT:
                                return null;
                        }
                        break;
                    case FLOAT:
                        switch (inputType) {
                            case STRING:
                                return Float.parseFloat((String) data);
                            case INT:
                                return ((Integer) data).floatValue();
                            case LONG:
                                return ((Long) data).floatValue();
                            case FLOAT:
                                return data;
                            case DOUBLE:
                                return ((Double) data).floatValue();
                            case BOOL:
                                return ((Boolean) data) ? 1F : 0F;
                            case OBJECT:
                                return null;
                        }
                        break;
                    case DOUBLE:
                        switch (inputType) {
                            case STRING:
                                return Double.parseDouble((String) data);
                            case INT:
                                return ((Integer) data).doubleValue();
                            case LONG:
                                return ((Long) data).doubleValue();
                            case FLOAT:
                                return ((Float) data).doubleValue();
                            case DOUBLE:
                                return data;
                            case BOOL:
                                return ((Boolean) data) ? 1.0 : 0.0;
                            case OBJECT:
                                return null;
                        }
                        break;
                    case BOOL:
                        switch (inputType) {
                            case STRING:
                                return Boolean.parseBoolean((String) data);
                            case INT:
                                return ((Integer) data) == 1;
                            case LONG:
                                return ((Long) data) == 1L;
                            case FLOAT:
                                return ((Float) data) == 1F;
                            case DOUBLE:
                                return ((Double) data) == 1.0;
                            case BOOL:
                                return data;
                            case OBJECT:
                                return null;
                        }
                        break;
                    case OBJECT:
                        break;
                }
            } catch (NumberFormatException e) {
                return null;
            }
        }
        return null;
    }
Executor class for convert function. Function execution logic is implemented in execute here.
modules/siddhi-core/src/main/java/io/siddhi/core/executor/function/ConvertFunctionExecutor.java