001 /**
002 * Copyright 2007 Mike Kroutikov.
003 *
004 * This program is free software; you can redistribute it and/or modify
005 * it under the terms of the Lesser GNU General Public License as
006 * published by the Free Software Foundation; either version 3 of
007 * the License, or (at your option) any later version.
008 *
009 * This program is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012 * Lesser GNU General Public License for more details.
013 *
014 * You should have received a copy of the Lesser GNU General Public License
015 * along with this program. If not, see <http://www.gnu.org/licenses/>.
016 *
017 * Derived from code developed by Opentick Corporation, http://www.opentick.com.
018 */
019
020 package org.otfeed.event;
021
022 import static org.otfeed.event.IdentityUtil.equalsTo;
023 import static org.otfeed.event.IdentityUtil.safeCompare;
024 import static org.otfeed.event.IdentityUtil.safeHashCode;
025
026 import java.io.Serializable;
027 import java.util.Date;
028
029 /**
030 * Clear all orders for the ECN.
031 */
032 public final class OTBookPurge implements Comparable<OTBookPurge>, Serializable {
033
034 private static final long serialVersionUID = 5257014452539624594L;
035
036 private Date timestamp;
037 private String nameRoot;
038
039 /**
040 * Default constructor.
041 */
042 public OTBookPurge() { }
043
044 /**
045 * Constructor.
046 * @param timestamp Time when the event occurred.
047 * @param nameRoot ECN name root.
048 */
049 public OTBookPurge(Date timestamp, String nameRoot) {
050 this.timestamp = timestamp;
051 this.nameRoot = nameRoot;
052 }
053
054 /**
055 *
056 * @return Time when the event occurred.
057 */
058 public Date getTimestamp() {
059 return timestamp;
060 }
061
062 /**
063 * Sets time of the event.
064 * @param timestamp Time when the event occurred.
065 */
066 public void setTimestamp(Date timestamp) {
067 this.timestamp = timestamp;
068 }
069
070 /**
071 *
072 * @return ECN name root.
073 */
074 public String getExchangeNameRoot() {
075 return nameRoot;
076 }
077
078 /**
079 * Sets ECN name root.
080 * @param nameRoot ECN name root.
081 */
082 public void setExchangeNameRoot(String nameRoot) {
083 this.nameRoot = nameRoot;
084 }
085
086 @Override
087 public String toString() {
088 return "OTBookPurge: timestamp=" + timestamp + ", exchangenamebase=" + nameRoot;
089
090 }
091
092 @Override
093 public int hashCode() {
094 return safeHashCode(timestamp)
095 + 3 * safeHashCode(nameRoot);
096 }
097
098 @Override
099 public boolean equals(Object o) {
100 return equalsTo(this, o);
101 }
102
103 public int compareTo(OTBookPurge other) {
104 int rc;
105
106 if((rc = safeCompare(timestamp, other.timestamp)) != 0) {
107 return rc;
108 }
109
110 if((rc = safeCompare(nameRoot, other.nameRoot)) != 0) {
111 return rc;
112 }
113
114 return 0;
115 }
116 }