code style
This commit is contained in:
parent
1c5ef2cfb6
commit
a815063b53
@ -16,7 +16,6 @@
|
||||
package com.baomidou.mybatisplus.core.handlers;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import lombok.Setter;
|
||||
import org.apache.ibatis.type.EnumTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.TypeException;
|
||||
@ -37,7 +36,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class CompositeEnumTypeHandler<E extends Enum<E>> implements TypeHandler<E> {
|
||||
|
||||
private static final Map<Class<?>, Boolean> MP_ENUM_CACHE = new ConcurrentHashMap<>();
|
||||
@Setter
|
||||
private static Class<? extends TypeHandler> defaultEnumTypeHandler = EnumTypeHandler.class;
|
||||
private final TypeHandler<E> delegate;
|
||||
|
||||
@ -52,6 +50,12 @@ public class CompositeEnumTypeHandler<E extends Enum<E>> implements TypeHandler<
|
||||
}
|
||||
}
|
||||
|
||||
public static void setDefaultEnumTypeHandler(Class<? extends TypeHandler> defaultEnumTypeHandler) {
|
||||
if (defaultEnumTypeHandler != null && !MybatisEnumTypeHandler.class.isAssignableFrom(defaultEnumTypeHandler)) {
|
||||
CompositeEnumTypeHandler.defaultEnumTypeHandler = defaultEnumTypeHandler;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameter(PreparedStatement ps, int i, E parameter, JdbcType jdbcType) throws SQLException {
|
||||
delegate.setParameter(ps, i, parameter, jdbcType);
|
||||
|
@ -46,7 +46,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* @author hubin
|
||||
* @since 2017-10-11
|
||||
*/
|
||||
public class MybatisEnumTypeHandler<E extends Enum<E>> extends BaseTypeHandler<E> {
|
||||
public final class MybatisEnumTypeHandler<E extends Enum<E>> extends BaseTypeHandler<E> {
|
||||
|
||||
private static final Map<String, String> TABLE_METHOD_OF_ENUM_TYPES = new ConcurrentHashMap<>();
|
||||
private static final ReflectorFactory REFLECTOR_FACTORY = new DefaultReflectorFactory();
|
||||
|
Loading…
x
Reference in New Issue
Block a user