Not.java

biz/hammurapi/sql/syntax/Not.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 36:32
Java Inspector 082 Parenthesis are redundant. 2 27:36
Java Inspector 089 Undocumented top level type 2 7:1
Java Inspector 089 Undocumented constructor 2 11:9
Java Inspector 089 Undocumented method 2 15:9
Java Inspector 089 Undocumented method 2 19:9
Java Inspector 089 Undocumented method 2 23:9
Java Inspector 089 Undocumented method 2 31:9
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 33:25
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 35:25
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 37:25
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 41:33
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 43:25
Java Inspector 025 Avoid hardwired numeric literals. Allowed literals: [1, -1, 0] 3 24:35
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 20:24
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 11:9

Source code

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