Frames | No Frames |
1: /* WildcardType.java -- A wildcard type expression e.g. ? extends String 2: Copyright (C) 2004, 2005 Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 6: GNU Classpath is free software; you can redistribute it and/or modify 7: it under the terms of the GNU General Public License as published by 8: the Free Software Foundation; either version 2, or (at your option) 9: any later version. 10: 11: GNU Classpath is distributed in the hope that it will be useful, but 12: WITHOUT ANY WARRANTY; without even the implied warranty of 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14: General Public License for more details. 15: 16: You should have received a copy of the GNU General Public License 17: along with GNU Classpath; see the file COPYING. If not, write to the 18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19: 02110-1301 USA. 20: 21: Linking this library statically or dynamically with other modules is 22: making a combined work based on this library. Thus, the terms and 23: conditions of the GNU General Public License cover the whole 24: combination. 25: 26: As a special exception, the copyright holders of this library give you 27: permission to link this library with independent modules to produce an 28: executable, regardless of the license terms of these independent 29: modules, and to copy and distribute the resulting executable under 30: terms of your choice, provided that you also meet, for each linked 31: independent module, the terms and conditions of the license of that 32: module. An independent module is a module which is not derived from 33: or based on this library. If you modify this library, you may extend 34: this exception to your version of the library, but you are not 35: obligated to do so. If you do not wish to do so, delete this 36: exception statement from your version. */ 37: 38: 39: 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 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(); 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(); 114: 115: }