1 |
/* WildcardType.java |
/* WildcardType.java -- A wildcard type expression e.g. ? extends String |
2 |
Copyright (C) 2004 Free Software Foundation, Inc. |
Copyright (C) 2004, 2005 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
38 |
|
|
39 |
package java.lang.reflect; |
package java.lang.reflect; |
40 |
|
|
41 |
|
/** |
42 |
|
* Represents a wildcard type expression, where the type variable |
43 |
|
* is unnamed. The simplest example of this is <code>?</code>, |
44 |
|
* which represents any unbounded type. Another example is |
45 |
|
* <code>? extends Number</code>, which specifies any type |
46 |
|
* which is a subclass of <code>Number</code> (<code>Number</code> |
47 |
|
* is the upper bound). |
48 |
|
* </p> |
49 |
|
* <p> |
50 |
|
* <code>? super String</code> gives the type a less common lower bound, |
51 |
|
* which means that the type must be either a <code>String</code> or one |
52 |
|
* of its superclasses. This can be useful in working with collections. |
53 |
|
* You may want a method to add instances of a class to a collection |
54 |
|
* with a more generic type (e.g. adding <code>String</code>s to |
55 |
|
* a list of <code>Object</code>s), but don't want to allow users |
56 |
|
* to pass in a collection with a more specific type. |
57 |
|
* </p> |
58 |
|
* |
59 |
|
* @author Tom Tromey (tromey@redhat.com) |
60 |
|
* @author Andrew John Hughes (gnu_andrew@member.fsf.org) |
61 |
|
* @since 1.5 |
62 |
|
*/ |
63 |
public interface WildcardType extends Type |
public interface WildcardType extends Type |
64 |
{ |
{ |
65 |
|
|
66 |
|
/** |
67 |
|
* <p> |
68 |
|
* Returns an array of <code>Type</code>s, which specify the |
69 |
|
* lower bounds of this type. The default lower bound is |
70 |
|
* <code>null</code>, which causes this method to return an |
71 |
|
* empty array. |
72 |
|
* </p> |
73 |
|
* <p> |
74 |
|
* In generating the array of <code>Type</code>s, each |
75 |
|
* <code>ParameterizedType</code> or <code>TypeVariable</code> is |
76 |
|
* created, (see the documentation for these classes for details of this |
77 |
|
* process), if necessary, while all other types are simply |
78 |
|
* resolved. |
79 |
|
* </p> |
80 |
|
* |
81 |
|
* @return an array of <code>Type</code> objects, representing |
82 |
|
* the wildcard type's lower bounds. |
83 |
|
* @throws TypeNotPresentException if any of the types referred to by |
84 |
|
* the lower bounds of this type do not actually exist. |
85 |
|
* @throws MalformedParameterizedTypeException if any of the types |
86 |
|
* refer to a type which can not be instantiated. |
87 |
|
*/ |
88 |
Type[] getLowerBounds(); |
Type[] getLowerBounds(); |
89 |
|
|
90 |
|
/** |
91 |
|
* <p> |
92 |
|
* Returns an array of <code>Type</code>s, which specify the |
93 |
|
* upper bounds of this type. The default upper bound is |
94 |
|
* <code>Object</code>, which causes this method to return an |
95 |
|
* array, containing just the <code>Type</code> instance for |
96 |
|
* <code>Object</code>. |
97 |
|
* </p> |
98 |
|
* <p> |
99 |
|
* In generating the array of <code>Type</code>s, each |
100 |
|
* <code>ParameterizedType</code> or <code>TypeVariable</code> is |
101 |
|
* created, (see the documentation for these classes for details of this |
102 |
|
* process), if necessary, while all other types are simply |
103 |
|
* resolved. |
104 |
|
* </p> |
105 |
|
* |
106 |
|
* @return an array of <code>Type</code> objects, representing |
107 |
|
* the wildcard type's upper bounds. |
108 |
|
* @throws TypeNotPresentException if any of the types referred to by |
109 |
|
* the upper bounds of this type do not actually exist. |
110 |
|
* @throws MalformedParameterizedTypeException if any of the types |
111 |
|
* refer to a type which can not be instantiated. |
112 |
|
*/ |
113 |
Type[] getUpperBounds(); |
Type[] getUpperBounds(); |
114 |
|
|
115 |
} |
} |