加强注释

This commit is contained in:
redkale
2023-11-10 22:01:20 +08:00
parent 3eb357055f
commit 553622cfec
8 changed files with 47 additions and 18 deletions

View File

@@ -43,7 +43,7 @@ public class JsonBytesWriter extends JsonWriter implements ByteTuple {
private byte[] content;
public JsonBytesWriter() {
this(defaultSize);
this(DEFAULT_SIZE);
}
public JsonBytesWriter(int size) {
@@ -76,8 +76,8 @@ public class JsonBytesWriter extends JsonWriter implements ByteTuple {
public boolean recycle() {
super.recycle();
this.count = 0;
if (this.content != null && this.content.length > defaultSize * 100) {
this.content = new byte[defaultSize];
if (this.content != null && this.content.length > DEFAULT_SIZE * 100) {
this.content = new byte[DEFAULT_SIZE];
}
return true;
}

View File

@@ -19,7 +19,7 @@ import org.redkale.convert.*;
*/
public abstract class JsonWriter extends Writer {
protected static final int defaultSize = Integer.getInteger("redkale.convert.json.writer.buffer.defsize", Integer.getInteger("redkale.convert.writer.buffer.defsize", 1024));
protected static final int DEFAULT_SIZE = Integer.getInteger("redkale.convert.json.writer.buffer.defsize", Integer.getInteger("redkale.convert.writer.buffer.defsize", 1024));
protected JsonWriter() {
this.features = JsonFactory.root().getFeatures();

View File

@@ -7,6 +7,7 @@ package org.redkale.source;
import java.util.Objects;
import org.redkale.annotation.ConstructorParameters;
import org.redkale.convert.ConvertColumn;
/**
* FilterKey主要用于自身字段间的表达式, 如: a.recordid = a.parentid , a.parentid就需要FilterKey来表示 new FilterKey("parentid")
@@ -20,6 +21,7 @@ import org.redkale.annotation.ConstructorParameters;
*/
public class FilterKey implements java.io.Serializable {
@ConvertColumn(index = 1)
private final String column;
@ConstructorParameters({"column"})

View File

@@ -697,6 +697,7 @@ public interface Copier<S, D> extends BiFunction<S, D, D> {
Class clz = RedkaleClassLoader.findDynClass(newDynName.replace('/', '.'));
return (Copier) (clz == null ? loader.loadClass(newDynName.replace('/', '.')) : clz).getDeclaredConstructor().newInstance();
} catch (Throwable ex) {
//do nothing
}
// ------------------------------------------------------------------------------

View File

@@ -35,6 +35,9 @@ class Inners {
static final IntFunction<String[]> stringFuncArray = x -> new String[x];
private CreatorInner() {
}
static {
creatorCacheMap.put(Object.class, p -> new Object());
creatorCacheMap.put(ArrayList.class, p -> new ArrayList<>());
@@ -187,6 +190,7 @@ class Inners {
field = cz.getDeclaredField(names[i]);
break;
} catch (NoSuchFieldException nsfe) {
//do nothing
}
}
if (field == null) {
@@ -225,6 +229,7 @@ class Inners {
Class clz = RedkaleClassLoader.findDynClass(newDynName.replace('/', '.'));
return (IntFunction) (clz == null ? loader.loadClass(newDynName.replace('/', '.')) : clz).getDeclaredConstructor().newInstance();
} catch (Throwable ex) {
//do nothing
}
//-------------------------------------------------------------
@@ -289,6 +294,9 @@ class Inners {
static final ConcurrentHashMap<Class, ConcurrentHashMap<Integer, ConcurrentHashMap<Class, ConcurrentHashMap<Class, Function>>>> copierFuncListTwoCaches = new ConcurrentHashMap();
private CopierInner() {
}
public static void clearCopierCache() {
copierOneCaches.clear();
copierTwoCaches.clear();
@@ -303,5 +311,7 @@ class Inners {
static final ConcurrentHashMap<Class, ConcurrentHashMap<Method, Invoker>> invokerCaches = new ConcurrentHashMap();
private InvokerInner() {
}
}
}

View File

@@ -34,6 +34,7 @@ public class RedkaleClassLoader extends URLClassLoader {
try {
url = URI.create("file://redkale/uri").toURL(); //不能是jar结尾否则会视为jar文件url
} catch (MalformedURLException e) {
//do nothing
}
URL_NONE = url;
}
@@ -42,16 +43,26 @@ public class RedkaleClassLoader extends URLClassLoader {
private static final String[] buildPackages = {
"org.redkaledyn", //所有动态生成类的根package
"org.redkale.annotation", "org.redkale.asm",
"org.redkale.boot", "org.redkale.boot.watch",
"org.redkale.cluster", "org.redkale.convert",
"org.redkale.convert.bson", "org.redkale.convert.ext",
"org.redkale.convert.json", "org.redkale.convert.protobuf",
"org.redkale.mq", "org.redkale.net",
"org.redkale.net.client", "org.redkale.net.http",
"org.redkale.net.sncp", "org.redkale.persistence",
"org.redkale.service", "org.redkale.source",
"org.redkale.util", "org.redkale.watch"
"org.redkale.annotation",
"org.redkale.asm",
"org.redkale.boot",
"org.redkale.boot.watch",
"org.redkale.cluster",
"org.redkale.convert",
"org.redkale.convert.bson",
"org.redkale.convert.ext",
"org.redkale.convert.json",
"org.redkale.convert.protobuf",
"org.redkale.mq",
"org.redkale.net",
"org.redkale.net.client",
"org.redkale.net.http",
"org.redkale.net.sncp",
"org.redkale.persistence",
"org.redkale.service",
"org.redkale.source",
"org.redkale.util",
"org.redkale.watch"
};
//redkale里所有使用动态字节码生成的类都需要存于此处
@@ -473,6 +484,7 @@ public class RedkaleClassLoader extends URLClassLoader {
try {
set.add(Paths.get(path.replace("&&", "://").replace("##", ":\\")).toRealPath().toFile().toURI().toURL());
} catch (Exception e) {
//do nothing
}
}
}
@@ -497,6 +509,7 @@ public class RedkaleClassLoader extends URLClassLoader {
ucp = field.get(loader);
break;
} catch (Throwable e) {
//do nothing
}
} while ((loaderClazz = loaderClazz.getSuperclass()) != Object.class);
if (ucp != null) { //URLClassPath
@@ -505,6 +518,7 @@ public class RedkaleClassLoader extends URLClassLoader {
Method method = ucp.getClass().getMethod("getURLs");
urls = (URL[]) method.invoke(ucp);
} catch (Exception e) {
//do nothing
}
if (urls != null) {
for (URL url : urls) {

View File

@@ -43,7 +43,7 @@ public abstract class TypeToken<T> {
*
* @return 是否可反解析
*/
public final static boolean isClassType(final Type type) {
public static final boolean isClassType(final Type type) {
if (type instanceof Class) {
return true;
}
@@ -74,7 +74,7 @@ public abstract class TypeToken<T> {
return true;
}
public final static boolean containsUnknownType(final Type type) {
public static final boolean containsUnknownType(final Type type) {
if (type == null) {
return false;
}
@@ -111,7 +111,7 @@ public abstract class TypeToken<T> {
return true;
}
public final static Class typeToClass(final Type type) {
public static final Class typeToClass(final Type type) {
if (type instanceof Class) {
return (Class) type;
}
@@ -133,7 +133,7 @@ public abstract class TypeToken<T> {
return typeToClass(raw != null ? raw : owner);
}
public final static Class typeToClassOrElse(final Type type, final Class defClass) {
public static final Class typeToClassOrElse(final Type type, final Class defClass) {
Class clazz = typeToClass(type);
return clazz == null ? defClass : clazz;
}

View File

@@ -189,7 +189,9 @@ public class XmlReader {
throw newException("illegal character " + ch);
}
} else if (ch >= 'a' && ch <= 'z') {
//do nothing
} else if (ch >= 'A' && ch <= 'Z') {
//do nothing
} else if (ch == '.' || ch == '-' || ch == '_' || ch == ':') {
if (first) {
throw newException("illegal character " + ch);