001: /*
002: * @(#)DeclaredType.java 1.6 04/06/07
003: *
004: * Copyright (c) 2004, Sun Microsystems, Inc.
005: * All rights reserved.
006: *
007: * Redistribution and use in source and binary forms, with or without
008: * modification, are permitted provided that the following conditions are met:
009: *
010: * * Redistributions of source code must retain the above copyright
011: * notice, this list of conditions and the following disclaimer.
012: * * Redistributions in binary form must reproduce the above copyright
013: * notice, this list of conditions and the following disclaimer in the
014: * documentation and/or other materials provided with the distribution.
015: * * Neither the name of the Sun Microsystems, Inc. nor the names of
016: * its contributors may be used to endorse or promote products derived from
017: * this software without specific prior written permission.
018: *
019: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
020: * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
021: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
022: * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
023: * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
024: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
025: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
026: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
027: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
028: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
029: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
030: */
031:
032: package com.sun.mirror.type;
033:
034: import java.util.Collection;
035:
036: import com.sun.mirror.declaration.TypeDeclaration;
037:
038: /**
039: * Represents a declared type, either a class type or an interface type.
040: * This includes parameterized types such as {@code java.util.Set<String>}
041: * as well as raw types.
042: *
043: * <p> While a <tt>TypeDeclaration</tt> represents the <i>declaration</i>
044: * of a class or interface, a <tt>DeclaredType</tt> represents a class
045: * or interface <i>type</i>, the latter being a use of the former.
046: * See {@link TypeDeclaration} for more on this distinction.
047: *
048: * <p> A <tt>DeclaredType</tt> may represent a type
049: * for which details (declaration, supertypes, <i>etc.</i>) are unknown.
050: * This may be the result of a processing error, such as a missing class file,
051: * and is indicated by {@link #getDeclaration()} returning <tt>null</tt>.
052: * Other method invocations on such an unknown type will not, in general,
053: * return meaningful results.
054: *
055: * @author Joseph D. Darcy
056: * @author Scott Seligman
057: * @version 1.6 04/06/07
058: * @since 1.5
059: */
060:
061: public interface DeclaredType extends ReferenceType {
062:
063: /**
064: * Returns the declaration of this type.
065: *
066: * <p> Returns null if this type's declaration is unknown. This may
067: * be the result of a processing error, such as a missing class file.
068: *
069: * @return the declaration of this type, or null if unknown
070: */
071: TypeDeclaration getDeclaration();
072:
073: /**
074: * Returns the type that contains this type as a member.
075: * Returns <tt>null</tt> if this is a top-level type.
076: *
077: * <p> For example, the containing type of {@code O.I<S>}
078: * is the type {@code O}, and the containing type of
079: * {@code O<T>.I<S>} is the type {@code O<T>}.
080: *
081: * @return the type that contains this type,
082: * or <tt>null</tt> if this is a top-level type
083: */
084: DeclaredType getContainingType();
085:
086: /**
087: * Returns (in order) the actual type arguments of this type.
088: * For a generic type nested within another generic type
089: * (such as {@code Outer<String>.Inner<Number>}), only the type
090: * arguments of the innermost type are included.
091: *
092: * @return the actual type arguments of this type, or an empty collection
093: * if there are none
094: */
095: Collection<TypeMirror> getActualTypeArguments();
096:
097: /**
098: * Returns the interface types that are direct supertypes of this type.
099: * These are the interface types implemented or extended
100: * by this type's declaration, with any type arguments
101: * substituted in.
102: *
103: * <p> For example, the interface type extended by
104: * {@code java.util.Set<String>} is {@code java.util.Collection<String>}.
105: *
106: * @return the interface types that are direct supertypes of this type,
107: * or an empty collection if there are none
108: */
109: Collection<InterfaceType> getSuperinterfaces();
110: }
|