class FilterUtils {

    public static IFilter merge(IFilter filter) throws EmptyResultFilterException {
        if (filter == null || filter instanceof IBooleanFilter) {
            return filter;
        }
        // 先转为DNF结构
        filter = toDNFAndFlat(filter);
        List<List<IFilter>> DNFNodes = toDNFNodesArray(filter);
        if (!needToMerge(DNFNodes)) {
            return filter;
        }

        DNFNodes = mergeOrDNFNodes(mergeAndDNFNodesArray(DNFNodes));
        if (DNFNodes == null || DNFNodes.isEmpty() || DNFNodes.get(0) == null || DNFNodes.get(0).isEmpty()
            || DNFNodes.get(0).get(0) == null) {
            // 返回常量true
            IBooleanFilter f = ASTNodeFactory.getInstance().createBooleanFilter();
            f.setOperation(OPERATION.CONSTANT);
            f.setColumn("1");
            f.setColumnName(ObjectUtils.toString("1"));
            return f;
        } else {
            return DNFToOrLogicTree(DNFNodes);
        }
    }

}