Package org.beanio.internal.util
Class TypeUtil
- java.lang.Object
-
- org.beanio.internal.util.TypeUtil
-
public class TypeUtil extends java.lang.ObjectUtility 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_TYPEClass type used to indicate a Java arraystatic java.lang.StringCALENDAR_DATE_ALIASAlias for ajava.util.Calendarthat includes only date informationstatic java.lang.StringCALENDAR_DATETIME_ALIASAlias for ajava.util.Calendarthat includes both date and time information.static java.lang.StringCALENDAR_TIME_ALIASAlias for ajava.util.Calendarthat includes only time informationstatic java.lang.StringDATE_ALIASAlias for thejava.util.Dateclass that includes only date informationstatic java.lang.StringDATETIME_ALIASAlias for ajava.util.Datethat includes both date and time information.static java.lang.StringTIME_ALIASAlias for ajava.util.Datethat includes only time information
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisAliasOnly(java.lang.String alias)Returnstrueif the type alias is not used to register a type handler for its associated class.static booleanisAssignable(java.lang.Class<?> to, java.lang.Class<?> from)Returnstrueifto.isAssignableFrom(from)after converting primitive values oftoto 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 collectionClassobject for a collection class name or type alias.static java.lang.Class<?>toType(java.lang.ClassLoader classLoader, java.lang.String type)Returns theClassobject 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.Datethat 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 allDateclasses.- See Also:
- Constant Field Values
-
DATE_ALIAS
public static final java.lang.String DATE_ALIAS
Alias for thejava.util.Dateclass that includes only date information- See Also:
- Constant Field Values
-
TIME_ALIAS
public static final java.lang.String TIME_ALIAS
Alias for ajava.util.Datethat 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.Calendarthat 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 allCalendarclasses.- See Also:
- Constant Field Values
-
CALENDAR_TIME_ALIAS
public static final java.lang.String CALENDAR_TIME_ALIAS
Alias for ajava.util.Calendarthat 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.Calendarthat 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)Returnstrueifto.isAssignableFrom(from)after converting primitive values oftoto its object counterpart.- Parameters:
to- the class or primitive to test assignability tofrom- the class to test assignability from- Returns:
trueiftois 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
typewas not a primitive, its returned as is
-
toType
public static java.lang.Class<?> toType(java.lang.ClassLoader classLoader, java.lang.String type)Returns theClassobject 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- theClassLoaderfor 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)
Returnstrueif the type alias is not used to register a type handler for its associated class.- Parameters:
alias- the type alias to check- Returns:
trueif 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 collectionClassobject 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_TYPEfor array, ornullif 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)
-
-