class DefineFunctionUtils {

    static MethodDeclaration getExpressionMethodDeclaration(final String methodName,
                                                            final Expression expression,
                                                            final DataType dataType,
                                                            final List<ParameterField> parameterFields) {
        final ClassOrInterfaceType returnedType = parseClassOrInterfaceType(getBoxedClassName(dataType));
        final LinkedHashMap<String, ClassOrInterfaceType> parameterNameTypeMap = new LinkedHashMap<>(DEFAULT_PARAMETERTYPE_MAP); // Must be an ordered Map
        parameterNameTypeMap.putAll(getNameClassOrInterfaceTypeMap(parameterFields));
        if (expression instanceof Aggregate) {
            return getAggregatedMethodDeclaration(methodName, (Aggregate) expression, returnedType,
                                                  parameterNameTypeMap);
        } else if (expression instanceof Apply) {
            return getApplyMethodDeclaration(methodName, (Apply) expression, returnedType, parameterNameTypeMap);
        } else if (expression instanceof Constant) {
            return getConstantMethodDeclaration(methodName, (Constant) expression, returnedType,
                                                parameterNameTypeMap);
        } else if (expression instanceof Discretize) {
            return getDiscretizeMethodDeclaration(methodName, (Discretize) expression, returnedType,
                                                  parameterNameTypeMap);
        } else if (expression instanceof FieldRef) {
            return getFieldRefMethodDeclaration(methodName, (FieldRef) expression, returnedType,
                                                parameterNameTypeMap);
        } else if (expression instanceof Lag) {
            return getLagMethodDeclaration(methodName, (Lag) expression, returnedType, parameterNameTypeMap);
        } else if (expression instanceof MapValues) {
            return getMapValuesMethodDeclaration(methodName, (MapValues) expression, returnedType,
                                                 parameterNameTypeMap);
        } else if (expression instanceof NormContinuous) {
            return getNormContinuousMethodDeclaration(methodName, (NormContinuous) expression, returnedType,
                                                      parameterNameTypeMap);
        } else if (expression instanceof NormDiscrete) {
            return getNormDiscreteMethodDeclaration(methodName, (NormDiscrete) expression, returnedType,
                                                    parameterNameTypeMap);
        } else if (expression instanceof TextIndex) {
            return getTextIndexMethodDeclaration(methodName, (TextIndex) expression, returnedType,
                                                 parameterNameTypeMap);
        } else {
            throw new IllegalArgumentException(String.format("Expression %s not managed", expression.getClass()));
        }
    }

    private  DefineFunctionUtils();

}