1 /*
   2  * Copyright (c) 2004, Oracle and/or its affiliates. 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * 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  * @deprecated All components of this API have been superseded by the
  58  * standardized annotation processing API.  The replacement for the
  59  * functionality of this interface is included in {@link
  60  * javax.lang.model.element.TypeElement}.
  61  *
  62  * @author Joseph D. Darcy
  63  * @author Scott Seligman
  64  *
  65  * @see DeclaredType
  66  * @since 1.5
  67  */
  68 @Deprecated
  69 @SuppressWarnings("deprecation")
  70 public interface TypeDeclaration extends MemberDeclaration {
  71 
  72     /**
  73      * Returns the package within which this type is declared.
  74      *
  75      * @return the package within which this type is declared
  76      */
  77     PackageDeclaration getPackage();
  78 
  79     /**
  80      * Returns the fully qualified name of this class or interface
  81      * declaration.  More precisely, it returns the <i>canonical</i>
  82      * name.
  83      * The name of a generic type does not include any reference
  84      * to its formal type parameters.
  85      * For example, the the fully qualified name of the interface declaration
  86      * {@code java.util.Set<E>} is <tt>"java.util.Set"</tt>.
  87      *
  88      * @return the fully qualified name of this class or interface declaration
  89      */
  90     String getQualifiedName();
  91 
  92     /**
  93      * Returns the formal type parameters of this class or interface.
  94      *
  95      * @return the formal type parameters, or an empty collection
  96      * if there are none
  97      */
  98     Collection<TypeParameterDeclaration> getFormalTypeParameters();
  99 
 100     /**
 101      * Returns the interface types directly implemented by this class
 102      * or extended by this interface.
 103      *
 104      * @return the interface types directly implemented by this class
 105      * or extended by this interface, or an empty collection if there are none
 106      *
 107      * @see com.sun.mirror.util.DeclarationFilter
 108      */
 109     Collection<InterfaceType> getSuperinterfaces();
 110 
 111     /**
 112      * Returns the fields that are directly declared by this class or
 113      * interface.  Includes enum constants.
 114      *
 115      * @return the fields that are directly declared,
 116      * or an empty collection if there are none
 117      *
 118      * @see com.sun.mirror.util.DeclarationFilter
 119      */
 120     Collection<FieldDeclaration> getFields();
 121 
 122     /**
 123      * Returns the methods that are directly declared by this class or
 124      * interface.  Includes annotation type elements.  Excludes
 125      * implicitly declared methods of an interface, such as
 126      * <tt>toString</tt>, that correspond to the methods of
 127      * <tt>java.lang.Object</tt>.
 128      *
 129      * @return the methods that are directly declared,
 130      * or an empty collection if there are none
 131      *
 132      * @see com.sun.mirror.util.DeclarationFilter
 133      */
 134     Collection<? extends MethodDeclaration> getMethods();
 135 
 136     /**
 137      * Returns the declarations of the nested classes and interfaces
 138      * that are directly declared by this class or interface.
 139      *
 140      * @return the declarations of the nested classes and interfaces,
 141      * or an empty collection if there are none
 142      *
 143      * @see com.sun.mirror.util.DeclarationFilter
 144      */
 145     Collection<TypeDeclaration> getNestedTypes();
 146 }