Package io.ebeaninternal.server.type
Class DefaultTypeManager
- java.lang.Object
-
- io.ebeaninternal.server.type.DefaultTypeManager
-
- All Implemented Interfaces:
TypeManager
public final class DefaultTypeManager extends Object implements TypeManager
Default implementation of TypeManager.Manages the list of ScalarType that is available.
-
-
Constructor Summary
Constructors Constructor Description DefaultTypeManager(ServerConfig config, BootupClasses bootupClasses)
Create the DefaultTypeManager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(ScalarType<?> scalarType)
Register a custom ScalarType.void
addEnumType(ScalarType<?> scalarType, Class<? extends Enum> enumClass)
Register the ScalarType for an enum.Object
convert(Object value, int toJdbcType)
Convert the Object to the required datatype.ScalarType<?>
createEnumScalarType(Class<? extends Enum<?>> enumType, javax.persistence.EnumType type)
Create a ScalarType for an Enum that has additional mapping.ScalarType<?>
getArrayScalarType(Class<?> type, io.ebean.annotation.DbArray dbArray, Type genericType, boolean nullable)
Return the ScalarType used to handle DB ARRAY.ScalarType<?>
getDbMapScalarType()
Return the ScalarType used to handle HSTORE (Map). ScalarType<?>
getJsonScalarType(DeployBeanProperty prop, int dbType, int dbLength)
Return the ScalarType used to handle JSON content.ScalarType<?>
getScalarType(int jdbcType)
Return the ScalarType for the given jdbc type as per java.sql.Types.ScalarType<?>
getScalarType(Class<?> type)
This can return null if no matching ScalarType is found.ScalarType<?>
getScalarType(Class<?> type, int jdbcType)
Return a ScalarType for a given class.ScalarType<?>
getScalarType(String cast)
Return the scalar type for the given logical type.
-
-
-
Constructor Detail
-
DefaultTypeManager
public DefaultTypeManager(ServerConfig config, BootupClasses bootupClasses)
Create the DefaultTypeManager.
-
-
Method Detail
-
add
public void add(ScalarType<?> scalarType)
Register a custom ScalarType.- Specified by:
add
in interfaceTypeManager
-
addEnumType
public void addEnumType(ScalarType<?> scalarType, Class<? extends Enum> enumClass)
Register the ScalarType for an enum. This is special in the sense that an Enum can have many classes if it uses method overrides and we need to register all the variations/classes for the enum.- Specified by:
addEnumType
in interfaceTypeManager
-
getScalarType
public ScalarType<?> getScalarType(String cast)
Description copied from interface:TypeManager
Return the scalar type for the given logical type.- Specified by:
getScalarType
in interfaceTypeManager
-
getScalarType
public ScalarType<?> getScalarType(int jdbcType)
Return the ScalarType for the given jdbc type as per java.sql.Types.- Specified by:
getScalarType
in interfaceTypeManager
- Parameters:
jdbcType
- as per java.sql.Types
-
getScalarType
public ScalarType<?> getScalarType(Class<?> type)
This can return null if no matching ScalarType is found.- Specified by:
getScalarType
in interfaceTypeManager
-
getDbMapScalarType
public ScalarType<?> getDbMapScalarType()
Description copied from interface:TypeManager
Return the ScalarType used to handle HSTORE (Map). - Specified by:
getDbMapScalarType
in interfaceTypeManager
-
getArrayScalarType
public ScalarType<?> getArrayScalarType(Class<?> type, io.ebean.annotation.DbArray dbArray, Type genericType, boolean nullable)
Description copied from interface:TypeManager
Return the ScalarType used to handle DB ARRAY.- Specified by:
getArrayScalarType
in interfaceTypeManager
-
getJsonScalarType
public ScalarType<?> getJsonScalarType(DeployBeanProperty prop, int dbType, int dbLength)
Description copied from interface:TypeManager
Return the ScalarType used to handle JSON content.Note that type expected to be JsonNode or Map.
- Specified by:
getJsonScalarType
in interfaceTypeManager
-
getScalarType
public ScalarType<?> getScalarType(Class<?> type, int jdbcType)
Return a ScalarType for a given class.Used for java.util.Date and java.util.Calendar which can be mapped to different jdbcTypes in a single system.
- Specified by:
getScalarType
in interfaceTypeManager
-
convert
public Object convert(Object value, int toJdbcType)
Convert the Object to the required datatype. The- Parameters:
value
- the Object valuetoJdbcType
- the type as per java.sql.Types.
-
createEnumScalarType
public ScalarType<?> createEnumScalarType(Class<? extends Enum<?>> enumType, javax.persistence.EnumType type)
Create a ScalarType for an Enum that has additional mapping.The reason for this is that often in a DB there will be short codes used such as A,I,N rather than the ACTIVE, INACTIVE, NEW. So there really needs to be a mapping from the nicely named enumeration values to the typically much shorter codes used in the DB.
- Specified by:
createEnumScalarType
in interfaceTypeManager
-
-