001 /* ParameterizedType.java -- Represents parameterized types e.g. List<String>
002 Copyright (C) 2004, 2005 Free Software Foundation, Inc.
003
004 This file is part of GNU Classpath.
005
006 GNU Classpath is free software; you can redistribute it and/or modify
007 it under the terms of the GNU General Public License as published by
008 the Free Software Foundation; either version 2, or (at your option)
009 any later version.
010
011 GNU Classpath is distributed in the hope that it will be useful, but
012 WITHOUT ANY WARRANTY; without even the implied warranty of
013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 General Public License for more details.
015
016 You should have received a copy of the GNU General Public License
017 along with GNU Classpath; see the file COPYING. If not, write to the
018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
019 02110-1301 USA.
020
021 Linking this library statically or dynamically with other modules is
022 making a combined work based on this library. Thus, the terms and
023 conditions of the GNU General Public License cover the whole
024 combination.
025
026 As a special exception, the copyright holders of this library give you
027 permission to link this library with independent modules to produce an
028 executable, regardless of the license terms of these independent
029 modules, and to copy and distribute the resulting executable under
030 terms of your choice, provided that you also meet, for each linked
031 independent module, the terms and conditions of the license of that
032 module. An independent module is a module which is not derived from
033 or based on this library. If you modify this library, you may extend
034 this exception to your version of the library, but you are not
035 obligated to do so. If you do not wish to do so, delete this
036 exception statement from your version. */
037
038
039 package java.lang.reflect;
040
041 /**
042 * <p>
043 * Represents a type which is parameterized over one or more other
044 * types. For example, <code>List<Integer></code> is a parameterized
045 * type, with <code>List</code> parameterized over the type
046 * <code>Integer</code>.
047 * </p>
048 * <p>
049 * Instances of this classes are created as needed, during reflection.
050 * On creating a parameterized type, <code>p</code>, the
051 * <code>GenericTypeDeclaration</code> corresponding to <code>p</code>
052 * is created and resolved. Each type argument of <code>p</code>
053 * is then created recursively; details of this process are availble
054 * in the documentation of <code>TypeVariable</code>. This creation
055 * process only happens once; repetition has no effect.
056 * </p>
057 * <p>
058 * Implementors of this interface must implement an appropriate
059 * <code>equals()</code> method. This method should equate any
060 * two instances of the implementing class that have the same
061 * <code>GenericTypeDeclaration</code> and <code>Type</code>
062 * parameters.
063 *
064 * @author Tom Tromey (tromey@redhat.com)
065 * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
066 * @see GenericDeclaration
067 * @see TypeVariable
068 * @since 1.5
069 */
070 public interface ParameterizedType
071 extends Type
072 {
073
074 /**
075 * <p>
076 * Returns an array of <code>Type</code> objects, which gives
077 * the parameters of this type.
078 * </p>
079 * <p>
080 * <strong>Note</code>: the returned array may be empty. This
081 * occurs if the supposed <code>ParameterizedType</code> is simply
082 * a normal type wrapped inside a parameterized type.
083 * </p>
084 *
085 * @return an array of <code>Type</code>s, representing the arguments
086 * of this type.
087 * @throws TypeNotPresentException if any of the types referred to by
088 * the parameters of this type do not actually exist.
089 * @throws MalformedParameterizedTypeException if any of the types
090 * refer to a type which can not be instantiated.
091 */
092 Type[] getActualTypeArguments();
093
094 /**
095 * Returns the type of which this type is a member. For example,
096 * in <code>Top<String>.Bottom<Integer></code>,
097 * <code>Bottom<Integer></code> is a member of
098 * <code>Top<String></code>, and so the latter is returned
099 * 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 }