Class CodedValueTypeHandler<E extends Enum<E> & net.solarnetwork.domain.CodedValue>
java.lang.Object
org.apache.ibatis.type.TypeReference<E>
org.apache.ibatis.type.BaseTypeHandler<E>
net.solarnetwork.central.dao.mybatis.type.CodedValueTypeHandler<E>
- Type Parameters:
E- the enum type
- All Implemented Interfaces:
org.apache.ibatis.type.TypeHandler<E>
- Direct Known Subclasses:
CodedValueTypeHandler.Zero
public class CodedValueTypeHandler<E extends Enum<E> & net.solarnetwork.domain.CodedValue>
extends org.apache.ibatis.type.BaseTypeHandler<E>
Type handler for enum values that implement
CodedValue so that an
integer database column is used for storage.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCodedValueTypeHandler.Zero<E extends Enum<E> & net.solarnetwork.domain.CodedValue>CodedValueenum handler that defaults to code 0. -
Field Summary
Fields inherited from class org.apache.ibatis.type.BaseTypeHandler
configuration -
Constructor Summary
ConstructorsConstructorDescriptionCodedValueTypeHandler(Class<E> type) Constructor.CodedValueTypeHandler(Class<E> type, E defaultValue) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiongetNullableResult(CallableStatement cs, int columnIndex) getNullableResult(ResultSet rs, int columnIndex) getNullableResult(ResultSet rs, String columnName) getType()Get the class type.voidsetNonNullParameter(PreparedStatement ps, int i, E parameter, org.apache.ibatis.type.JdbcType jdbcType) voidsetParameter(PreparedStatement ps, int i, E parameter, org.apache.ibatis.type.JdbcType jdbcType) Methods inherited from class org.apache.ibatis.type.BaseTypeHandler
getResult, getResult, getResult, setConfigurationMethods inherited from class org.apache.ibatis.type.TypeReference
getRawType, toString
-
Constructor Details
-
CodedValueTypeHandler
Constructor.This will attempt to resolve a code value 0 for a default value, falling back to null if that is not found.
- Parameters:
type- the type
-
CodedValueTypeHandler
Constructor.- Parameters:
type- the typedefaultValue- the default value to use if no matching code is found
-
-
Method Details
-
setParameter
public void setParameter(PreparedStatement ps, int i, E parameter, org.apache.ibatis.type.JdbcType jdbcType) throws SQLException -
setNonNullParameter
public void setNonNullParameter(PreparedStatement ps, int i, E parameter, org.apache.ibatis.type.JdbcType jdbcType) throws SQLException - Specified by:
setNonNullParameterin classorg.apache.ibatis.type.BaseTypeHandler<E extends Enum<E> & net.solarnetwork.domain.CodedValue>- Throws:
SQLException
-
getNullableResult
- Specified by:
getNullableResultin classorg.apache.ibatis.type.BaseTypeHandler<E extends Enum<E> & net.solarnetwork.domain.CodedValue>- Throws:
SQLException
-
getNullableResult
- Specified by:
getNullableResultin classorg.apache.ibatis.type.BaseTypeHandler<E extends Enum<E> & net.solarnetwork.domain.CodedValue>- Throws:
SQLException
-
getNullableResult
- Specified by:
getNullableResultin classorg.apache.ibatis.type.BaseTypeHandler<E extends Enum<E> & net.solarnetwork.domain.CodedValue>- Throws:
SQLException
-
getType
Get the class type.- Returns:
- the type, never null
-