WhereCause.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /**
  2. *
  3. */
  4. package com.primeton.dsp.datarelease.api.model;
  5. import org.apache.commons.lang.builder.ToStringBuilder;
  6. /**
  7. *
  8. * SQL 的 where 条件
  9. *
  10. * @author zhaopx
  11. *
  12. */
  13. public class WhereCause {
  14. /**
  15. * 表,where 条件的表
  16. */
  17. String tableName;
  18. /**
  19. * 该字段名称
  20. */
  21. String fieldName;
  22. /**
  23. * 左表某字段大于右表某字段的条件
  24. */
  25. String toTableName;
  26. /**
  27. * 左表某字段大于右表某字段的条件
  28. */
  29. String toFieldName;
  30. /**
  31. * 数据类型:string, numeric, datetime 三种类型
  32. */
  33. String type = "string";
  34. /**
  35. * 运算逻辑: =(等于),>(大于),<(小于),>=(大于或等于),<=(小于或等于),<> or !=(不等于)
  36. */
  37. String opera = "=";
  38. /**
  39. * 取值
  40. */
  41. String value;
  42. /**
  43. * 与上一个条件的连接条件,与或。默认为 and。 and/or
  44. */
  45. String cond = "and";
  46. /**
  47. * 构造方法
  48. */
  49. public WhereCause() {
  50. }
  51. public WhereCause(String tableName, String fieldName, String value) {
  52. this.tableName = tableName;
  53. this.fieldName = fieldName;
  54. this.value = value;
  55. }
  56. public WhereCause(String tableName, String fieldName, String opera, String value) {
  57. this(tableName, fieldName, value);
  58. this.opera = opera;
  59. }
  60. public WhereCause(String tableName, String fieldName, String type, String opera, String value) {
  61. this(tableName, fieldName, value);
  62. this.type = type;
  63. this.opera = opera;
  64. }
  65. public WhereCause(String tableName, String fieldName, String type, String opera, String value, String cond) {
  66. this(tableName, fieldName, value);
  67. this.type = type;
  68. this.opera = opera;
  69. this.cond = cond;
  70. }
  71. public String getTableName() {
  72. return tableName;
  73. }
  74. public String getFieldName() {
  75. return fieldName;
  76. }
  77. public String getToTableName() {
  78. return toTableName;
  79. }
  80. public String getToFieldName() {
  81. return toFieldName;
  82. }
  83. public String getType() {
  84. return type;
  85. }
  86. public String getOpera() {
  87. return opera;
  88. }
  89. public String getValue() {
  90. return value;
  91. }
  92. public String getCond() {
  93. return cond;
  94. }
  95. public void setTableName(String tableName) {
  96. this.tableName = tableName;
  97. }
  98. public void setFieldName(String fieldName) {
  99. this.fieldName = fieldName;
  100. }
  101. public void setToTableName(String toTableName) {
  102. this.toTableName = toTableName;
  103. }
  104. public void setToFieldName(String toFieldName) {
  105. this.toFieldName = toFieldName;
  106. }
  107. public void setType(String type) {
  108. this.type = type;
  109. }
  110. public void setOpera(String opera) {
  111. this.opera = opera;
  112. }
  113. public void setValue(String value) {
  114. this.value = value;
  115. }
  116. public void setCond(String cond) {
  117. this.cond = cond;
  118. }
  119. @Override
  120. public String toString() {
  121. return ToStringBuilder.reflectionToString(this);
  122. }
  123. }