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.lang.reflect.Constructor;
021: import java.lang.reflect.Method;
022: import java.util.List;
023:
024: import spoon.reflect.declaration.CtExecutable;
025:
026: /**
027: * This interface defines a reference to a
028: * {@link spoon.reflect.declaration.CtExecutable}. It can be a
029: * {@link spoon.reflect.declaration.CtMethod} or a
030: * {@link spoon.reflect.declaration.CtConstructor}.
031: */
032: public interface CtExecutableReference<T> extends CtReference,
033: CtGenericElementReference, CtModifiableReference {
034:
035: /**
036: * Tells if this is a reference to a constructor.
037: */
038: boolean isConstructor();
039:
040: /**
041: * Gets the runtime method that corresponds to an executable reference if
042: * any.
043: *
044: * @return the method (null if not found)
045: */
046: Method getActualMethod();
047:
048: /**
049: * Gets the runtime constructor that corresponds to an executable reference
050: * if any.
051: *
052: * @return the constructor (null if not found)
053: */
054: Constructor<?> getActualConstructor();
055:
056: CtExecutable<T> getDeclaration();
057:
058: /**
059: * Gets the reference to the type that declares this executable.
060: */
061: CtTypeReference<?> getDeclaringType();
062:
063: /**
064: * Gets the list of the executable's parameter types.
065: */
066: List<CtTypeReference<?>> getParameterTypes();
067:
068: /**
069: * Gets the type of the executable.
070: */
071: CtTypeReference<T> getType();
072:
073: /**
074: * Returns <code>true</code> if this executable overrides the given
075: * executable.
076: */
077: boolean isOverriding(CtExecutableReference<?> executable);
078:
079: /**
080: * Returns the executable overriden by this one, if exists (null
081: * otherwise).
082: */
083: CtExecutableReference<?> getOverridingExecutable();
084:
085: /**
086: * Gets an overriding executable for this executable from a given subtype,
087: * if exists.
088: *
089: * @param <S>
090: * subtype of T
091: * @param subType
092: * starting bottom type to find an overriding executable
093: * (subtypes are not tested)
094: * @return the first found (most concrete) executable that overrides this
095: * executable (null if none found)
096: */
097: <S extends T> CtExecutableReference<S> getOverridingExecutable(
098: CtTypeReference<?> subType);
099:
100: /**
101: * Tells if the referenced executable is static.
102: */
103: boolean isStatic();
104:
105: /**
106: * Sets the declaring type.
107: */
108: void setDeclaringType(CtTypeReference<?> declaringType);
109:
110: /**
111: * Sets the list of the executable's parameters types.
112: */
113: void setParameterTypes(List<CtTypeReference<?>> parameterTypes);
114:
115: /**
116: * Sets this executable reference to be static or not.
117: */
118: void setStatic(boolean b);
119:
120: /**
121: * Sets the type of the variable.
122: */
123: void setType(CtTypeReference<T> type);
124:
125: /**
126: * Tells if the referenced executable is final.
127: */
128: boolean isFinal();
129: }
|