Class InheritanceDistanceCalculator

java.lang.Object
ch.tocco.nice2.toolbox.api.reflect.InheritanceDistanceCalculator

public class InheritanceDistanceCalculator extends Object
This simple helper calculates the depth of the inheritance tree. Instantiation of this class will throw an IllegalArgumentException if the given super class is not assignable from the given sub class.
  • Constructor Details

    • InheritanceDistanceCalculator

      public InheritanceDistanceCalculator(Class subClass, Class superClass)
  • Method Details

    • calculateDistance

      public int calculateDistance()
      Calculates the distance between the two given classes. For instance if the given subclass extends the given super class directly, the distance will be 1. If there is one class between the two given classes, the distance will be 2.
      Returns:
      the distance between the two classes.