sun.reflect.generics.scope
abstract public class: AbstractScope [javadoc |
source]
java.lang.Object
sun.reflect.generics.scope.AbstractScope
All Implemented Interfaces:
Scope
Direct Known Subclasses:
MethodScope, ConstructorScope, ClassScope
Abstract superclass for lazy scope objects, used when building
factories for generic information repositories.
The type parameter
D represents the type of reflective
object whose scope this class is representing.
To subclass this, all one needs to do is implement
computeEnclosingScope and the subclass' constructor.
Constructor: |
protected AbstractScope(D decl) {
recvr = decl;
}
Constructor. Takes a reflective object whose scope the newly
constructed instance will represent. Parameters:
D - - A generic declaration whose scope the newly
constructed instance will represent
|
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from sun.reflect.generics.scope.AbstractScope Detail: |
abstract protected Scope computeEnclosingScope()
This method must be implemented by any concrete subclass.
It must return the enclosing scope of this scope. If this scope
is a top-level scope, an instance of DummyScope must be returned. |
protected Scope getEnclosingScope() {
if (enclosingScope == null) {enclosingScope = computeEnclosingScope();}
return enclosingScope;
}
Accessor for the enclosing scope, which is computed lazily and cached. |
protected D getRecvr() {
return recvr;
}
Accessor for the receiver - the object whose scope this Scope
object represents. |
public TypeVariable<?> lookup(String name) {
TypeVariable[] tas = getRecvr().getTypeParameters();
for (TypeVariable/*< ? >*/ tv : tas) {
if (tv.getName().equals(name)) {return tv;}
}
return getEnclosingScope().lookup(name);
}
Lookup a type variable in the scope, using its name. Returns null if
no type variable with this name is declared in this scope or any of its
surrounding scopes. |