summaryrefslogtreecommitdiffstats
path: root/tests/java5/generics/GenericMethods.java
blob: 78ef492127ffb9345b07afaa7a30652a28e24da1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.util.*;
/*
 * test case fodder for basic generic signature matching
 */
public class GenericMethods {
	
	public List<Integer> returningListOfInteger() { 
		return new LinkedList<Integer>(); 
	}
	
	public List<Object> returningListOfObject() {
		return new LinkedList<Object>();
	}
	
	public List returningRawList() { return new ArrayList(); }
	
	public LinkedList<Integer> returningSubtypeOfListOfInteger() {
		return new LinkedList<Integer>();
	}
	
	public void takesAMap(Map<Double,Short> aMap) {}
	
	public void takesAHashmap(HashMap<Double,Short> aMap) {}
	
	public static void staticTakesAMap(Map<Double,Short> aMap) {}
	
	public void collectionOfAnything(Collection<?> aCollection) {}
	
	public void collectionOfAnyNumber(Collection<? extends Number> aNumberCollection) {}
	
	public void collectionOfAnythingTakingADouble(Collection<? super Double> aDoubleHandlingCollection) {}
	
	// now some fun with statics
	static <T> T findMax(List<T> ts) { return ts.get(0); }
	
	static <T extends Comparable<T>> T betterMax(Collection<T> collection) {
		return null;
	}
	
	static <T extends Comparable<? super T>> T evenBetterMax(Collection<T> coll) {
		return null;
	}
	
	static <T extends Object & Comparable<? super T>> T jdkMax(Collection<? extends T> coll) {
		return null;
	}
	
	static <T> void copy(List<T> dest, List<? extends T> src) {}
	
	static <T,S extends T> copyv2(List<T> dest, List<S> src) {}
}