00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 package com.realtime.crossfire.jxclient.timeouts;
00023
00024 import org.jetbrains.annotations.NotNull;
00025 import org.jetbrains.annotations.Nullable;
00026
00031 public class Event implements Comparable<Event> {
00032
00037 private final long timeout;
00038
00042 @NotNull
00043 private final TimeoutEvent timeoutEvent;
00044
00050 public Event(final int timeout, @NotNull final TimeoutEvent timeoutEvent) {
00051 this.timeout = System.currentTimeMillis()+timeout;
00052 this.timeoutEvent = timeoutEvent;
00053 }
00054
00059 public long getTimeout() {
00060 return timeout;
00061 }
00062
00067 @NotNull
00068 public TimeoutEvent getTimeoutEvent() {
00069 return timeoutEvent;
00070 }
00071
00075 @Override
00076 public int compareTo(@NotNull final Event o) {
00077 if (timeout < o.timeout) {
00078 return -1;
00079 }
00080 if (timeout > o.timeout) {
00081 return +1;
00082 }
00083 return 0;
00084 }
00085
00089 @Override
00090 public int hashCode() {
00091 return (int)timeout;
00092 }
00093
00097 @Override
00098 public boolean equals(@Nullable final Object obj) {
00099 if (obj == null) {
00100 return false;
00101 }
00102 if (obj.getClass() != getClass()) {
00103 return false;
00104 }
00105 final Event m = (Event)obj;
00106 return m.timeout == timeout;
00107 }
00108
00109 }