TypeHierarchy
The TypeHierarchy models the relationship of Classes or Interfaces of a OOP program.
Creating TypeHierarchy
Create a JavaClassType
Query the TypeHierarchy
Classes
| // if the assertion fails, the following methods will throw an Exception (you don't have to call it - it's just to illustrate the assumption)
assert typehierarchy.contains(classTypeA);
typehierarchy.superclassOf(classTypeA);
typehierarchy.subclassesOf(classTypeA);
typehierarchy.isSubtypeOf(classTypeA, classTypeB);
|
Interfaces
1
2
3
4
5
6
7
8
9
10
11
12
13 | JavaClassType iterableInterface = view.getIdentifierFactory().getClassType("java.lang.Iterable");
// if any of the assertions fail, the following methods will throw an Exception (you don't have to call these - it's just to illustrate the assumptions)
assert typehierarchy.contains(iterableInterface);
assert typehierarchy.isInterface(iterableInterface);
// transitive relations as well
typehierarchy.implementedInterfacesOf(iterableInterface);
typehierarchy.implementersOf(iterableInterface);
// only the direct related relations
typehierarchy.directlyImplementedInterfacesOf(iterableInterface);
typehierarchy.directlyExtendedInterfacesOf(iterableInterface);
|