设置普通token:
packComparator.addToken(new Token(0, CompareFilter.CompareOp.EQUAL, "hello world");
设置and
packComparator.addToken(new Token(0, CompareFilter.CompareOp.LESS_OR_EQUAL, Long.MAX_VALUE - queryParam.getDatefromFormat().getTime()));
packComparator.addToken(new Token(0, CompareFilter.CompareOp.GREATER, Long.MAX_VALUE - queryParam.getDatetoFormat().getTime()));
设置or
List<Token> ipAndPortsTokens = Lists.newArrayList();
for (String ipAndPort : ipAndPorts) {
ipAndPortsTokens.add(new Token(0, CompareFilter.CompareOp.EQUAL, ipAndPort));
}
packComparator.addToken(Restrictions.or(ipAndPortsTokens));
-
List<Token> tokens
存放所有要or
的token -
Restrictions.or(ipAndPortsTokens)
token转变成一个 - 加入
packComparator
中
网友评论