hibernate / hibernate-models

An abstraction over "reflection" and annotations
Apache License 2.0
2 stars 5 forks source link

Methods to walk supers #30

Closed sebersole closed 4 months ago

sebersole commented 4 months ago

Methods to walk supers..

interface ClassDetails {
    ...

    default void forEachSuper(Consumer<ClassDetails> consumer) {
        ClassDetails check = getSuperClass();
        while ( check != null && check != OBJECT_CLASS_DETAILS ) {
            consumer.accept( check );
            check = check.getSuperClass();
        }
    }

    default void forSelfAndEachSuper(Consumer<ClassDetails> consumer) {
        consumer.accept( this );
        forEachSuper( consumer );
    }
}

Sounds simple, but I code this iteration over and over in hibernate-core. Centralize that here.

gavinking commented 4 months ago

Yes pleeez!