Package com.tonic.renamer.hierarchy
Class ClassHierarchy
- java.lang.Object
-
- com.tonic.renamer.hierarchy.ClassHierarchy
-
public class ClassHierarchy extends Object
Queryable inheritance graph of the classes in a ClassPool.
-
-
Constructor Summary
Constructors Constructor Description ClassHierarchy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<ClassNode>findMethodHierarchy(String className, String methodName, String descriptor)Finds all classes that declare or inherit a method with the given signature.Collection<ClassNode>getAllNodes()MethodEntrygetMethod(String className, String methodName, String descriptor)Finds a method declared directly on one class, without walking the hierarchy.ClassNodegetNode(String className)Looks up an already-registered node.Collection<ClassNode>getPoolNodes()booleanisAncestorOf(String ancestorName, String descendantName)Checks if a class is an ancestor of another class.intsize()StringtoString()
-
-
-
Method Detail
-
getNode
public ClassNode getNode(String className)
Looks up an already-registered node.- Parameters:
className- internal name of the class- Returns:
- the node, or null if the hierarchy has no entry for it
-
getAllNodes
public Collection<ClassNode> getAllNodes()
- Returns:
- an unmodifiable view of every node, pool classes and external references alike
-
getPoolNodes
public Collection<ClassNode> getPoolNodes()
- Returns:
- a fresh list of the nodes backed by a pool class, excluding external references
-
isAncestorOf
public boolean isAncestorOf(String ancestorName, String descendantName)
Checks if a class is an ancestor of another class.- Parameters:
ancestorName- The potential ancestor class namedescendantName- The potential descendant class name- Returns:
- true if ancestor is a superclass or interface of descendant
-
findMethodHierarchy
public Set<ClassNode> findMethodHierarchy(String className, String methodName, String descriptor)
Finds all classes that declare or inherit a method with the given signature.- Parameters:
className- The starting class namemethodName- The method namedescriptor- The method descriptor- Returns:
- Set of ClassNodes that have this method (declared or inherited)
-
getMethod
public MethodEntry getMethod(String className, String methodName, String descriptor)
Finds a method declared directly on one class, without walking the hierarchy.- Parameters:
className- internal name of the declaring classmethodName- method name to matchdescriptor- method descriptor to match- Returns:
- the matching entry, or null if the class is unknown, external, or lacks the method
-
size
public int size()
- Returns:
- the number of registered nodes
-
-