package bluej.debugger.gentype;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import bluej.parser.entity.ParsedArrayReflective;
| A version of Reflective which can be easily customised to suit the needs
| of a test.
|
| @author Davin McCall
|
public class TestReflective
extends Reflective{
public String name;
public List<GenTypeDeclTpar> typeParams;
public List<GenTypeClass> superTypes;
public Map<String,FieldReflective> fields = Collections.emptyMap();
public TestReflective(String name)
{
this.name = name;
typeParams = new ArrayList<GenTypeDeclTpar>();
superTypes = new ArrayList<GenTypeClass>();
}
public TestReflective(String name, Reflective superClass)
{
this(name);
superTypes.add(new GenTypeClass(superClass));
}
public String getName()
{
return name;
}
@Override
public boolean isInterface()
{
return false;
}
@Override
public boolean isStatic()
{
return false;
}
@Override
public boolean isPublic()
{
return true;
}
@Override
public boolean isFinal()
{
return false;
}
public Reflective getRelativeClass(String name)
{
return null;
}
public List getTypeParams()
{
return typeParams;
}
public List getSuperTypesR()
{
List<Reflective> n = new ArrayList<Reflective>();
Iterator<GenTypeClass> i = superTypes.iterator();
while (i.hasNext()){
n.add(i.next().getReflective());
}
return n;
}
public List getSuperTypes()
{
return superTypes;
}
public Reflective getArrayOf()
{
return new ParsedArrayReflective(this, "L" + getName() + ";");
}
public boolean isAssignableFrom(Reflective r)
{
if (r == this) {
return true;
}
List<Reflective> supers = r.getSuperTypesR();
for (Reflective superR : supers) {
if (isAssignableFrom(superR)) {
return true;
}
}
return false;
}
@Override
public Map getDeclaredFields()
{
return fields;
}
@Override
public Map> getDeclaredMethods()
{
return Collections.emptyMap();
}
@Override
public List getDeclaredConstructors()
{
return Collections.emptyList();
}
@Override
public Reflective getInnerClass(String name)
{
return null;
}
@Override
public String getModuleName()
{
return null;
}
}
top,
use,
map,
class TestReflective
. TestReflective
. TestReflective
. getName
. isInterface
. isStatic
. isPublic
. isFinal
. getRelativeClass
. getTypeParams
. getSuperTypesR
. getSuperTypes
. getArrayOf
. isAssignableFrom
. getDeclaredFields
. getDeclaredMethods
. getDeclaredConstructors
. getInnerClass
. getModuleName
187 neLoCode
+ 3 LoComm