Skip to content

Commit 2a6488a

Browse files
committed
fix: fix judge bean
1 parent 66cb939 commit 2a6488a

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

uno-core/src/main/java/cc/allio/uno/core/type/Types.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,17 @@ public static boolean isArray(Class<?> clazz) {
244244
return clazz.isArray();
245245
}
246246

247-
248247
/**
249248
* 判断给定的class是否是Bean
250249
*
251250
* @param clazz class对象实例
252251
* @return true false
253252
*/
254253
public static boolean isBean(Class<?> clazz) {
255-
return !SIMPLE_TYPES.contains(clazz) && !isList(clazz) && !isMap(clazz);
254+
return !SIMPLE_TYPES.contains(clazz)
255+
&& !isList(clazz)
256+
&& !isMap(clazz)
257+
&& !clazz.isEnum();
256258
}
257259

258260
/**

uno-core/src/test/java/cc/allio/uno/core/type/TypeValueTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import cc.allio.uno.core.BaseTestCase;
44
import com.google.common.collect.Lists;
5+
import lombok.AllArgsConstructor;
56
import lombok.Data;
7+
import lombok.Getter;
68
import org.junit.jupiter.api.Test;
79

810
import java.lang.reflect.Field;
@@ -59,6 +61,14 @@ void testCompositeType() {
5961
assertEquals("n", children.getName());
6062
}
6163

64+
@Test
65+
void testEnumType() {
66+
Object success = new TypeValue(Status.class, "SUCCESS").tryConvert();
67+
68+
assertNotNull(success);
69+
assertEquals(Status.SUCCESS, success);
70+
}
71+
6272
public static class TypeSet {
6373
ENUM[] enums;
6474
List<ENUM> enumsList;
@@ -82,4 +92,14 @@ public static class Children {
8292
public static class Parent {
8393
private Children children;
8494
}
95+
96+
97+
@Getter
98+
@AllArgsConstructor
99+
public enum Status {
100+
SUCCESS("SUCCESS"),
101+
FAILED("FAILED");
102+
103+
private final String value;
104+
}
85105
}

uno-data/uno-data-mongodb/src/main/java/cc/allio/uno/data/orm/executor/mongodb/internal/MongodbQueryCommandExecutor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ public List<R> doExec(MongodbQueryOperator operator, ListResultSetHandler<R> han
102102
* @return the java value
103103
*/
104104
public Object toJavaValue(Object v) {
105+
if (v == null) {
106+
return null;
107+
}
105108
if (Types.isArray(v.getClass())) {
106109
return Arrays.stream(((Object[]) v)).map(this::toJavaValue).toArray(Object[]::new);
107110
} else if (v instanceof Collection<?> coll) {

0 commit comments

Comments
 (0)