Skip to content

Commit 73c3320

Browse files
committed
Support anonymous enum object that implement method
Fixes gh-1489
1 parent 51710ed commit 73c3320

File tree

5 files changed

+5
-6
lines changed

5 files changed

+5
-6
lines changed

src/main/java/org/apache/ibatis/type/TypeHandlerRegistry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ private Map<JdbcType, TypeHandler<?>> getJdbcHandlerMap(Type type) {
241241
}
242242
if (jdbcHandlerMap == null && type instanceof Class) {
243243
Class<?> clazz = (Class<?>) type;
244-
if (clazz.isEnum()) {
244+
if (clazz.isEnum() || (clazz.isAnonymousClass() && clazz.getEnclosingClass().isEnum())) {
245245
jdbcHandlerMap = getJdbcHandlerMapForEnumInterfaces(clazz, clazz);
246246
if (jdbcHandlerMap == null) {
247247
register(clazz, getInstance(clazz, defaultEnumTypeHandler));

src/test/java/org/apache/ibatis/submitted/enum_with_method/Currency.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/**
22
* Copyright 2009-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package org.apache.ibatis.submitted.enum_with_method;
1817

1918
import java.math.BigDecimal;

src/test/java/org/apache/ibatis/submitted/enum_with_method/EnumWithMethodTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/**
22
* Copyright 2009-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");

src/test/java/org/apache/ibatis/submitted/enum_with_method/Mapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/**
22
* Copyright 2009-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");

src/test/java/org/apache/ibatis/submitted/enum_with_method/User.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/**
22
* Copyright 2009-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");

0 commit comments

Comments
 (0)