// This is java code
// it is saying comparable is a raw type, references to generic type comparable
<T> should be parameterized. I have never recieved this error before so I
don't know how to resolve the issue.
package edu.swosu.wordcraft.timers;
/** The base (and abstract) class for timer events */
public abstract class Event implements Comparable {
protected long time;
protected long delay;
/** Constructs new timer.
* This determines current system time and adds the appropriate
time based on the delay parameter.
*
* Note that this does not automatically add itself to the timer thread
*
* @param delay Delay for the timed event (in milliseconds)
*/
public Event(long delay) {
time = System.currentTimeMillis() + delay;
this.delay = delay;
}
/** Implements Comparable interface - compares value of time parameter
*
*/
public int compareTo(Object otherEvent) {
if(!(otherEvent instanceof Event)) {
//this really shouldn't happen
throw new ClassCastException("Invalid Onject during Even compare");
}
long otherTime = ((Event)otherEvent).getTime();
if (this.time > otherTime) {
return 1;
}
else {
if (this.time < otherTime) {
return -1;
}
else {
return 0;
}
}
}
public long getTime() {
return time;
}
/** method to be called when timer fires
*
*/
public abstract void execute();
}
Asked
Active
Viewed 70 times
-2
![](../../users/profiles/1103872.webp)
Marko Topolnik
- 179,046
- 25
- 276
- 399
![](../../users/profiles/3265173.webp)
user3265173
- 1
- 1
1 Answers
3
Basically, it informs you, that you have to provide the class to which the class implementing Comparable
could been compared with. In your case, if you want to compare Event
with Event
, you could simply write
implements Comparable<Event>
![](../../users/profiles/3296621.webp)
Smutje
- 16,300
- 3
- 20
- 36
-
Sorry, not intended :-) – Smutje Mar 05 '14 at 20:25
-
If I make this change though the line. public int compareTo(Object otherEvent) will then have errors. – user3265173 Mar 05 '14 at 20:42