package com.github.pyknic.stiletto.internal.util;

import java.lang.reflect.Field;
import java.util.stream.Stream;

/**
 * Some common utility methods for analyzing classes with reflection.
 *
 * @author  Emil Forslund
 * @since   1.0.0
 */
public final class ReflectionUtil {

    public static Stream<Field> traverseFields(Class<?> clazz) {
        final Class<?> parent = clazz.getSuperclass();
        final Stream<Field> inherited;

        if (parent != null) {
            inherited = traverseFields(parent);
        } else {
            inherited = Stream.empty();
        }

        return Stream.concat(inherited, Stream.of(clazz.getDeclaredFields()));
    }

    public static Stream<Class<?>> traverseAncestors(Class<?> clazz) {
        if (clazz.getSuperclass() == null) { // We have reached Object.class
            return Stream.of(clazz);
        } else {
            return Stream.concat(
                Stream.of(clazz),
                Stream.concat(
                    traverseAncestors(clazz.getSuperclass()),
                    Stream.of(clazz.getInterfaces())
                )
            ).distinct();
        }
    }

    private ReflectionUtil() {}
}
@@ -271,16 +271,324 @@
 Util %7B%0A%0A
+    /**%0A     * Returns a stream of all the member fields for the specified class,%0A     * including inherited fields from any ancestors. This includes public,%0A     * private, protected and package private fields.%0A     *%0A     * @param clazz  the class to traverse%0A     * @return       stream of fields%0A     */%0A
     publ
@@ -967,24 +967,373 @@
 )));%0A    %7D%0A%0A
+    /**%0A     * Returns a stream of all the classes upwards in the inheritance tree of%0A     * the specified class, including the class specified as the first element%0A     * and %7B@code java.lang.Object%7D as the last one.%0A     *%0A     * @param clazz  the first class in the tree%0A     * @return       stream of ancestors (including %7B@code clazz%7D)%0A     */%0A
     public s
@@ -1793,24 +1793,72 @@
    %7D%0A    %7D%0A%0A
+    /**%0A     * Should never be invoked.%0A     */%0A
     private 

Improve documentation in ReflectionUtil