Java tutorial
/* * SpiderDB - Lightweight Database Schema Crawler * Copyright (c) 2010, Avdhesh yadav. * Contact: avdhesh.yadav@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.avdheshyadav.spiderdb.dbmodel; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.CompareToBuilder; /** * * @author Avdhesh Yadav * */ public class Trigger implements Comparable<Trigger> { /** */ private String name; /** */ private String table; /** */ private String schema; /** */ private String catalog; /** */ private String condition; /** */ private String statement; /** */ private int actionOrder; /** */ private TriggerActionType actionType; /** */ private String conditionTiming; /** */ private TriggerEventType eventType; public Trigger(String name, String table, String schema, String catalog, String condition, String statement, int actionOrder, TriggerActionType actionType, String conditionTiming, TriggerEventType eventType) { this.name = name; this.table = table; this.schema = schema; this.catalog = catalog; this.condition = condition; this.statement = statement; this.actionOrder = actionOrder; this.actionType = actionType; this.conditionTiming = conditionTiming; this.eventType = eventType; } /** * * @return String */ public String getTriggerName() { return name; } /** * * @return String */ public String getTableName() { return table; } /** * * @return String */ public String getSchemaName() { return schema; } /** * * @return String */ public String getCatalogName() { return catalog; } /** * * @return String */ public String getCondition() { return condition; } /** * * @return String */ public String getActionStatement() { return statement; } /** * * @return int */ public int getActionOrder() { return actionOrder; } /** * * @return TriggerActionType */ public TriggerActionType getActionType() { return actionType; } /** * * @return String */ public String getConditionTiming() { return conditionTiming; } /** * * @return TriggerEventType */ public TriggerEventType getEventType() { return eventType; } /** * */ public int compareTo(final Trigger other) { return new CompareToBuilder().append(name, other.name).append(table, other.table) .append(schema, other.schema).append(catalog, other.catalog).append(condition, other.condition) .append(statement, other.statement).append(actionOrder, other.actionOrder) .append(actionType, other.actionType).append(conditionTiming, other.conditionTiming) .append(eventType, other.eventType).toComparison(); } @Override public boolean equals(final Object other) { if (this == other) return true; if (other == null) return false; if (!(other instanceof Trigger)) return false; Trigger castOther = (Trigger) other; return new EqualsBuilder().append(name, castOther.name).append(table, castOther.table) .append(schema, castOther.schema).append(catalog, castOther.catalog) .append(condition, castOther.condition).append(statement, castOther.statement) .append(actionOrder, castOther.actionOrder).append(actionType, castOther.actionType) .append(conditionTiming, castOther.conditionTiming).append(eventType, castOther.eventType) .isEquals(); } @Override public int hashCode() { return new HashCodeBuilder().append(name).append(table).append(schema).append(catalog).append(condition) .append(statement).append(actionOrder).append(actionType).append(conditionTiming).append(eventType) .toHashCode(); } @Override public String toString() { return "Trigger [name=" + name + ", table=" + table + ", schema=" + schema + ", catalog=" + catalog + ", condition=" + condition + ", statement=" + statement + ", actionOrder=" + actionOrder + ", actionType=" + actionType + ", conditionTiming=" + conditionTiming + ", eventType=" + eventType + "]"; } }