public class TypeUtils extends Object
Various type utilities used in LensKit.
Modifier and Type | Method and Description |
---|---|
static <T> Set<Class<? extends T>> |
findTypes(Iterable<? extends T> objects,
Class<T> parent)
Build the set of types implemented by the objects’ classes.
|
static Predicate<Class<?>> |
subtypePredicate(Class<?> parent)
A predicate that accepts classes which are subtypes of (assignable to) the parent class.
|
static Set<Class<?>> |
typeClosure(Class<?> type)
Return the supertype closure of a type (the type and all its transitive supertypes).
|
public static <T> Set<Class<? extends T>> findTypes(Iterable<? extends T> objects, Class<T> parent)
Build the set of types implemented by the objects’ classes. This includes all supertypes which are themselves subclasses of parent. The resulting set is the set of all subclasses of parent such that there exists some object in objects assignable to one of them.
objects
- A collection of objects. This iterable may be fast (returning a modified version of the same object).parent
- The parent type of interest.public static Set<Class<?>> typeClosure(Class<?> type)
Return the supertype closure of a type (the type and all its transitive supertypes).
type
- The type.public static Predicate<Class<?>> subtypePredicate(Class<?> parent)
A predicate that accepts classes which are subtypes of (assignable to) the parent class.
parent
- The parent class.true
when applied to a subtype of parent
. That is, it implements paret.isAssignableFrom(type)
.