public class TypeUtils
extends java.lang.Object
Various type utilities used in LensKit.
Modifier and Type | Method and Description |
---|---|
static <T> TypeToken<T> |
listElementType(TypeToken<? extends java.util.List<T>> token)
Extract the element type from a type token representing a list.
|
static <T> org.joda.convert.FromStringConverter<T> |
lookupFromStringConverter(TypeToken<T> type)
Look up a converter to convert strings to the specified type.
|
static <T> TypeToken<java.util.List<T>> |
makeListType(TypeToken<T> element)
Make a type token for a list of a particular element type.
|
static <T> java.lang.String |
makeTypeName(TypeToken<T> type)
Turn a type token into a parsable type name.
|
static TypeToken<?> |
resolveTypeName(java.lang.String type)
Resolve a type name into a type.
|
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 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).
type
- The type.public static <T> TypeToken<java.util.List<T>> makeListType(TypeToken<T> element)
Make a type token for a list of a particular element type.
element
- The element type.T
- The element type.List<T>
.public static <T> TypeToken<T> listElementType(TypeToken<? extends java.util.List<T>> token)
Extract the element type from a type token representing a list.
token
- The type token.T
- The list element type.public static TypeToken<?> resolveTypeName(java.lang.String type)
Resolve a type name into a type. This is like class lookup with a few additions:
string
, int
, long
, double
)string[]
becomes List<String>
)type
- The type name to resolve.public static <T> java.lang.String makeTypeName(TypeToken<T> type)
Turn a type token into a parsable type name.
type
- The type token.T
- The type.resolveTypeName(String)
.public static <T> org.joda.convert.FromStringConverter<T> lookupFromStringConverter(TypeToken<T> type)
Look up a converter to convert strings to the specified type. List types are converted from comma-separated values.
type
- The type.T
- The type.type
from strings.