001/* ParameterizedType.java -- Represents parameterized types e.g. List<String>
002   Copyright (C) 2004, 2005 Free Software Foundation, Inc.
003
004This file is part of GNU Classpath.
005
006GNU Classpath is free software; you can redistribute it and/or modify
007it under the terms of the GNU General Public License as published by
008the Free Software Foundation; either version 2, or (at your option)
009any later version.
010
011GNU Classpath is distributed in the hope that it will be useful, but
012WITHOUT ANY WARRANTY; without even the implied warranty of
013MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014General Public License for more details.
015
016You should have received a copy of the GNU General Public License
017along with GNU Classpath; see the file COPYING.  If not, write to the
018Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
01902110-1301 USA.
020
021Linking this library statically or dynamically with other modules is
022making a combined work based on this library.  Thus, the terms and
023conditions of the GNU General Public License cover the whole
024combination.
025
026As a special exception, the copyright holders of this library give you
027permission to link this library with independent modules to produce an
028executable, regardless of the license terms of these independent
029modules, and to copy and distribute the resulting executable under
030terms of your choice, provided that you also meet, for each linked
031independent module, the terms and conditions of the license of that
032module.  An independent module is a module which is not derived from
033or based on this library.  If you modify this library, you may extend
034this exception to your version of the library, but you are not
035obligated to do so.  If you do not wish to do so, delete this
036exception statement from your version. */
037
038
039package 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&lt;Integer&gt;</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 */
070public 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&lt;String&gt;.Bottom&lt;Integer&gt;</code>,
097   * <code>Bottom&lt;Integer&gt;</code> is a member of
098   * <code>Top&lt;String&gt;</code>, and so the latter is returned
099   * by this method.  Calling this method on top-level types (such as
100   * <code>Top&lt;String&gt;</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&lt;Double&gt;</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}