public class TypeUtils
extends java.lang.Object
Constructor and Description |
---|
TypeUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> Function<java.lang.Class<?>,java.lang.Class<? extends T>> |
asSubclass(java.lang.Class<T> supertype)
Function that casts classes to specified types.
|
static Function<java.lang.Object,java.lang.Class<?>> |
extractClass()
Function that gets the class for its argument.
|
static Function<java.lang.Object,java.lang.Class<?>> |
extractClass(boolean acceptNull)
Function that gets the class for its argument.
|
static <T> Function<T,java.lang.Class<? extends T>> |
extractClass(java.lang.Class<T> supertype)
Function that gets the class for its argument.
|
static <T> Function<T,java.lang.Class<? extends T>> |
extractClass(java.lang.Class<T> supertype,
boolean acceptNull)
Function that gets the class for its argument.
|
static <T> java.util.Set<java.lang.Class<? extends T>> |
findTypes(java.lang.Iterable<? extends T> objects,
java.lang.Class<T> parent)
Build the set of types implemented by the objects' classes.
|
static Predicate<java.lang.Class<?>> |
isSubclass(java.lang.Class<?> cls) |
static Predicate<java.lang.Class<?>> |
subtypePredicate(java.lang.Class<?> parent)
A predicate that accepts classes which are subtypes of (assignable to) the parent class.
|
static java.util.Set<java.lang.Class<?>> |
typeClosure(java.lang.Class<?> type)
Return the supertype closure of a type (the type and all its transitive
supertypes).
|
public static <T> java.util.Set<java.lang.Class<? extends T>> findTypes(java.lang.Iterable<? extends T> objects, java.lang.Class<T> parent)
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 java.util.Set<java.lang.Class<?>> typeClosure(java.lang.Class<?> type)
type
- The type.public static Predicate<java.lang.Class<?>> isSubclass(java.lang.Class<?> cls)
public static <T> Function<java.lang.Class<?>,java.lang.Class<? extends T>> asSubclass(java.lang.Class<T> supertype)
supertype
- A class known to be a valid supertype for any argument.public static <T> Function<T,java.lang.Class<? extends T>> extractClass(java.lang.Class<T> supertype, boolean acceptNull)
supertype
- A class known to be a valid supertype for any argument.acceptNull
- Whether nulls are accepted & passed through. If false
, the function
will never return null
.public static <T> Function<T,java.lang.Class<? extends T>> extractClass(java.lang.Class<T> supertype)
supertype
- A class known to be a valid supertype for any argument.public static Function<java.lang.Object,java.lang.Class<?>> extractClass()
public static Function<java.lang.Object,java.lang.Class<?>> extractClass(boolean acceptNull)
public static Predicate<java.lang.Class<?>> subtypePredicate(java.lang.Class<?> parent)
parent
- The parent class.true
when applied to a subtype of parent
.
That is, it implements paret.isAssignableFrom(type)
.