123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- package com.jtgh.yjpt.common;
- import java.util.Collection;
- /**
- * Predicate模型对象
- *
- * @author 袁晓冬
- *
- */
- public class PredicateModel {
- /**
- * 条件类型
- *
- * @author 袁晓冬
- *
- */
- public enum Operator {
- EQ, LIKE, LIKE_L, LIKE_R, GT, LT, GTE, LTE,
- /** IS NULL */
- NL,
- /** IS NOT NULL */
- NNL,
- /** not equal */
- NEQ,
- /** in,值必须是Iterable */
- IN
- }
- /**
- * 子模型连接方式
- *
- * @author 袁晓冬
- *
- */
- public enum JoinType {
- AND, OR
- }
- /** 查询字段名称 */
- private String fieldName;
- /** 查询字段值 */
- private Object value;
- /** 条件类型 */
- private Operator operator;
- /** 子模型链接方式(AND OR) */
- private JoinType joinType;
- /** 子模型集合 */
- private Collection<PredicateModel> subPms;
- /**
- * 构造无下级的模型对象
- *
- * @param fieldName
- * @param value
- * @param operator
- */
- public PredicateModel(String fieldName, Object value, Operator operator) {
- this(fieldName, value, operator, JoinType.AND);
- }
- /**
- * 构造无下级的模型对象
- *
- * @param fieldName
- * @param value
- * @param operator
- * @param type
- */
- public PredicateModel(String fieldName, Object value, Operator operator, JoinType type) {
- this.fieldName = fieldName;
- this.value = value;
- this.operator = operator;
- this.joinType = type;
- }
- /**
- * 构造带下级模型的对象,模型之间用指定的type(AND OR)连接
- *
- * @param type
- * @param subPms
- */
- public PredicateModel(JoinType type, Collection<PredicateModel> subPms) {
- this.joinType = type;
- this.subPms = subPms;
- }
- public PredicateModel() {
- }
- /**
- * 查询字段名称
- *
- * @return
- */
- public String getFieldName() {
- return fieldName;
- }
- /**
- * 条件类型
- *
- * @return
- */
- public Operator getOperator() {
- return operator;
- }
- /**
- * 子模型集合
- *
- * @return
- */
- public Collection<PredicateModel> getSubPms() {
- return subPms;
- }
- /**
- * 子模型链接方式(AND OR)
- *
- * @return
- */
- public JoinType getJoinType() {
- return joinType;
- }
- /**
- * 查询字段值
- *
- * @return
- */
- public Object getValue() {
- return value;
- }
- /**
- * 是否包含下级模型
- *
- * @return
- */
- public boolean hasSubPredicateModel() {
- return null != subPms && subPms.size() > 0;
- }
- public void setFieldName(String fieldName) {
- this.fieldName = fieldName;
- }
- public void setOperator(Operator operator) {
- this.operator = operator;
- }
- public void setSubPms(Collection<PredicateModel> subPms) {
- this.subPms = subPms;
- }
- public void setJoinType(JoinType type) {
- this.joinType = type;
- }
- public void setValue(Object value) {
- this.value = value;
- }
- }
|