IsNull.java

biz/hammurapi/sql/syntax/IsNull.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 35:32
Java Inspector 082 Parenthesis are redundant. 2 26:36
Java Inspector 089 Undocumented top level type 2 6:1
Java Inspector 089 Undocumented constructor 2 10:9
Java Inspector 089 Undocumented method 2 14:9
Java Inspector 089 Undocumented method 2 18:9
Java Inspector 089 Undocumented method 2 22:9
Java Inspector 089 Undocumented method 2 30:9
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 32:25
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 34:25
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 36:25
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 40:33
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 42:25
Java Inspector 025 Avoid hardwired numeric literals. Allowed literals: [1, -1, 0] 3 23:35
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 15:35
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 10:9

Source code

1package biz.hammurapi.sql.syntax;
2
3import java.sql.PreparedStatement;
4import java.sql.SQLException;
5
6public class IsNull implements StatementFragment {
7
8 private String columnName;
9
10 public IsNull(String columnName) {
11 this.columnName = columnName;
12 }
13
14 public String toSqlString() {
15 return columnName+" IS NULL";
16 }
17
18 public int parameterize(PreparedStatement ps, int idx) throws SQLException {
19 return idx;
20 }
21
22 public int hashCode() {
23 final int prime = 31;
24 int result = 1;
25 result = prime * result
26 + ((columnName == null) ? 0 : columnName.hashCode());
27 return result;
28 }
29
30 public boolean equals(Object obj) {
31 if (this == obj)
32 return true;
33 if (obj == null)
34 return false;
35 if (getClass() != obj.getClass())
36 return false;
37 final IsNull other = (IsNull) obj;
38 if (columnName == null) {
39 if (other.columnName != null)
40 return false;
41 } else if (!columnName.equals(other.columnName))
42 return false;
43 return true;
44 }
45
46}
47