Skip to content

Commit 26bc606

Browse files
authored
Merge pull request #2551 from Oliverwqcwrw/master-char-registry-12
[ISSSUE #2546]Register char
2 parents b1dd4aa + c3fe842 commit 26bc606

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2021 the original author or authors.
2+
* Copyright 2009-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -43,6 +43,8 @@ public TypeAliasRegistry() {
4343
registerAlias("string", String.class);
4444

4545
registerAlias("byte", Byte.class);
46+
registerAlias("char", Character.class);
47+
registerAlias("character", Character.class);
4648
registerAlias("long", Long.class);
4749
registerAlias("short", Short.class);
4850
registerAlias("int", Integer.class);
@@ -52,6 +54,8 @@ public TypeAliasRegistry() {
5254
registerAlias("boolean", Boolean.class);
5355

5456
registerAlias("byte[]", Byte[].class);
57+
registerAlias("char[]", Character[].class);
58+
registerAlias("character[]", Character[].class);
5559
registerAlias("long[]", Long[].class);
5660
registerAlias("short[]", Short[].class);
5761
registerAlias("int[]", Integer[].class);
@@ -61,6 +65,8 @@ public TypeAliasRegistry() {
6165
registerAlias("boolean[]", Boolean[].class);
6266

6367
registerAlias("_byte", byte.class);
68+
registerAlias("_char", char.class);
69+
registerAlias("_character", char.class);
6470
registerAlias("_long", long.class);
6571
registerAlias("_short", short.class);
6672
registerAlias("_int", int.class);
@@ -70,6 +76,8 @@ public TypeAliasRegistry() {
7076
registerAlias("_boolean", boolean.class);
7177

7278
registerAlias("_byte[]", byte[].class);
79+
registerAlias("_char[]", char[].class);
80+
registerAlias("_character[]", char[].class);
7381
registerAlias("_long[]", long[].class);
7482
registerAlias("_short[]", short[].class);
7583
registerAlias("_int[]", int[].class);

src/test/java/org/apache/ibatis/type/TypeAliasRegistryTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2021 the original author or authors.
2+
* Copyright 2009-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -67,4 +67,12 @@ void shouldBeAbleToRegisterNewTypeIfRegisteredTypeIsNull() {
6767
typeAliasRegistry.registerAlias("foo", String.class);
6868
}
6969

70+
@Test
71+
void shouldFetchCharType() {
72+
TypeAliasRegistry typeAliasRegistry = new TypeAliasRegistry();
73+
assertEquals(Character.class, typeAliasRegistry.resolveAlias("char"));
74+
assertEquals(Character[].class, typeAliasRegistry.resolveAlias("char[]"));
75+
assertEquals(char[].class, typeAliasRegistry.resolveAlias("_char[]"));
76+
}
77+
7078
}

0 commit comments

Comments
 (0)