GreaterThan.java

biz/hammurapi/sql/syntax/GreaterThan.java

Violations

Inspector Message Severity Location
Java Inspector 048 Copyrights information should be present in each file. 1
Java Inspector 086 Use equals() instead of == or != to compare objects. 1 96:32
Java Inspector 082 Parenthesis are redundant. 2 86:36
Java Inspector 082 Parenthesis are redundant. 2 87:44
Java Inspector 089 Type documentation is too short. It is only 2 words. Should be at least 3 words. 2 14:1
Java Inspector 089 Undocumented constructor 2 19:9
Java Inspector 089 Undocumented constructor 2 24:9
Java Inspector 089 Undocumented constructor 2 29:9
Java Inspector 089 Undocumented constructor 2 34:9
Java Inspector 089 Undocumented constructor 2 39:9
Java Inspector 089 Undocumented constructor 2 44:9
Java Inspector 089 Undocumented constructor 2 49:9
Java Inspector 089 Undocumented constructor 2 54:9
Java Inspector 089 Undocumented constructor 2 59:9
Java Inspector 089 Undocumented constructor 2 64:9
Java Inspector 089 Undocumented constructor 2 69:9
Java Inspector 089 Undocumented method 2 74:9
Java Inspector 089 Undocumented method 2 78:9
Java Inspector 089 Undocumented method 2 82:9
Java Inspector 089 Undocumented method 2 91:9
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 93:25
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 95:25
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 97:25
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 101:33
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 103:25
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 106:33
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 108:25
Java Inspector 025 Avoid hardwired numeric literals. Allowed literals: [1, -1, 0] 3 83:35
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 75:37
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 19:9
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 24:9
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 29:9
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 34:9
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 39:9
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 44:9
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 49:9
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 54:9
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 59:9
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 64:9
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 69:9

Source code

1package biz.hammurapi.sql.syntax;
2
3import java.io.Serializable;
4import java.sql.PreparedStatement;
5import java.sql.SQLException;
6
7import biz.hammurapi.sql.Variant;
8
9/**
10 * Greater than
11 * @author Pavel
12 *
13 */
14public class GreaterThan implements StatementFragment, Serializable {
15
16 private Variant variant;
17 private String columnName;
18
19 public GreaterThan(String columnName, boolean value) {
20 variant = new Variant(value);
21 this.columnName = columnName;
22 }
23
24 public GreaterThan(String columnName, byte value) {
25 variant = new Variant(value);
26 this.columnName = columnName;
27 }
28
29 public GreaterThan(String columnName, char value) {
30 variant = new Variant(value);
31 this.columnName = columnName;
32 }
33
34 public GreaterThan(String columnName, double value) {
35 variant = new Variant(value);
36 this.columnName = columnName;
37 }
38
39 public GreaterThan(String columnName, float value) {
40 variant = new Variant(value);
41 this.columnName = columnName;
42 }
43
44 public GreaterThan(String columnName, int value) {
45 variant = new Variant(value);
46 this.columnName = columnName;
47 }
48
49 public GreaterThan(String columnName, long value) {
50 variant = new Variant(value);
51 this.columnName = columnName;
52 }
53
54 public GreaterThan(String columnName, String value) {
55 variant = new Variant(value);
56 this.columnName = columnName;
57 }
58
59 public GreaterThan(String columnName, Object value) {
60 variant = new Variant(value);
61 this.columnName = columnName;
62 }
63
64 public GreaterThan(String columnName, Object value, int sqlType) {
65 variant = new Variant(value, sqlType);
66 this.columnName = columnName;
67 }
68
69 public GreaterThan(String columnName, short value) {
70 variant = new Variant(value);
71 this.columnName = columnName;
72 }
73
74 public String toSqlString() {
75 return columnName + ">?";
76 }
77
78 public int parameterize(PreparedStatement ps, int idx) throws SQLException {
79 return variant.parameterize(ps, idx);
80 }
81
82 public int hashCode() {
83 final int prime = 31;
84 int result = 1;
85 result = prime * result
86 + ((columnName == null) ? 0 : columnName.hashCode());
87 result = prime * result + ((variant == null) ? 0 : variant.hashCode());
88 return result;
89 }
90
91 public boolean equals(Object obj) {
92 if (this == obj)
93 return true;
94 if (obj == null)
95 return false;
96 if (getClass() != obj.getClass())
97 return false;
98 final GreaterThan other = (GreaterThan) obj;
99 if (columnName == null) {
100 if (other.columnName != null)
101 return false;
102 } else if (!columnName.equals(other.columnName))
103 return false;
104 if (variant == null) {
105 if (other.variant != null)
106 return false;
107 } else if (!variant.equals(other.variant))
108 return false;
109 return true;
110 }
111
112}
113