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