001/* WildcardType.java -- A wildcard type expression e.g. ? extends 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 * Represents a wildcard type expression, where the type variable
043 * is unnamed.  The simplest example of this is <code>?</code>,
044 * which represents any unbounded type.  Another example is
045 * <code>? extends Number</code>, which specifies any type
046 * which is a subclass of <code>Number</code> (<code>Number</code>
047 * is the upper bound).
048 * </p>
049 * <p>
050 * <code>? super String</code> gives the type a less common lower bound,
051 * which means that the type must be either a <code>String</code> or one
052 * of its superclasses. This can be useful in working with collections.
053 * You may want a method to add instances of a class to a collection
054 * with a more generic type (e.g. adding <code>String</code>s to
055 * a list of <code>Object</code>s), but don't want to allow users
056 * to pass in a collection with a more specific type.
057 * </p>
058 *
059 * @author Tom Tromey (tromey@redhat.com)
060 * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
061 * @since 1.5
062 */
063public interface WildcardType extends Type
064{
065
066  /**
067   * <p>
068   * Returns an array of <code>Type</code>s, which specify the
069   * lower bounds of this type.  The default lower bound is
070   * <code>null</code>, which causes this method to return an
071   * empty array.
072   * </p>
073   * <p>
074   * In generating the array of <code>Type</code>s, each
075   * <code>ParameterizedType</code> or <code>TypeVariable</code> is
076   * created, (see the documentation for these classes for details of this
077   * process), if necessary, while all other types are simply
078   * resolved.
079   * </p>
080   *
081   * @return an array of <code>Type</code> objects, representing
082   *         the wildcard type's lower bounds.
083   * @throws TypeNotPresentException if any of the types referred to by
084   *         the lower bounds of this type do not actually exist.
085   * @throws MalformedParameterizedTypeException if any of the types
086   *         refer to a type which can not be instantiated.
087   */
088  Type[] getLowerBounds();
089
090  /**
091   * <p>
092   * Returns an array of <code>Type</code>s, which specify the
093   * upper bounds of this type.  The default upper bound is
094   * <code>Object</code>, which causes this method to return an
095   * array, containing just the <code>Type</code> instance for
096   * <code>Object</code>.
097   * </p>
098   * <p>
099   * 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}