可重用条件/表达式类

编程入门 行业动态 更新时间:2024-10-23 13:29:47
本文介绍了可重用条件/表达式类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有几个需要一些类来表示和操纵条件(通常在UI中,因此用户通过组合不同的条件类型构建查询,然后代码可以根据要查询的底层系统进行转换,例如lucene和db)。我搜索了一整套可重用的课程,我相信这必须在许多现有的地方(所有表达语言为起始者)使用,但找不到任何容易使用的东西。我最终自己编写了这两个时代,但对不重复使用我确信存在的东西感到很不好。

I have needed in several occasions some classes to represent and manipulate conditions (typically in a UI so the user builds a query by combining different condition types and then the code can transform that depending on the underlying system to be queried, for example lucene and a db). I searched all over for a reusable set of classes, I am sure this has to be used in many existing places (all the expression languages for starters) but could not find anything easily usable. I ended up coding both times myself, but felt bad about not reusing something I am sure exists.

典型需求是: - 几个运算符:和/或 - 可变数量的操作数 - 组合条件来构建表达式 - 表达式的序列化 - 从/到字符串的解析/格式化表达式

Typical needs are: - several operators: and or etc - variable number of operands - combining conditions to build expressions - serializing of expressions - parsing/formatting of expressions from/to strings

有人找到这样的东西?

推荐答案

看看 Apache Commons Functor 。例如。 UnaryPredicate , UnaryAnd , UnaryOr 等等在实现是可序列化,但我不知道从字符串解析。不过,我认为这是一个非常好的开始。另外,请查看本IBM教程,基于图书馆。

Take a look at Apache Commons Functor. E.g. UnaryPredicate, UnaryAnd, UnaryOr, etc. The built-in implementations are Serializable, but I don't know about parsing from strings. Still, I think it's a very good start towards what you want. Also, take a look at this IBM tutorial based on the library.

更多推荐

可重用条件/表达式类

本文发布于:2023-11-29 23:17:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1647931.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表达式   条件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!