001    package biz.hammurapi.sql.syntax;
002    
003    import java.sql.PreparedStatement;
004    import java.sql.SQLException;
005    
006    public class IsNull implements StatementFragment {
007            
008            private String columnName;
009    
010            public IsNull(String columnName) {
011                    this.columnName = columnName;
012            }
013    
014            public String toSqlString() {
015                    return columnName+" IS NULL";
016            }
017    
018            public int parameterize(PreparedStatement ps, int idx) throws SQLException {
019                    return idx;
020            }
021    
022            public int hashCode() {
023                    final int prime = 31;
024                    int result = 1;
025                    result = prime * result
026                                    + ((columnName == null) ? 0 : columnName.hashCode());
027                    return result;
028            }
029    
030            public boolean equals(Object obj) {
031                    if (this == obj)
032                            return true;
033                    if (obj == null)
034                            return false;
035                    if (getClass() != obj.getClass())
036                            return false;
037                    final IsNull other = (IsNull) obj;
038                    if (columnName == null) {
039                            if (other.columnName != null)
040                                    return false;
041                    } else if (!columnName.equals(other.columnName))
042                            return false;
043                    return true;
044            }
045    
046    }