001package com.avaje.ebean.event.readaudit;
002
003/**
004 * A SQL query and associated keys.
005 * <p>
006 * This is logged as a separate event so that the
007 * </p>
008 */
009public class ReadAuditQueryPlan {
010
011  String beanType;
012
013  String queryKey;
014
015  String sql;
016
017  /**
018   * Construct given the beanType, queryKey and sql.
019   */
020  public ReadAuditQueryPlan(String beanType, String queryKey, String sql) {
021    this.beanType = beanType;
022    this.queryKey = queryKey;
023    this.sql = sql;
024  }
025
026  /**
027   * Construct for JSON tools.
028   */
029  public ReadAuditQueryPlan() {
030  }
031
032  public String toString() {
033    return "beanType:" + beanType + " queryKey:" + queryKey + " sql:" + sql;
034  }
035
036  /**
037   * Return the bean type.
038   */
039  public String getBeanType() {
040    return beanType;
041  }
042
043  /**
044   * Set the bean type.
045   */
046  public void setBeanType(String beanType) {
047    this.beanType = beanType;
048  }
049
050  /**
051   * Return the query key (relative to the bean type).
052   */
053  public String getQueryKey() {
054    return queryKey;
055  }
056
057  /**
058   * Set the query key.
059   */
060  public void setQueryKey(String queryKey) {
061    this.queryKey = queryKey;
062  }
063
064  /**
065   * Return the sql statement.
066   */
067  public String getSql() {
068    return sql;
069  }
070
071  /**
072   * Set the sql statement.
073   */
074  public void setSql(String sql) {
075    this.sql = sql;
076  }
077
078  @Override
079  public boolean equals(Object o) {
080    if (this == o) return true;
081    if (o == null || getClass() != o.getClass()) return false;
082
083    ReadAuditQueryPlan that = (ReadAuditQueryPlan) o;
084    if (!beanType.equals(that.beanType)) return false;
085    if (!queryKey.equals(that.queryKey)) return false;
086    return sql.equals(that.sql);
087  }
088
089  @Override
090  public int hashCode() {
091    int result = beanType.hashCode();
092    result = 31 * result + queryKey.hashCode();
093    result = 31 * result + sql.hashCode();
094    return result;
095  }
096}