Frames | No Frames |
1: /* ParameterizedType.java -- Represents parameterized types e.g. List<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: * <p> 43: * Represents a type which is parameterized over one or more other 44: * types. For example, <code>List<Integer></code> is a parameterized 45: * type, with <code>List</code> parameterized over the type 46: * <code>Integer</code>. 47: * </p> 48: * <p> 49: * Instances of this classes are created as needed, during reflection. 50: * On creating a parameterized type, <code>p</code>, the 51: * <code>GenericTypeDeclaration</code> corresponding to <code>p</code> 52: * is created and resolved. Each type argument of <code>p</code> 53: * is then created recursively; details of this process are availble 54: * in the documentation of <code>TypeVariable</code>. This creation 55: * process only happens once; repetition has no effect. 56: * </p> 57: * <p> 58: * Implementors of this interface must implement an appropriate 59: * <code>equals()</code> method. This method should equate any 60: * two instances of the implementing class that have the same 61: * <code>GenericTypeDeclaration</code> and <code>Type</code> 62: * parameters. 63: * 64: * @author Tom Tromey (tromey@redhat.com) 65: * @author Andrew John Hughes (gnu_andrew@member.fsf.org) 66: * @see GenericDeclaration 67: * @see TypeVariable 68: * @since 1.5 69: */ 70: public interface ParameterizedType 71: extends Type 72: { 73: 74: /** 75: * <p> 76: * Returns an array of <code>Type</code> objects, which gives 77: * the parameters of this type. 78: * </p> 79: * <p> 80: * <strong>Note</code>: the returned array may be empty. This 81: * occurs if the supposed <code>ParameterizedType</code> is simply 82: * a normal type wrapped inside a parameterized type. 83: * </p> 84: * 85: * @return an array of <code>Type</code>s, representing the arguments 86: * of this type. 87: * @throws TypeNotPresentException if any of the types referred to by 88: * the parameters of this type do not actually exist. 89: * @throws MalformedParameterizedTypeException if any of the types 90: * refer to a type which can not be instantiated. 91: */ 92: Type[] getActualTypeArguments(); 93: 94: /** 95: * Returns the type of which this type is a member. For example, 96: * in <code>Top<String>.Bottom<Integer></code>, 97: * <code>Bottom<Integer></code> is a member of 98: * <code>Top<String></code>, and so the latter is returned 99: * by this method. Calling this method on top-level types (such as 100: * <code>Top<String></code>) returns null. 101: * 102: * @return the type which owns this type. 103: * @throws TypeNotPresentException if the owner type referred to by 104: * this type do not actually exist. 105: * @throws MalformedParameterizedTypeException if the owner type 106: * referred to by this type can not be instantiated. 107: */ 108: Type getOwnerType(); 109: 110: /** 111: * Returns a version of this type without parameters, which corresponds 112: * to the class or interface which declared the type. For example, 113: * the raw type corresponding to <code>List<Double></code> 114: * is <code>List</code>, which was declared by the <code>List</code> 115: * class. 116: * 117: * @return the raw variant of this type (i.e. the type without 118: * parameters). 119: */ 120: Type getRawType(); 121: 122: }