001: /*
002: * Spoon - http://spoon.gforge.inria.fr/
003: * Copyright (C) 2006 INRIA Futurs <renaud.pawlak@inria.fr>
004: *
005: * This software is governed by the CeCILL-C License under French law and
006: * abiding by the rules of distribution of free software. You can use, modify
007: * and/or redistribute the software under the terms of the CeCILL-C license as
008: * circulated by CEA, CNRS and INRIA at http://www.cecill.info.
009: *
010: * This program is distributed in the hope that it will be useful, but WITHOUT
011: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
012: * FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details.
013: *
014: * The fact that you are presently reading this means that you have had
015: * knowledge of the CeCILL-C license and that you accept its terms.
016: */
017:
018: package spoon.reflect.reference;
019:
020: import java.util.Collection;
021: import java.util.Set;
022:
023: import spoon.reflect.declaration.CtSimpleType;
024:
025: /**
026: * This interface defines a reference to a
027: * {@link spoon.reflect.declaration.CtType} or sub-type.
028: */
029: public interface CtTypeReference<T> extends CtReference,
030: CtGenericElementReference, CtModifiableReference {
031:
032: /**
033: * The name of the null type ("<nulltype>").
034: */
035: public static final String NULL_TYPE_NAME = "<nulltype>";
036:
037: /**
038: * Gets the Java runtime class of the referenced type.
039: *
040: * @return the Java class or null if the class is not found (not in
041: * classpath)
042: */
043: Class<T> getActualClass();
044:
045: CtSimpleType<T> getDeclaration();
046:
047: /**
048: * Gets the type that declares the referenced type.
049: *
050: * @return the declaring type if this references an inner class; null in
051: * other cases
052: */
053: CtTypeReference<?> getDeclaringType();
054:
055: /**
056: * Gets the package of the referenced type.
057: *
058: * @return the declaring package or null if this if a inner class
059: */
060: CtPackageReference getPackage();
061:
062: /**
063: * Gets the qualified name.
064: *
065: * @return the fully-qualified name of the referenced type
066: */
067: String getQualifiedName();
068:
069: /**
070: * Returns <code>true</code> if this referenced type is assignable from an
071: * instance of the given type.
072: */
073: boolean isAssignableFrom(CtTypeReference<?> type);
074:
075: /**
076: * Return {@code true} if the referenced type is a primitive type (int,
077: * double, boolean...).
078: */
079: boolean isPrimitive();
080:
081: /**
082: * Returns the corresponding non-primitive type for a primitive type (the
083: * same type otherwhise).
084: */
085: CtTypeReference<?> box();
086:
087: /**
088: * Returns the primitive type for a boxing type (unchanged if the type does
089: * not correspond to a boxing type).
090: */
091: CtTypeReference<?> unbox();
092:
093: /**
094: * Returns true if the referenced type is a sub-type of the given type.
095: */
096: boolean isSubtypeOf(CtTypeReference<?> type);
097:
098: /**
099: * Sets the reference to the declaring type. Should be set to null if the
100: * referenced type is not a inner type.
101: */
102: void setDeclaringType(CtTypeReference<?> type);
103:
104: /**
105: * Sets the reference to the declaring package.
106: */
107: void setPackage(CtPackageReference pack);
108:
109: /**
110: * Gets the fields declared by this type.
111: */
112: Collection<CtFieldReference<?>> getDeclaredFields();
113:
114: /**
115: * Gets the fields declared by this type and by all its supertypes if
116: * applicable.
117: */
118: Collection<CtFieldReference<?>> getAllFields();
119:
120: /**
121: * Gets the executables declared by this type if applicable.
122: */
123: Collection<CtExecutableReference<?>> getDeclaredExecutables();
124:
125: /**
126: * Gets the executables declared by this type and by all its supertypes if
127: * applicable.
128: */
129: Collection<CtExecutableReference<?>> getAllExecutables();
130:
131: /**
132: * Gets the superclass of this type if applicable (only for classes).
133: */
134: CtTypeReference<?> getSuperclass();
135:
136: /**
137: * Gets the super interfaces of this type.
138: */
139: Set<CtTypeReference<?>> getSuperInterfaces();
140:
141: }
|