And more specific example:
abstract trait A
trait B extends A
trait C extends A
How to check what traits that extend trait A (it can be from 0 to many) were mixed in specified class?
And more specific example:
abstract trait A
trait B extends A
trait C extends A
How to check what traits that extend trait A (it can be from 0 to many) were mixed in specified class?
How about something like this:
This finds all traits that
clazz
implements that are themselves subtraits ofbaseTrait
. With the following traits:Use as follows:
This only looks at the interfaces that are the directly implemented by the class of the instance passed in, but could be extended to recursively look up the inheritance hierarchy.
How about a hybrid of the other answers
returns