Package io.permazen.util
Class TypeTokens
java.lang.Object
io.permazen.util.TypeTokens
Various utility routines relating to
TypeToken
s.-
Method Summary
Modifier and TypeMethodDescriptionstatic TypeToken<?>
findLowestCommonAncestor
(Stream<TypeToken<?>> types) Find the narrowest type that is a supertype of all of the given types.static TypeToken<?>
findLowestCommonAncestorOfClasses
(Stream<Class<?>> types) Find the narrowest type that is a supertype of all of the given types.findLowestCommonAncestors
(Stream<TypeToken<?>> types) Find the narrowest type(s) each of which is a supertype of all of the given types.findLowestCommonAncestorsOfClasses
(Stream<Class<?>> types) Find the narrowest type(s) each of which is a supertype of all of the given types.static <T> TypeToken<? extends T>
getWildcardedType
(Class<T> type) Parameterize the raw type with wildcards.static <T> TypeToken<? extends T>
newParameterizedType
(Class<T> target, Type[] params) Convert a raw class back into its generic type using caller-supplied type parameters.
-
Method Details
-
findLowestCommonAncestorOfClasses
Find the narrowest type that is a supertype of all of the given types.This method delegates to
findLowestCommonAncestor()
after converting theClass
instances toTypeToken
s.- Parameters:
types
- sub-types- Returns:
- narrowest common super-type
- Throws:
IllegalArgumentException
- iftypes
or any type intypes
is null- See Also:
-
findLowestCommonAncestorsOfClasses
Find the narrowest type(s) each of which is a supertype of all of the given types.This method delegates to
findLowestCommonAncestors()
after converting theClass
instances toTypeToken
s.- Parameters:
types
- sub-types- Returns:
- maximally narrow common supertype(s)
- Throws:
IllegalArgumentException
- if any type intypes
is null- See Also:
-
findLowestCommonAncestor
Find the narrowest type that is a supertype of all of the given types.Note that there may be more than one such type. The returned type will always be as narrow as possible, but it's possible there for there to be multiple such types for which none is a sub-type of any other.
- Parameters:
types
- sub-types- Returns:
- narrowest common super-type
-
findLowestCommonAncestors
Find the narrowest type(s) each of which is a supertype of all of the given types.- Parameters:
types
- sub-types- Returns:
- maximally narrow common supertype(s)
-
getWildcardedType
Parameterize the raw type with wildcards.- Type Parameters:
T
- raw type- Parameters:
type
- raw type- Returns:
type
genericized with wildcards
-
newParameterizedType
Convert a raw class back into its generic type using caller-supplied type parameters.- Type Parameters:
T
- raw class type- Parameters:
target
- raw classparams
- type parameters- Returns:
- generic
TypeToken
fortarget
- See Also:
-