mirror of
https://github.com/corda/corda.git
synced 2025-06-14 05:08:18 +00:00
throw ClassCastException if asked to compare Enums of different types
This commit is contained in:
@ -22,6 +22,10 @@ public abstract class Enum<E extends Enum<E>> implements Comparable<E> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo(E other) {
|
public int compareTo(E other) {
|
||||||
|
if (getDeclaringClass() != other.getDeclaringClass()) {
|
||||||
|
throw new ClassCastException();
|
||||||
|
}
|
||||||
|
|
||||||
return ordinal - other.ordinal;
|
return ordinal - other.ordinal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user