File: NotComparableException.java

package info (click to toggle)
rjava 1.0-11-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,184 kB
  • sloc: java: 13,223; ansic: 5,479; sh: 3,776; xml: 325; makefile: 250; perl: 33
file content (24 lines) | stat: -rw-r--r-- 725 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
 * Exception generated when two objects cannot be compared
 * 
 * Such cases happen when an object does not implement the Comparable 
 * interface or when the comparison produces a ClassCastException
 */
public class NotComparableException extends Exception{
	public NotComparableException(Object a, Object b){
		super( "objects of class " + a.getClass().getName() + 
			" and " + b.getClass().getName() + " are not comparable"  ) ;
	}
	public NotComparableException( Object o){
		this( o.getClass().getName() ) ;
	}
	
	public NotComparableException( Class cl){
		this( cl.getName() ) ;
	}
	
	public NotComparableException( String type ){
		super( "class " + type + " does not implement java.util.Comparable" ) ; 
	}
	
}