Package org.beanio.internal.util
Class TypeUtil
- java.lang.Object
-
- org.beanio.internal.util.TypeUtil
-
public class TypeUtil extends java.lang.Object
Utility class for working with Java types supported by BeanIO.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.Class<? extends java.util.Collection<java.lang.Object>>
ARRAY_TYPE
Class type used to indicate a Java arraystatic java.lang.String
CALENDAR_DATE_ALIAS
Alias for ajava.util.Calendar
that includes only date informationstatic java.lang.String
CALENDAR_DATETIME_ALIAS
Alias for ajava.util.Calendar
that includes both date and time information.static java.lang.String
CALENDAR_TIME_ALIAS
Alias for ajava.util.Calendar
that includes only time informationstatic java.lang.String
DATE_ALIAS
Alias for thejava.util.Date
class that includes only date informationstatic java.lang.String
DATETIME_ALIAS
Alias for ajava.util.Date
that includes both date and time information.static java.lang.String
TIME_ALIAS
Alias for ajava.util.Date
that includes only time information
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
isAliasOnly(java.lang.String alias)
Returnstrue
if the type alias is not used to register a type handler for its associated class.static boolean
isAssignable(java.lang.Class<?> to, java.lang.Class<?> from)
Returnstrue
ifto.isAssignableFrom(from)
after converting primitive values ofto
to its object counterpart.static java.lang.Class<?>
toAggregationType(java.lang.String type)
static java.lang.Class<?>
toBeanType(java.lang.ClassLoader classLoader, java.lang.String type)
static java.lang.Class<? extends java.util.Collection<java.lang.Object>>
toCollectionType(java.lang.String type)
Returns the collectionClass
object for a collection class name or type alias.static java.lang.Class<?>
toType(java.lang.ClassLoader classLoader, java.lang.String type)
Returns theClass
object for a class name or type alias.static java.lang.Class<?>
toWrapperClass(java.lang.Class<?> type)
Converts primitive types to their wrapper counterparts.
-
-
-
Field Detail
-
DATETIME_ALIAS
public static final java.lang.String DATETIME_ALIAS
Alias for ajava.util.Date
that includes both date and time information. If a type handler is registered using this alias, the registered type handler will become the default type handler for allDate
classes.- See Also:
- Constant Field Values
-
DATE_ALIAS
public static final java.lang.String DATE_ALIAS
Alias for thejava.util.Date
class that includes only date information- See Also:
- Constant Field Values
-
TIME_ALIAS
public static final java.lang.String TIME_ALIAS
Alias for ajava.util.Date
that includes only time information- See Also:
- Constant Field Values
-
CALENDAR_DATETIME_ALIAS
public static final java.lang.String CALENDAR_DATETIME_ALIAS
Alias for ajava.util.Calendar
that includes both date and time information. If a type handler is registered using this alias, the registered type handler will become the default type handler for allCalendar
classes.- See Also:
- Constant Field Values
-
CALENDAR_TIME_ALIAS
public static final java.lang.String CALENDAR_TIME_ALIAS
Alias for ajava.util.Calendar
that includes only time information- See Also:
- Constant Field Values
-
CALENDAR_DATE_ALIAS
public static final java.lang.String CALENDAR_DATE_ALIAS
Alias for ajava.util.Calendar
that includes only date information- See Also:
- Constant Field Values
-
ARRAY_TYPE
public static final java.lang.Class<? extends java.util.Collection<java.lang.Object>> ARRAY_TYPE
Class type used to indicate a Java array
-
-
Method Detail
-
isAssignable
public static boolean isAssignable(java.lang.Class<?> to, java.lang.Class<?> from)
Returnstrue
ifto.isAssignableFrom(from)
after converting primitive values ofto
to its object counterpart.- Parameters:
to
- the class or primitive to test assignability tofrom
- the class to test assignability from- Returns:
true
ifto
is assignable fromfrom
-
toWrapperClass
public static java.lang.Class<?> toWrapperClass(java.lang.Class<?> type)
Converts primitive types to their wrapper counterparts.- Parameters:
type
- the class type to convert- Returns:
- the wrapper equivalent for the primitive type, or if
type
was not a primitive, its returned as is
-
toType
public static java.lang.Class<?> toType(java.lang.ClassLoader classLoader, java.lang.String type)
Returns theClass
object for a class name or type alias. A type alias is not case sensitive. The following type aliases are supported:Alias Class or Primitive string java.lang.String boolean java.lang.Boolean byte java.lang.Byte int java.lang.Integer integer java.lang.Integer short java.lang.Short char java.lang.Character character java.lang.Character long java.lang.Long float java.lang.Float double java.lang.Double bigdecimal java.math.BigDecimal decimal java.math.BigDecimal biginteger java.math.BigInteger uuid java.util.UUID url java.net.URL date java.util.Date time java.util.Date datetime java.util.Date calendar java.util.Calendar - Parameters:
classLoader
- theClassLoader
for loading classestype
- the fully qualified class name or type alias- Returns:
- the class, or null if the type name is invalid
-
isAliasOnly
public static boolean isAliasOnly(java.lang.String alias)
Returnstrue
if the type alias is not used to register a type handler for its associated class.- Parameters:
alias
- the type alias to check- Returns:
true
if the type alias is only an alias
-
toCollectionType
public static java.lang.Class<? extends java.util.Collection<java.lang.Object>> toCollectionType(java.lang.String type)
Returns the collectionClass
object for a collection class name or type alias. A type alias is not case sensitive. The following collection type aliases are supported:Alias Class or Primitive array Java Array list java.util.ArrayList set java.util.HashSet - Parameters:
type
- the fully qualified class name or type alias of the collection- Returns:
- the collection class, or
ARRAY_TYPE
for array, ornull
if the type name is invalid
-
toAggregationType
public static java.lang.Class<?> toAggregationType(java.lang.String type)
-
toBeanType
public static java.lang.Class<?> toBeanType(java.lang.ClassLoader classLoader, java.lang.String type)
-
-