1 /*
   2  * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Sun designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Sun in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  22  * CA 95054 USA or visit www.sun.com if you need additional information or
  23  * have any questions.
  24  */
  25 
  26 package com.sun.mirror.type;
  27 
  28 
  29 import java.util.Collection;
  30 
  31 import com.sun.mirror.declaration.TypeDeclaration;
  32 
  33 
  34 /**
  35  * Represents a declared type, either a class type or an interface type.
  36  * This includes parameterized types such as {@code java.util.Set<String>}
  37  * as well as raw types.
  38  *
  39  * <p> While a <tt>TypeDeclaration</tt> represents the <i>declaration</i>
  40  * of a class or interface, a <tt>DeclaredType</tt> represents a class
  41  * or interface <i>type</i>, the latter being a use of the former.
  42  * See {@link TypeDeclaration} for more on this distinction.
  43  *
  44  * <p> A <tt>DeclaredType</tt> may represent a type
  45  * for which details (declaration, supertypes, <i>etc.</i>) are unknown.
  46  * This may be the result of a processing error, such as a missing class file,
  47  * and is indicated by {@link #getDeclaration()} returning <tt>null</tt>.
  48  * Other method invocations on such an unknown type will not, in general,
  49  * return meaningful results.
  50  *
  51  * @author Joseph D. Darcy
  52  * @author Scott Seligman
  53  * @since 1.5
  54  */
  55 
  56 public interface DeclaredType extends ReferenceType {
  57 
  58     /**
  59      * Returns the declaration of this type.
  60      *
  61      * <p> Returns null if this type's declaration is unknown.  This may
  62      * be the result of a processing error, such as a missing class file.
  63      *
  64      * @return the declaration of this type, or null if unknown
  65      */
  66     TypeDeclaration getDeclaration();
  67 
  68     /**
  69      * Returns the type that contains this type as a member.
  70      * Returns <tt>null</tt> if this is a top-level type.
  71      *
  72      * <p> For example, the containing type of {@code O.I<S>}
  73      * is the type {@code O}, and the containing type of
  74      * {@code O<T>.I<S>} is the type {@code O<T>}.
  75      *
  76      * @return the type that contains this type,
  77      * or <tt>null</tt> if this is a top-level type
  78      */
  79     DeclaredType getContainingType();
  80 
  81     /**
  82      * Returns (in order) the actual type arguments of this type.
  83      * For a generic type nested within another generic type
  84      * (such as {@code Outer<String>.Inner<Number>}), only the type
  85      * arguments of the innermost type are included.
  86      *
  87      * @return the actual type arguments of this type, or an empty collection
  88      * if there are none
  89      */
  90     Collection<TypeMirror> getActualTypeArguments();
  91 
  92     /**
  93      * Returns the interface types that are direct supertypes of this type.
  94      * These are the interface types implemented or extended
  95      * by this type's declaration, with any type arguments
  96      * substituted in.
  97      *
  98      * <p> For example, the interface type extended by
  99      * {@code java.util.Set<String>} is {@code java.util.Collection<String>}.
 100      *
 101      * @return the interface types that are direct supertypes of this type,
 102      * or an empty collection if there are none
 103      */
 104     Collection<InterfaceType> getSuperinterfaces();
 105 }