mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-09-10 02:17:57 +00:00
perf[orm]: map type check
This commit is contained in:
@@ -543,9 +543,9 @@ public class OrmManager implements IOrmManager {
|
||||
var keyType = types[0];
|
||||
var valueType = types[1];
|
||||
|
||||
// if (!String.class.isAssignableFrom((Class<?>) keyType)) {
|
||||
// throw new RunException("[class:{}] type declaration is incorrect, and the key type of the Map must be the String type", clazz.getCanonicalName());
|
||||
// }
|
||||
if (!ClassUtils.isBaseType((Class<?>) keyType)) {
|
||||
throw new RunException("[class:{}] type declaration is incorrect, and the key type of the Map must be the Base type", clazz.getCanonicalName());
|
||||
}
|
||||
|
||||
checkSubEntity(clazz, valueType);
|
||||
} else if (ObjectId.class.isAssignableFrom(fieldType)) {
|
||||
@@ -574,9 +574,9 @@ public class OrmManager implements IOrmManager {
|
||||
var types = ((ParameterizedType) type).getActualTypeArguments();
|
||||
var keyType = types[0];
|
||||
var valueType = types[1];
|
||||
if (!String.class.isAssignableFrom((Class<?>) keyType)) {
|
||||
if (!ClassUtils.isBaseType((Class<?>) keyType)) {
|
||||
// ORM中Map的key必须是String类型
|
||||
throw new RunException("The key of the map in the ORM must be of the String type");
|
||||
throw new RunException("The key of the map in the ORM must be of the Base type");
|
||||
}
|
||||
checkSubEntity(currentEntityClass, valueType);
|
||||
return;
|
||||
|
||||
@@ -20,16 +20,8 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.JarURLConnection;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
@@ -484,7 +476,7 @@ public abstract class ClassUtils {
|
||||
throw new RunException("[type:{}]类型不正确", type);
|
||||
}
|
||||
|
||||
private static boolean isBaseType(Class<?> clazz) {
|
||||
public static boolean isBaseType(Class<?> clazz) {
|
||||
return clazz.isPrimitive()
|
||||
|| Number.class.isAssignableFrom(clazz)
|
||||
|| String.class.isAssignableFrom(clazz)
|
||||
|
||||
Reference in New Issue
Block a user