Creator
This commit is contained in:
@@ -7,8 +7,8 @@ package org.redkale.util;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.net.*;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.*;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.*;
|
||||
import org.redkale.annotation.ConstructorParameters;
|
||||
@@ -101,6 +101,10 @@ public interface Creator<T> {
|
||||
return Inners.CreatorInner.arrayCacheMap.computeIfAbsent(type, Inners.CreatorInner::createArrayFunction);
|
||||
}
|
||||
|
||||
public static IntFunction<String[]> funcStringArray() {
|
||||
return Inners.CreatorInner.stringFuncArray;
|
||||
}
|
||||
|
||||
public static <T> Creator<T> load(Class<T> clazz) {
|
||||
return Inners.CreatorInner.creatorCacheMap.computeIfAbsent(clazz, v -> create(clazz));
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ class Inners {
|
||||
|
||||
static final Map<Class, IntFunction> arrayCacheMap = new ConcurrentHashMap<>();
|
||||
|
||||
static final IntFunction<String[]> stringFuncArray = x -> new String[x];
|
||||
|
||||
static {
|
||||
creatorCacheMap.put(Object.class, p -> new Object());
|
||||
creatorCacheMap.put(ArrayList.class, p -> new ArrayList<>());
|
||||
|
||||
Reference in New Issue
Block a user