org.apache.tapestry5.ioc.internal.util

## Class InheritanceSearch

- java.lang.Object
- - org.apache.tapestry5.ioc.internal.util.InheritanceSearch

- All Implemented Interfaces:
    Iterable<Class>, Iterator<Class>

      public class InheritanceSearch
      extends Object
      implements Iterator<Class>, Iterable<Class>

  Used to search from a particular class up the inheritance hierarchy of extended classes and implemented interfaces. The search starts with the initial class (provided in the constructor). It progresses up the inheritance chain, but skips java.lang.Object. Once classes are exhausted, the inheritance hierarchy is searched. This is a breadth-first search, rooted in the interfaces implemented by the initial class at its super classes. Once all interfaces are exhausted, java.lang.Object is returned (it is always returned last). Two minor tweak to normal inheritance rules:
  - Normally, the parent class of an object array is java.lang.Object, which is odd because FooService[] is assignable to Object[]. Thus, we tweak the search so that the effective super class of FooService[] is Object[].
  - The "super class" of a primtive type is its wrapper type, with the exception of void, whose "super class" is left at its normal value (Object.class)
  This class implements the `Iterable` interface, so it can be used directly in a for loop: `for (Class search : new InheritanceSearch(startClass)) { ... }` This class is not thread-safe.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `InheritanceSearch(Class searchClass)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `hasNext()`
    `Iterator<Class>` | `iterator()`
    `Class` | `next()`
    `void` | `remove()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface java.util.Iterator

      `forEachRemaining`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, spliterator`

- - ### Constructor Detail

    - #### InheritanceSearch

          public InheritanceSearch(Class searchClass)

  - ### Method Detail

    - #### iterator

          public Iterator<Class> iterator()

      Specified by:
        `iterator` in interface `Iterable<Class>`

    - #### hasNext

          public boolean hasNext()

      Specified by:
        `hasNext` in interface `Iterator<Class>`

    - #### next

          public Class next()

      Specified by:
        `next` in interface `Iterator<Class>`

    - #### remove

          public void remove()

      Specified by:
        `remove` in interface `Iterator<Class>`
      Throws:
        `UnsupportedOperationException` - always

5.6.0 - Copyright © 2003-2020 The Apache Software Foundation.