1. /*
  2. * @(#)TypeDeclaration.java 1.4 04/04/30
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.mirror.declaration;
  8. import java.util.Collection;
  9. import com.sun.mirror.type.*;
  10. /**
  11. * Represents the declaration of a class or interface.
  12. * Provides access to information about the type and its members.
  13. * Note that an {@linkplain EnumDeclaration enum} is a kind of class,
  14. * and an {@linkplain AnnotationTypeDeclaration annotation type} is
  15. * a kind of interface.
  16. *
  17. * <p> <a name="DECL_VS_TYPE"></a>
  18. * While a <tt>TypeDeclaration</tt> represents the <i>declaration</i>
  19. * of a class or interface, a {@link DeclaredType} represents a class
  20. * or interface <i>type</i>, the latter being a use
  21. * (or <i>invocation</i>) of the former.
  22. * The distinction is most apparent with generic types,
  23. * for which a single declaration can define a whole
  24. * family of types. For example, the declaration of
  25. * {@code java.util.Set} corresponds to the parameterized types
  26. * {@code java.util.Set<String>} and {@code java.util.Set<Number>}
  27. * (and many others), and to the raw type {@code java.util.Set}.
  28. *
  29. * <p> {@link com.sun.mirror.util.DeclarationFilter}
  30. * provides a simple way to select just the items of interest
  31. * when a method returns a collection of declarations.
  32. *
  33. * @author Joseph D. Darcy
  34. * @author Scott Seligman
  35. * @version 1.4 04/04/30
  36. *
  37. * @see DeclaredType
  38. * @since 1.5
  39. */
  40. public interface TypeDeclaration extends MemberDeclaration {
  41. /**
  42. * Returns the package within which this type is declared.
  43. *
  44. * @return the package within which this type is declared
  45. */
  46. PackageDeclaration getPackage();
  47. /**
  48. * Returns the fully qualified name of this class or interface
  49. * declaration. More precisely, it returns the <i>canonical</i>
  50. * name.
  51. * The name of a generic type does not include any reference
  52. * to its formal type parameters.
  53. * For example, the the fully qualified name of the interface declaration
  54. * {@code java.util.Set<E>} is <tt>"java.util.Set"</tt>.
  55. *
  56. * @return the fully qualified name of this class or interface declaration
  57. */
  58. String getQualifiedName();
  59. /**
  60. * Returns the formal type parameters of this class or interface.
  61. *
  62. * @return the formal type parameters, or an empty collection
  63. * if there are none
  64. */
  65. Collection<TypeParameterDeclaration> getFormalTypeParameters();
  66. /**
  67. * Returns the interface types directly implemented by this class
  68. * or extended by this interface.
  69. *
  70. * @return the interface types directly implemented by this class
  71. * or extended by this interface, or an empty collection if there are none
  72. *
  73. * @see com.sun.mirror.util.DeclarationFilter
  74. */
  75. Collection<InterfaceType> getSuperinterfaces();
  76. /**
  77. * Returns the fields that are directly declared by this class or
  78. * interface. Includes enum constants.
  79. *
  80. * @return the fields that are directly declared,
  81. * or an empty collection if there are none
  82. *
  83. * @see com.sun.mirror.util.DeclarationFilter
  84. */
  85. Collection<FieldDeclaration> getFields();
  86. /**
  87. * Returns the methods that are directly declared by this class or
  88. * interface. Includes annotation type elements. Excludes
  89. * implicitly declared methods of an interface, such as
  90. * <tt>toString</tt>, that correspond to the methods of
  91. * <tt>java.lang.Object</tt>.
  92. *
  93. * @return the methods that are directly declared,
  94. * or an empty collection if there are none
  95. *
  96. * @see com.sun.mirror.util.DeclarationFilter
  97. */
  98. Collection<? extends MethodDeclaration> getMethods();
  99. /**
  100. * Returns the declarations of the nested classes and interfaces
  101. * that are directly declared by this class or interface.
  102. *
  103. * @return the declarations of the nested classes and interfaces,
  104. * or an empty collection if there are none
  105. *
  106. * @see com.sun.mirror.util.DeclarationFilter
  107. */
  108. Collection<TypeDeclaration> getNestedTypes();
  109. }