“is null”过滤器vaadin

5n0oy7gb  于 2021-07-14  发布在  Java
关注(0)|答案(0)|浏览(154)

vaadin有过滤器(and、between、compare、isnull、like、not、or等)。在vaadin中是否有一个过滤器,我可以用来输出值为null的字符串。我有一个使用sql(where)条件执行数字搜索的代码,如何输出空值。p、 不按条件输入数字的字段输出所有值

public String getCondition() {
        if (currentFilter == null || currentFilter.getLines().isEmpty()) {
            return null;
        }
        List<String> lines = getSanitizedLines(currentFilter.getLines());
        if (lines.isEmpty())
            return null;

        MultiLineComponentFilter.FilterType filterType = currentFilter.getFilterType();

        Function<String, Container.Filter> map = value -> {
            String likedValue;
            String withoutNumber = "is null";
            switch (filterType) {
                case CONTAINS:
                    likedValue = "%" + value + "%";
                    break;
                case START_WITH:
                    likedValue = value + "%";
                    break;
                case END_WITH:
                    likedValue = "%" + value;
                    break;
                case EQUALS:
                    return new Compare.Equal(colName, value);
                case NOTEXIST:
                    return withoutNumber;

                default:
                    throw new UnsupportedOperationException("Unexpected filterType=" + filterType);
            }

            return new Like(colName, likedValue);
        };

        List<Container.Filter> filters = lines.stream().map(map).collect(Collectors.toList());
        return QueryBuilderExt.getPlainJoinedFilterString(filters, "or");
    }

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题