我有一个由{2}其他类扩展的Filters
类
public class Filters {
}
public class SimpleFilter extends Filters {
FilterAttribute A;
FilterOperator op;
String value;
}
public class ComplexFilter extends Filters {
Filters filterA;
Filters filterB;
Conjunction c;
}
我有一个字符串:
String filters = "(((CreationT>1234)and(LastM<567))or(LastM<=8910))";
我需要将此字符串解析为ComplexFilter
。其中ComplexFilter
为"((creationT>1234)and(LastM<567))/*This complex filter has 2 simple filters and conjunction 'and'*/"
,"(LastM<=8910)"
为简单过滤,or
为
这样做的最佳方法是什么?从几个小时就坚持了下来。