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.declaration;
  27 
  28 
  29 import java.util.Collection;
  30 
  31 import com.sun.mirror.type.*;
  32 
  33 
  34 /**
  35  * Represents the declaration of a class or interface.
  36  * Provides access to information about the type and its members.
  37  * Note that an {@linkplain EnumDeclaration enum} is a kind of class,
  38  * and an {@linkplain AnnotationTypeDeclaration annotation type} is
  39  * a kind of interface.
  40  *
  41  * <p> <a name="DECL_VS_TYPE"></a>
  42  * While a <tt>TypeDeclaration</tt> represents the <i>declaration</i>
  43  * of a class or interface, a {@link DeclaredType} represents a class
  44  * or interface <i>type</i>, the latter being a use
  45  * (or <i>invocation</i>) of the former.
  46  * The distinction is most apparent with generic types,
  47  * for which a single declaration can define a whole
  48  * family of types.  For example, the declaration of
  49  * {@code java.util.Set} corresponds to the parameterized types
  50  * {@code java.util.Set<String>} and {@code java.util.Set<Number>}
  51  * (and many others), and to the raw type {@code java.util.Set}.
  52  *
  53  * <p> {@link com.sun.mirror.util.DeclarationFilter}
  54  * provides a simple way to select just the items of interest
  55  * when a method returns a collection of declarations.
  56  *
  57  * @author Joseph D. Darcy
  58  * @author Scott Seligman
  59  *
  60  * @see DeclaredType
  61  * @since 1.5
  62  */
  63 
  64 public interface TypeDeclaration extends MemberDeclaration {
  65 
  66     /**
  67      * Returns the package within which this type is declared.
  68      *
  69      * @return the package within which this type is declared
  70      */
  71     PackageDeclaration getPackage();
  72 
  73     /**
  74      * Returns the fully qualified name of this class or interface
  75      * declaration.  More precisely, it returns the <i>canonical</i>
  76      * name.
  77      * The name of a generic type does not include any reference
  78      * to its formal type parameters.
  79      * For example, the the fully qualified name of the interface declaration
  80      * {@code java.util.Set<E>} is <tt>"java.util.Set"</tt>.
  81      *
  82      * @return the fully qualified name of this class or interface declaration
  83      */
  84     String getQualifiedName();
  85 
  86     /**
  87      * Returns the formal type parameters of this class or interface.
  88      *
  89      * @return the formal type parameters, or an empty collection
  90      * if there are none
  91      */
  92     Collection<TypeParameterDeclaration> getFormalTypeParameters();
  93 
  94     /**
  95      * Returns the interface types directly implemented by this class
  96      * or extended by this interface.
  97      *
  98      * @return the interface types directly implemented by this class
  99      * or extended by this interface, or an empty collection if there are none
 100      *
 101      * @see com.sun.mirror.util.DeclarationFilter
 102      */
 103     Collection<InterfaceType> getSuperinterfaces();
 104 
 105     /**
 106      * Returns the fields that are directly declared by this class or
 107      * interface.  Includes enum constants.
 108      *
 109      * @return the fields that are directly declared,
 110      * or an empty collection if there are none
 111      *
 112      * @see com.sun.mirror.util.DeclarationFilter
 113      */
 114     Collection<FieldDeclaration> getFields();
 115 
 116     /**
 117      * Returns the methods that are directly declared by this class or
 118      * interface.  Includes annotation type elements.  Excludes
 119      * implicitly declared methods of an interface, such as
 120      * <tt>toString</tt>, that correspond to the methods of
 121      * <tt>java.lang.Object</tt>.
 122      *
 123      * @return the methods that are directly declared,
 124      * or an empty collection if there are none
 125      *
 126      * @see com.sun.mirror.util.DeclarationFilter
 127      */
 128     Collection<? extends MethodDeclaration> getMethods();
 129 
 130     /**
 131      * Returns the declarations of the nested classes and interfaces
 132      * that are directly declared by this class or interface.
 133      *
 134      * @return the declarations of the nested classes and interfaces,
 135      * or an empty collection if there are none
 136      *
 137      * @see com.sun.mirror.util.DeclarationFilter
 138      */
 139     Collection<TypeDeclaration> getNestedTypes();
 140 }