This commit is contained in:
Looly 2022-06-21 18:42:52 +08:00
parent 8080a1cd83
commit 1ee014bdae
123 changed files with 275 additions and 270 deletions

View File

@ -63,7 +63,7 @@ public class Hutool {
*/ */
public static void printAllUtils() { public static void printAllUtils() {
final Set<Class<?>> allUtils = getAllUtils(); final Set<Class<?>> allUtils = getAllUtils();
final ConsoleTable consoleTable = ConsoleTable.create().addHeader("工具类名", "所在包"); final ConsoleTable consoleTable = ConsoleTable.of().addHeader("工具类名", "所在包");
for (final Class<?> clazz : allUtils) { for (final Class<?> clazz : allUtils) {
consoleTable.addBody(clazz.getSimpleName(), clazz.getPackage().getName()); consoleTable.addBody(clazz.getSimpleName(), clazz.getPackage().getName());
} }

View File

@ -35,7 +35,7 @@ public enum GlobalPruneTimer {
* 构造 * 构造
*/ */
GlobalPruneTimer() { GlobalPruneTimer() {
create(); init();
} }
/** /**
@ -50,9 +50,9 @@ public enum GlobalPruneTimer {
} }
/** /**
* 创建定时器 * 初始化定时器
*/ */
public void create() { public void init() {
if (null != pruneTimer) { if (null != pruneTimer) {
shutdownNow(); shutdownNow();
} }

View File

@ -60,7 +60,7 @@ public class UniqueKeySet<K, V> extends AbstractSet<V> implements Serializable {
* @param uniqueGenerator 唯一键生成规则函数用于生成对象对应的唯一键 * @param uniqueGenerator 唯一键生成规则函数用于生成对象对应的唯一键
*/ */
public UniqueKeySet(final boolean isLinked, final Function<V, K> uniqueGenerator) { public UniqueKeySet(final boolean isLinked, final Function<V, K> uniqueGenerator) {
this(MapBuilder.create(isLinked), uniqueGenerator); this(MapBuilder.of(isLinked), uniqueGenerator);
} }
/** /**
@ -84,7 +84,7 @@ public class UniqueKeySet<K, V> extends AbstractSet<V> implements Serializable {
* @param uniqueGenerator 唯一键生成规则函数用于生成对象对应的唯一键 * @param uniqueGenerator 唯一键生成规则函数用于生成对象对应的唯一键
*/ */
public UniqueKeySet(final int initialCapacity, final float loadFactor, final Function<V, K> uniqueGenerator) { public UniqueKeySet(final int initialCapacity, final float loadFactor, final Function<V, K> uniqueGenerator) {
this(MapBuilder.create(new HashMap<>(initialCapacity, loadFactor)), uniqueGenerator); this(MapBuilder.of(new HashMap<>(initialCapacity, loadFactor)), uniqueGenerator);
} }
/** /**

View File

@ -72,9 +72,9 @@ public class CompilerUtil {
* *
* @param parent {@link ClassLoader} * @param parent {@link ClassLoader}
* @return {@link JavaSourceCompiler} * @return {@link JavaSourceCompiler}
* @see JavaSourceCompiler#create(ClassLoader) * @see JavaSourceCompiler#of(ClassLoader)
*/ */
public static JavaSourceCompiler getCompiler(final ClassLoader parent) { public static JavaSourceCompiler getCompiler(final ClassLoader parent) {
return JavaSourceCompiler.create(parent); return JavaSourceCompiler.of(parent);
} }
} }

View File

@ -75,7 +75,7 @@ public class JavaSourceCompiler {
* @param parent 父类加载器 * @param parent 父类加载器
* @return Java源码编译器 * @return Java源码编译器
*/ */
public static JavaSourceCompiler create(final ClassLoader parent) { public static JavaSourceCompiler of(final ClassLoader parent) {
return new JavaSourceCompiler(parent); return new JavaSourceCompiler(parent);
} }

View File

@ -69,7 +69,7 @@ public class BeanConverter implements Converter, Serializable {
BeanUtil.isBean(value.getClass())) { BeanUtil.isBean(value.getClass())) {
if (value instanceof Map && targetClass.isInterface()) { if (value instanceof Map && targetClass.isInterface()) {
// 将Map动态代理为Bean // 将Map动态代理为Bean
return MapProxy.create((Map<?, ?>) value).toProxyBean(targetClass); return MapProxy.of((Map<?, ?>) value).toProxyBean(targetClass);
} }
//限定被转换对象类型 //限定被转换对象类型

View File

@ -1,6 +1,11 @@
package cn.hutool.core.date; package cn.hutool.core.date.chinese;
import cn.hutool.core.convert.NumberChineseFormatter; import cn.hutool.core.convert.NumberChineseFormatter;
import cn.hutool.core.date.CalendarUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.TimeUtil;
import cn.hutool.core.date.Zodiac;
import cn.hutool.core.date.chinese.ChineseMonth; import cn.hutool.core.date.chinese.ChineseMonth;
import cn.hutool.core.date.chinese.GanZhi; import cn.hutool.core.date.chinese.GanZhi;
import cn.hutool.core.date.chinese.LunarFestival; import cn.hutool.core.date.chinese.LunarFestival;

View File

@ -1,6 +1,5 @@
package cn.hutool.core.date.chinese; package cn.hutool.core.date.chinese;
import cn.hutool.core.date.ChineseDate;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.math.NumberUtil; import cn.hutool.core.math.NumberUtil;

View File

@ -222,7 +222,7 @@ public class BufferUtil {
* @return {@link ByteBuffer} * @return {@link ByteBuffer}
* @since 4.5.0 * @since 4.5.0
*/ */
public static ByteBuffer create(final byte[] data) { public static ByteBuffer of(final byte[] data) {
return ByteBuffer.wrap(data); return ByteBuffer.wrap(data);
} }
@ -234,8 +234,8 @@ public class BufferUtil {
* @return {@link ByteBuffer} * @return {@link ByteBuffer}
* @since 4.5.0 * @since 4.5.0
*/ */
public static ByteBuffer create(final CharSequence data, final Charset charset) { public static ByteBuffer of(final CharSequence data, final Charset charset) {
return create(StrUtil.bytes(data, charset)); return of(StrUtil.bytes(data, charset));
} }
/** /**
@ -246,7 +246,7 @@ public class BufferUtil {
* @since 4.5.0 * @since 4.5.0
*/ */
public static ByteBuffer createUtf8(final CharSequence data) { public static ByteBuffer createUtf8(final CharSequence data) {
return create(StrUtil.utf8Bytes(data)); return of(StrUtil.utf8Bytes(data));
} }
/** /**

View File

@ -29,7 +29,7 @@ public class FileSystemUtil {
* @param path 文件路径可以是目录或Zip文件等 * @param path 文件路径可以是目录或Zip文件等
* @return {@link FileSystem} * @return {@link FileSystem}
*/ */
public static FileSystem create(final String path) { public static FileSystem of(final String path) {
try { try {
return FileSystems.newFileSystem( return FileSystems.newFileSystem(
Paths.get(path).toUri(), Paths.get(path).toUri(),

View File

@ -195,8 +195,8 @@ public class WatchMonitor extends WatchServer {
* @param watcher {@link Watcher} * @param watcher {@link Watcher}
* @return WatchMonitor * @return WatchMonitor
*/ */
public static WatchMonitor createAll(final URI uri, final Watcher watcher) { public static WatchMonitor ofAll(final URI uri, final Watcher watcher) {
return createAll(Paths.get(uri), watcher); return ofAll(Paths.get(uri), watcher);
} }
/** /**
@ -206,9 +206,9 @@ public class WatchMonitor extends WatchServer {
* @param watcher {@link Watcher} * @param watcher {@link Watcher}
* @return WatchMonitor * @return WatchMonitor
*/ */
public static WatchMonitor createAll(final URL url, final Watcher watcher) { public static WatchMonitor ofAll(final URL url, final Watcher watcher) {
try { try {
return createAll(Paths.get(url.toURI()), watcher); return ofAll(Paths.get(url.toURI()), watcher);
} catch (final URISyntaxException e) { } catch (final URISyntaxException e) {
throw new WatchException(e); throw new WatchException(e);
} }
@ -221,8 +221,8 @@ public class WatchMonitor extends WatchServer {
* @param watcher {@link Watcher} * @param watcher {@link Watcher}
* @return WatchMonitor * @return WatchMonitor
*/ */
public static WatchMonitor createAll(final File file, final Watcher watcher) { public static WatchMonitor ofAll(final File file, final Watcher watcher) {
return createAll(file.toPath(), watcher); return ofAll(file.toPath(), watcher);
} }
/** /**
@ -232,8 +232,8 @@ public class WatchMonitor extends WatchServer {
* @param watcher {@link Watcher} * @param watcher {@link Watcher}
* @return WatchMonitor * @return WatchMonitor
*/ */
public static WatchMonitor createAll(final String path, final Watcher watcher) { public static WatchMonitor ofAll(final String path, final Watcher watcher) {
return createAll(Paths.get(path), watcher); return ofAll(Paths.get(path), watcher);
} }
/** /**
@ -243,7 +243,7 @@ public class WatchMonitor extends WatchServer {
* @param watcher {@link Watcher} * @param watcher {@link Watcher}
* @return WatchMonitor * @return WatchMonitor
*/ */
public static WatchMonitor createAll(final Path path, final Watcher watcher) { public static WatchMonitor ofAll(final Path path, final Watcher watcher) {
final WatchMonitor watchMonitor = of(path, EVENTS_ALL); final WatchMonitor watchMonitor = of(path, EVENTS_ALL);
watchMonitor.setWatcher(watcher); watchMonitor.setWatcher(watcher);
return watchMonitor; return watchMonitor;

View File

@ -145,8 +145,8 @@ public class WatchUtil {
* @param watcher {@link Watcher} * @param watcher {@link Watcher}
* @return {@link WatchMonitor} * @return {@link WatchMonitor}
*/ */
public static WatchMonitor createAll(final URL url, final Watcher watcher) { public static WatchMonitor ofAll(final URL url, final Watcher watcher) {
return createAll(url, 0, watcher); return ofAll(url, 0, watcher);
} }
/** /**
@ -157,8 +157,8 @@ public class WatchUtil {
* @param watcher {@link Watcher} * @param watcher {@link Watcher}
* @return {@link WatchMonitor} * @return {@link WatchMonitor}
*/ */
public static WatchMonitor createAll(final URL url, final int maxDepth, final Watcher watcher) { public static WatchMonitor ofAll(final URL url, final int maxDepth, final Watcher watcher) {
return createAll(URLUtil.toURI(url), maxDepth, watcher); return ofAll(URLUtil.toURI(url), maxDepth, watcher);
} }
/** /**
@ -168,8 +168,8 @@ public class WatchUtil {
* @param watcher {@link Watcher} * @param watcher {@link Watcher}
* @return {@link WatchMonitor} * @return {@link WatchMonitor}
*/ */
public static WatchMonitor createAll(final URI uri, final Watcher watcher) { public static WatchMonitor ofAll(final URI uri, final Watcher watcher) {
return createAll(uri, 0, watcher); return ofAll(uri, 0, watcher);
} }
/** /**
@ -180,8 +180,8 @@ public class WatchUtil {
* @param watcher {@link Watcher} * @param watcher {@link Watcher}
* @return {@link WatchMonitor} * @return {@link WatchMonitor}
*/ */
public static WatchMonitor createAll(final URI uri, final int maxDepth, final Watcher watcher) { public static WatchMonitor ofAll(final URI uri, final int maxDepth, final Watcher watcher) {
return createAll(Paths.get(uri), maxDepth, watcher); return ofAll(Paths.get(uri), maxDepth, watcher);
} }
/** /**
@ -191,8 +191,8 @@ public class WatchUtil {
* @param watcher {@link Watcher} * @param watcher {@link Watcher}
* @return {@link WatchMonitor} * @return {@link WatchMonitor}
*/ */
public static WatchMonitor createAll(final File file, final Watcher watcher) { public static WatchMonitor ofAll(final File file, final Watcher watcher) {
return createAll(file, 0, watcher); return ofAll(file, 0, watcher);
} }
/** /**
@ -203,8 +203,8 @@ public class WatchUtil {
* @param watcher {@link Watcher} * @param watcher {@link Watcher}
* @return {@link WatchMonitor} * @return {@link WatchMonitor}
*/ */
public static WatchMonitor createAll(final File file, final int maxDepth, final Watcher watcher) { public static WatchMonitor ofAll(final File file, final int maxDepth, final Watcher watcher) {
return createAll(file.toPath(), maxDepth, watcher); return ofAll(file.toPath(), maxDepth, watcher);
} }
/** /**
@ -214,8 +214,8 @@ public class WatchUtil {
* @param watcher {@link Watcher} * @param watcher {@link Watcher}
* @return {@link WatchMonitor} * @return {@link WatchMonitor}
*/ */
public static WatchMonitor createAll(final String path, final Watcher watcher) { public static WatchMonitor ofAll(final String path, final Watcher watcher) {
return createAll(path, 0, watcher); return ofAll(path, 0, watcher);
} }
/** /**
@ -226,8 +226,8 @@ public class WatchUtil {
* @param watcher {@link Watcher} * @param watcher {@link Watcher}
* @return {@link WatchMonitor} * @return {@link WatchMonitor}
*/ */
public static WatchMonitor createAll(final String path, final int maxDepth, final Watcher watcher) { public static WatchMonitor ofAll(final String path, final int maxDepth, final Watcher watcher) {
return createAll(Paths.get(path), maxDepth, watcher); return ofAll(Paths.get(path), maxDepth, watcher);
} }
/** /**
@ -237,8 +237,8 @@ public class WatchUtil {
* @param watcher {@link Watcher} * @param watcher {@link Watcher}
* @return {@link WatchMonitor} * @return {@link WatchMonitor}
*/ */
public static WatchMonitor createAll(final Path path, final Watcher watcher) { public static WatchMonitor ofAll(final Path path, final Watcher watcher) {
return createAll(path, 0, watcher); return ofAll(path, 0, watcher);
} }
/** /**
@ -249,7 +249,7 @@ public class WatchUtil {
* @param watcher {@link Watcher} * @param watcher {@link Watcher}
* @return {@link WatchMonitor} * @return {@link WatchMonitor}
*/ */
public static WatchMonitor createAll(final Path path, final int maxDepth, final Watcher watcher) { public static WatchMonitor ofAll(final Path path, final int maxDepth, final Watcher watcher) {
final WatchMonitor watchMonitor = of(path, maxDepth, WatchMonitor.EVENTS_ALL); final WatchMonitor watchMonitor = of(path, maxDepth, WatchMonitor.EVENTS_ALL);
watchMonitor.setWatcher(watcher); watchMonitor.setWatcher(watcher);
return watchMonitor; return watchMonitor;

View File

@ -26,7 +26,7 @@ public class WatcherChain implements Watcher, Chain<Watcher, WatcherChain>{
* @param watchers 观察者列表 * @param watchers 观察者列表
* @return {@link WatcherChain} * @return {@link WatcherChain}
*/ */
public static WatcherChain create(final Watcher... watchers) { public static WatcherChain of(final Watcher... watchers) {
return new WatcherChain(watchers); return new WatcherChain(watchers);
} }

View File

@ -30,7 +30,7 @@ public class ConsoleTable {
* @return ConsoleTable * @return ConsoleTable
* @since 5.4.5 * @since 5.4.5
*/ */
public static ConsoleTable create() { public static ConsoleTable of() {
return new ConsoleTable(); return new ConsoleTable();
} }

View File

@ -40,7 +40,7 @@ public class WeightRandom<T> implements Serializable {
* @param <T> 权重随机获取的对象类型 * @param <T> 权重随机获取的对象类型
* @return WeightRandom * @return WeightRandom
*/ */
public static <T> WeightRandom<T> create() { public static <T> WeightRandom<T> of() {
return new WeightRandom<>(); return new WeightRandom<>();
} }

View File

@ -62,7 +62,7 @@ public class CamelCaseMap<K, V> extends FuncKeyMap<K, V> {
* @param loadFactor 加载因子 * @param loadFactor 加载因子
*/ */
public CamelCaseMap(final int initialCapacity, final float loadFactor) { public CamelCaseMap(final int initialCapacity, final float loadFactor) {
this(MapBuilder.create(new HashMap<>(initialCapacity, loadFactor))); this(MapBuilder.of(new HashMap<>(initialCapacity, loadFactor)));
} }
/** /**

View File

@ -62,7 +62,7 @@ public class CaseInsensitiveMap<K, V> extends FuncKeyMap<K, V> {
* @param loadFactor 加载因子 * @param loadFactor 加载因子
*/ */
public CaseInsensitiveMap(final int initialCapacity, final float loadFactor) { public CaseInsensitiveMap(final int initialCapacity, final float loadFactor) {
this(MapBuilder.create(new HashMap<>(initialCapacity, loadFactor))); this(MapBuilder.of(new HashMap<>(initialCapacity, loadFactor)));
} }
/** /**

View File

@ -45,7 +45,7 @@ public class Dict extends LinkedHashMap<String, Object> implements BasicTypeGett
* *
* @return Dict * @return Dict
*/ */
public static Dict create() { public static Dict of() {
return new Dict(); return new Dict();
} }
@ -57,7 +57,7 @@ public class Dict extends LinkedHashMap<String, Object> implements BasicTypeGett
* @return Vo * @return Vo
*/ */
public static <T> Dict parse(final T bean) { public static <T> Dict parse(final T bean) {
return create().parseBean(bean); return of().parseBean(bean);
} }
/** /**
@ -68,7 +68,7 @@ public class Dict extends LinkedHashMap<String, Object> implements BasicTypeGett
*/ */
@SafeVarargs @SafeVarargs
public static Dict ofEntries(final Map.Entry<String, Object>... pairs) { public static Dict ofEntries(final Map.Entry<String, Object>... pairs) {
final Dict dict = create(); final Dict dict = of();
for (final Map.Entry<String, Object> pair : pairs) { for (final Map.Entry<String, Object> pair : pairs) {
dict.put(pair.getKey(), pair.getValue()); dict.put(pair.getKey(), pair.getValue());
} }
@ -94,7 +94,7 @@ public class Dict extends LinkedHashMap<String, Object> implements BasicTypeGett
* @since 5.4.1 * @since 5.4.1
*/ */
public static Dict ofKvs(final Object... keysAndValues) { public static Dict ofKvs(final Object... keysAndValues) {
final Dict dict = create(); final Dict dict = of();
String key = null; String key = null;
for (int i = 0; i < keysAndValues.length; i++) { for (int i = 0; i < keysAndValues.length; i++) {

View File

@ -26,8 +26,8 @@ public class MapBuilder<K, V> implements Builder<Map<K, V>> {
* @return MapBuilder * @return MapBuilder
* @since 5.3.0 * @since 5.3.0
*/ */
public static <K, V> MapBuilder<K, V> create() { public static <K, V> MapBuilder<K, V> of() {
return create(false); return of(false);
} }
/** /**
@ -39,8 +39,8 @@ public class MapBuilder<K, V> implements Builder<Map<K, V>> {
* @return MapBuilder * @return MapBuilder
* @since 5.3.0 * @since 5.3.0
*/ */
public static <K, V> MapBuilder<K, V> create(final boolean isLinked) { public static <K, V> MapBuilder<K, V> of(final boolean isLinked) {
return create(MapUtil.newHashMap(isLinked)); return of(MapUtil.newHashMap(isLinked));
} }
/** /**
@ -52,7 +52,7 @@ public class MapBuilder<K, V> implements Builder<Map<K, V>> {
* @return MapBuilder * @return MapBuilder
* @since 3.2.3 * @since 3.2.3
*/ */
public static <K, V> MapBuilder<K, V> create(final Map<K, V> map) { public static <K, V> MapBuilder<K, V> of(final Map<K, V> map) {
return new MapBuilder<>(map); return new MapBuilder<>(map);
} }

View File

@ -34,7 +34,7 @@ public class MapProxy implements Map<Object, Object>, OptNullBasicTypeFromObject
* @param map 被代理的Map * @param map 被代理的Map
* @return {@link MapProxy} * @return {@link MapProxy}
*/ */
public static MapProxy create(final Map<?, ?> map) { public static MapProxy of(final Map<?, ?> map) {
return (map instanceof MapProxy) ? (MapProxy) map : new MapProxy(map); return (map instanceof MapProxy) ? (MapProxy) map : new MapProxy(map);
} }

View File

@ -873,7 +873,7 @@ public class MapUtil {
* @since 3.2.0 * @since 3.2.0
*/ */
public static MapProxy createProxy(final Map<?, ?> map) { public static MapProxy createProxy(final Map<?, ?> map) {
return MapProxy.create(map); return MapProxy.of(map);
} }
/** /**

View File

@ -41,7 +41,7 @@ public class SSLContextBuilder implements SSLProtocols, Builder<SSLContext> {
* *
* @return SSLContextBuilder * @return SSLContextBuilder
*/ */
public static SSLContextBuilder create() { public static SSLContextBuilder of() {
return new SSLContextBuilder(); return new SSLContextBuilder();
} }

View File

@ -23,7 +23,7 @@ public class SSLUtil {
* @since 5.7.8 * @since 5.7.8
*/ */
public static SSLContext createSSLContext(final String protocol) throws IORuntimeException{ public static SSLContext createSSLContext(final String protocol) throws IORuntimeException{
return SSLContextBuilder.create().setProtocol(protocol).build(); return SSLContextBuilder.of().setProtocol(protocol).build();
} }
/** /**
@ -52,7 +52,7 @@ public class SSLUtil {
* @throws IORuntimeException 包装 GeneralSecurityException异常 * @throws IORuntimeException 包装 GeneralSecurityException异常
*/ */
public static SSLContext createSSLContext(final String protocol, final KeyManager[] keyManagers, final TrustManager[] trustManagers) throws IORuntimeException { public static SSLContext createSSLContext(final String protocol, final KeyManager[] keyManagers, final TrustManager[] trustManagers) throws IORuntimeException {
return SSLContextBuilder.create() return SSLContextBuilder.of()
.setProtocol(protocol) .setProtocol(protocol)
.setKeyManagers(keyManagers) .setKeyManagers(keyManagers)
.setTrustManagers(trustManagers).build(); .setTrustManagers(trustManagers).build();

View File

@ -188,7 +188,7 @@ public final class UrlBuilder implements Builder<String> {
* *
* @return UrlBuilder * @return UrlBuilder
*/ */
public static UrlBuilder create() { public static UrlBuilder of() {
return new UrlBuilder(); return new UrlBuilder();
} }

View File

@ -44,7 +44,7 @@ public class ThreadFactoryBuilder implements Builder<ThreadFactory> {
* *
* @return {@code ThreadFactoryBuilder} * @return {@code ThreadFactoryBuilder}
*/ */
public static ThreadFactoryBuilder create() { public static ThreadFactoryBuilder of() {
return new ThreadFactoryBuilder(); return new ThreadFactoryBuilder();
} }

View File

@ -456,7 +456,7 @@ public class ThreadUtil {
* @since 4.1.13 * @since 4.1.13
*/ */
public static ThreadFactoryBuilder createThreadFactoryBuilder() { public static ThreadFactoryBuilder createThreadFactoryBuilder() {
return ThreadFactoryBuilder.create(); return ThreadFactoryBuilder.of();
} }
/** /**
@ -468,7 +468,7 @@ public class ThreadUtil {
* @since 5.8.0 * @since 5.8.0
*/ */
public static ThreadFactory createThreadFactory(final String threadNamePrefix) { public static ThreadFactory createThreadFactory(final String threadNamePrefix) {
return ThreadFactoryBuilder.create().setNamePrefix(threadNamePrefix).build(); return ThreadFactoryBuilder.of().setNamePrefix(threadNamePrefix).build();
} }
/** /**

View File

@ -28,8 +28,8 @@ public class ReferenceUtil {
* @param referent 被引用对象 * @param referent 被引用对象
* @return {@link Reference} * @return {@link Reference}
*/ */
public static <T> Reference<T> create(final ReferenceType type, final T referent) { public static <T> Reference<T> of(final ReferenceType type, final T referent) {
return create(type, referent, null); return of(type, referent, null);
} }
/** /**
@ -41,7 +41,7 @@ public class ReferenceUtil {
* @param queue 引用队列 * @param queue 引用队列
* @return {@link Reference} * @return {@link Reference}
*/ */
public static <T> Reference<T> create(final ReferenceType type, final T referent, final ReferenceQueue<T> queue) { public static <T> Reference<T> of(final ReferenceType type, final T referent, final ReferenceQueue<T> queue) {
switch (type) { switch (type) {
case SOFT: case SOFT:
return new SoftReference<>(referent, queue); return new SoftReference<>(referent, queue);

View File

@ -79,7 +79,7 @@ public class BeanUtilTest {
@Test @Test
public void fillBeanWithMapIgnoreCaseTest() { public void fillBeanWithMapIgnoreCaseTest() {
final Map<String, Object> map = MapBuilder.<String, Object>create() final Map<String, Object> map = MapBuilder.<String, Object>of()
.put("Name", "Joe") .put("Name", "Joe")
.put("aGe", 12) .put("aGe", 12)
.put("openId", "DFDFSDFWERWER") .put("openId", "DFDFSDFWERWER")

View File

@ -234,8 +234,8 @@ public class CollUtilTest {
@Test @Test
public void getFieldValuesTest() { public void getFieldValuesTest() {
final Dict v1 = Dict.create().set("id", 12).set("name", "张三").set("age", 23); final Dict v1 = Dict.of().set("id", 12).set("name", "张三").set("age", 23);
final Dict v2 = Dict.create().set("age", 13).set("id", 15).set("name", "李四"); final Dict v2 = Dict.of().set("age", 13).set("id", 15).set("name", "李四");
final ArrayList<Dict> list = ListUtil.of(v1, v2); final ArrayList<Dict> list = ListUtil.of(v1, v2);
final List<Object> fieldValues = (List<Object>) CollUtil.getFieldValues(list, "name"); final List<Object> fieldValues = (List<Object>) CollUtil.getFieldValues(list, "name");
@ -783,7 +783,7 @@ public class CollUtilTest {
public void pageTest() { public void pageTest() {
final List<Dict> objects = ListUtil.of(); final List<Dict> objects = ListUtil.of();
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
objects.add(Dict.create().set("name", "姓名:" + i)); objects.add(Dict.of().set("name", "姓名:" + i));
} }
Assert.assertEquals(0, CollUtil.page(3, 5, objects).size()); Assert.assertEquals(0, CollUtil.page(3, 5, objects).size());

View File

@ -39,7 +39,7 @@ public class MapProxyTest {
@Test @Test
public void classProxyTest() { public void classProxyTest() {
final Student student = MapProxy.create(new HashMap<>()).toProxyBean(Student.class); final Student student = MapProxy.of(new HashMap<>()).toProxyBean(Student.class);
student.setName("小明").setAge(18); student.setName("小明").setAge(18);
Assert.assertEquals(student.getAge(), 18); Assert.assertEquals(student.getAge(), 18);
Assert.assertEquals(student.getName(), "小明"); Assert.assertEquals(student.getName(), "小明");

View File

@ -30,7 +30,7 @@ public class MapConvertTest {
@Test @Test
public void mapToMapTest() { public void mapToMapTest() {
final Map<String, Object> srcMap = MapBuilder final Map<String, Object> srcMap = MapBuilder
.create(new HashMap<String, Object>()) .of(new HashMap<String, Object>())
.put("name", "AAA") .put("name", "AAA")
.put("age", 45).map(); .put("age", 45).map();

View File

@ -1,5 +1,6 @@
package cn.hutool.core.date; package cn.hutool.core.date;
import cn.hutool.core.date.chinese.ChineseDate;
import cn.hutool.core.text.StrUtil; import cn.hutool.core.text.StrUtil;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;

View File

@ -1,5 +1,6 @@
package cn.hutool.core.date; package cn.hutool.core.date;
import cn.hutool.core.date.chinese.ChineseDate;
import cn.hutool.core.date.chinese.GanZhi; import cn.hutool.core.date.chinese.GanZhi;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;

View File

@ -1,6 +1,5 @@
package cn.hutool.core.date.chinese; package cn.hutool.core.date.chinese;
import cn.hutool.core.date.ChineseDate;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;

View File

@ -44,7 +44,7 @@ public class WatchMonitorTest {
} }
}; };
final WatchMonitor monitor = WatchMonitor.createAll("d:/test/aaa.txt", new DelayWatcher(watcher, 500)); final WatchMonitor monitor = WatchMonitor.ofAll("d:/test/aaa.txt", new DelayWatcher(watcher, 500));
monitor.setMaxDepth(0); monitor.setMaxDepth(0);
monitor.start(); monitor.start();

View File

@ -8,7 +8,7 @@ public class ConsoleTableTest {
@Test @Test
@Ignore @Ignore
public void printSBCTest() { public void printSBCTest() {
ConsoleTable t = ConsoleTable.create(); ConsoleTable t = ConsoleTable.of();
t.addHeader("姓名", "年龄"); t.addHeader("姓名", "年龄");
t.addBody("张三", "15"); t.addBody("张三", "15");
t.addBody("李四", "29"); t.addBody("李四", "29");
@ -17,7 +17,7 @@ public class ConsoleTableTest {
Console.log(); Console.log();
t = ConsoleTable.create(); t = ConsoleTable.of();
t.addHeader("体温", "占比"); t.addHeader("体温", "占比");
t.addHeader("", "%"); t.addHeader("", "%");
t.addBody("36.8", "10"); t.addBody("36.8", "10");
@ -26,7 +26,7 @@ public class ConsoleTableTest {
Console.log(); Console.log();
t = ConsoleTable.create(); t = ConsoleTable.of();
t.addHeader("标题1", "标题2"); t.addHeader("标题1", "标题2");
t.addBody("12345", "混合321654asdfcSDF"); t.addBody("12345", "混合321654asdfcSDF");
t.addBody("sd e3ee ff22", "ff值"); t.addBody("sd e3ee ff22", "ff值");
@ -36,7 +36,7 @@ public class ConsoleTableTest {
@Test @Test
@Ignore @Ignore
public void printDBCTest() { public void printDBCTest() {
ConsoleTable t = ConsoleTable.create().setSBCMode(false); ConsoleTable t = ConsoleTable.of().setSBCMode(false);
t.addHeader("姓名", "年龄"); t.addHeader("姓名", "年龄");
t.addBody("张三", "15"); t.addBody("张三", "15");
t.addBody("李四", "29"); t.addBody("李四", "29");
@ -45,7 +45,7 @@ public class ConsoleTableTest {
Console.log(); Console.log();
t = ConsoleTable.create().setSBCMode(false); t = ConsoleTable.of().setSBCMode(false);
t.addHeader("体温", "占比"); t.addHeader("体温", "占比");
t.addHeader("", "%"); t.addHeader("", "%");
t.addBody("36.8", "10"); t.addBody("36.8", "10");

View File

@ -14,7 +14,7 @@ import static cn.hutool.core.lang.OptTest.User;
public class DictTest { public class DictTest {
@Test @Test
public void dictTest(){ public void dictTest(){
final Dict dict = Dict.create() final Dict dict = Dict.of()
.set("key1", 1)//int .set("key1", 1)//int
.set("key2", 1000L)//long .set("key2", 1000L)//long
.set("key3", DateTime.now());//Date .set("key3", DateTime.now());//Date
@ -66,7 +66,7 @@ public class DictTest {
@Test @Test
public void setFieldsTest() { public void setFieldsTest() {
final User user = GenericBuilder.of(User::new).with(User::setUsername, "hutool").build(); final User user = GenericBuilder.of(User::new).with(User::setUsername, "hutool").build();
final Dict dict = Dict.create(); final Dict dict = Dict.of();
dict.setFields(user::getNickname, user::getUsername); dict.setFields(user::getNickname, user::getUsername);
Assert.assertEquals("hutool", dict.get("username")); Assert.assertEquals("hutool", dict.get("username"));
Assert.assertNull(dict.get("nickname")); Assert.assertNull(dict.get("nickname"));

View File

@ -8,7 +8,7 @@ public class WeightRandomTest {
@Test @Test
public void weightRandomTest() { public void weightRandomTest() {
final WeightRandom<String> random = WeightRandom.create(); final WeightRandom<String> random = WeightRandom.of();
random.add("A", 10); random.add("A", 10);
random.add("B", 50); random.add("B", 50);
random.add("C", 100); random.add("C", 100);

View File

@ -9,7 +9,7 @@ public class MapBuilderTest {
@Test @Test
public void conditionPutTest() { public void conditionPutTest() {
final Map<String, String> map = MapBuilder.<String, String>create() final Map<String, String> map = MapBuilder.<String, String>of()
.put(true, "a", "1") .put(true, "a", "1")
.put(false, "b", "2") .put(false, "b", "2")
.put(true, "c", () -> getValue(3)) .put(true, "c", () -> getValue(3))

View File

@ -226,8 +226,8 @@ public class MapUtilTest {
@Test @Test
public void valuesOfKeysTest() { public void valuesOfKeysTest() {
final Dict v1 = Dict.create().set("id", 12).set("name", "张三").set("age", 23); final Dict v1 = Dict.of().set("id", 12).set("name", "张三").set("age", 23);
final Dict v2 = Dict.create().set("age", 13).set("id", 15).set("name", "李四"); final Dict v2 = Dict.of().set("age", 13).set("id", 15).set("name", "李四");
final String[] keys = v1.keySet().toArray(new String[0]); final String[] keys = v1.keySet().toArray(new String[0]);
final ArrayList<Object> v1s = MapUtil.valuesOfKeys(v1, keys); final ArrayList<Object> v1s = MapUtil.valuesOfKeys(v1, keys);

View File

@ -16,7 +16,7 @@ public class UrlBuilderTest {
@Test @Test
public void buildTest() { public void buildTest() {
final String buildUrl = UrlBuilder.create().setHost("www.hutool.cn").build(); final String buildUrl = UrlBuilder.of().setHost("www.hutool.cn").build();
Assert.assertEquals("http://www.hutool.cn/", buildUrl); Assert.assertEquals("http://www.hutool.cn/", buildUrl);
} }
@ -29,7 +29,7 @@ public class UrlBuilderTest {
@Test @Test
public void testHost() { public void testHost() {
final String buildUrl = UrlBuilder.create() final String buildUrl = UrlBuilder.of()
.setScheme("https") .setScheme("https")
.setHost("www.hutool.cn").build(); .setHost("www.hutool.cn").build();
Assert.assertEquals("https://www.hutool.cn/", buildUrl); Assert.assertEquals("https://www.hutool.cn/", buildUrl);
@ -37,7 +37,7 @@ public class UrlBuilderTest {
@Test @Test
public void testHostPort() { public void testHostPort() {
final String buildUrl = UrlBuilder.create() final String buildUrl = UrlBuilder.of()
.setScheme("https") .setScheme("https")
.setHost("www.hutool.cn") .setHost("www.hutool.cn")
.setPort(8080) .setPort(8080)
@ -47,7 +47,7 @@ public class UrlBuilderTest {
@Test @Test
public void testPathAndQuery() { public void testPathAndQuery() {
final String buildUrl = UrlBuilder.create() final String buildUrl = UrlBuilder.of()
.setScheme("https") .setScheme("https")
.setHost("www.hutool.cn") .setHost("www.hutool.cn")
.addPath("/aaa").addPath("bbb") .addPath("/aaa").addPath("bbb")
@ -60,7 +60,7 @@ public class UrlBuilderTest {
@Test @Test
public void testQueryWithChinese() { public void testQueryWithChinese() {
final String buildUrl = UrlBuilder.create() final String buildUrl = UrlBuilder.of()
.setScheme("https") .setScheme("https")
.setHost("www.hutool.cn") .setHost("www.hutool.cn")
.addPath("/aaa").addPath("bbb") .addPath("/aaa").addPath("bbb")
@ -73,7 +73,7 @@ public class UrlBuilderTest {
@Test @Test
public void testMultiQueryWithChinese() { public void testMultiQueryWithChinese() {
final String buildUrl = UrlBuilder.create() final String buildUrl = UrlBuilder.of()
.setScheme("https") .setScheme("https")
.setHost("www.hutool.cn") .setHost("www.hutool.cn")
.addPath("/s") .addPath("/s")
@ -303,7 +303,7 @@ public class UrlBuilderTest {
@Test @Test
public void addPathEncodeTest(){ public void addPathEncodeTest(){
final String url = UrlBuilder.create() final String url = UrlBuilder.of()
.setScheme("https") .setScheme("https")
.setHost("domain.cn") .setHost("domain.cn")
.addPath("api") .addPath("api")
@ -317,7 +317,7 @@ public class UrlBuilderTest {
@Test @Test
public void addPathEncodeTest2(){ public void addPathEncodeTest2(){
// https://github.com/dromara/hutool/issues/1912 // https://github.com/dromara/hutool/issues/1912
final String url = UrlBuilder.create() final String url = UrlBuilder.of()
.setScheme("https") .setScheme("https")
.setHost("domain.cn") .setHost("domain.cn")
.addPath("/api/xxx/bbb") .addPath("/api/xxx/bbb")

View File

@ -9,7 +9,7 @@ public class NamingCaseTest {
@Test @Test
public void toCamelCaseTest() { public void toCamelCaseTest() {
Dict.create() Dict.of()
.set("Table_Test_Of_day","tableTestOfDay") .set("Table_Test_Of_day","tableTestOfDay")
.set("TableTestOfDay","TableTestOfDay") .set("TableTestOfDay","TableTestOfDay")
.set("abc_1d","abc1d") .set("abc_1d","abc1d")
@ -18,14 +18,14 @@ public class NamingCaseTest {
@Test @Test
public void toCamelCaseFromDashedTest() { public void toCamelCaseFromDashedTest() {
Dict.create() Dict.of()
.set("Table-Test-Of-day","tableTestOfDay") .set("Table-Test-Of-day","tableTestOfDay")
.forEach((key, value) -> Assert.assertEquals(value, NamingCase.toCamelCase(key, CharUtil.DASHED))); .forEach((key, value) -> Assert.assertEquals(value, NamingCase.toCamelCase(key, CharUtil.DASHED)));
} }
@Test @Test
public void toUnderLineCaseTest() { public void toUnderLineCaseTest() {
Dict.create() Dict.of()
.set("Table_Test_Of_day", "table_test_of_day") .set("Table_Test_Of_day", "table_test_of_day")
.set("_Table_Test_Of_day_", "_table_test_of_day_") .set("_Table_Test_Of_day_", "_table_test_of_day_")
.set("_Table_Test_Of_DAY_", "_table_test_of_DAY_") .set("_Table_Test_Of_DAY_", "_table_test_of_DAY_")

View File

@ -15,21 +15,21 @@ public class ReferenceUtilTest {
@Test @Test
public void createWeakTest(){ public void createWeakTest(){
final Reference<Integer> integerReference = ReferenceUtil.create(ReferenceUtil.ReferenceType.WEAK, 1); final Reference<Integer> integerReference = ReferenceUtil.of(ReferenceUtil.ReferenceType.WEAK, 1);
Assert.assertTrue(integerReference instanceof WeakReference); Assert.assertTrue(integerReference instanceof WeakReference);
Assert.assertEquals(new Integer(1), integerReference.get()); Assert.assertEquals(new Integer(1), integerReference.get());
} }
@Test @Test
public void createSoftTest(){ public void createSoftTest(){
final Reference<Integer> integerReference = ReferenceUtil.create(ReferenceUtil.ReferenceType.SOFT, 1); final Reference<Integer> integerReference = ReferenceUtil.of(ReferenceUtil.ReferenceType.SOFT, 1);
Assert.assertTrue(integerReference instanceof SoftReference); Assert.assertTrue(integerReference instanceof SoftReference);
Assert.assertEquals(new Integer(1), integerReference.get()); Assert.assertEquals(new Integer(1), integerReference.get());
} }
@Test @Test
public void createPhantomTest(){ public void createPhantomTest(){
final Reference<Integer> integerReference = ReferenceUtil.create(ReferenceUtil.ReferenceType.PHANTOM, 1); final Reference<Integer> integerReference = ReferenceUtil.of(ReferenceUtil.ReferenceType.PHANTOM, 1);
Assert.assertTrue(integerReference instanceof PhantomReference); Assert.assertTrue(integerReference instanceof PhantomReference);
// get方法永远都返回nullPhantomReference只能用来监控对象的GC状况 // get方法永远都返回nullPhantomReference只能用来监控对象的GC状况
Assert.assertNull(integerReference.get()); Assert.assertNull(integerReference.get());

View File

@ -123,10 +123,10 @@ public class StrUtilTest {
@Test @Test
public void formatTest() { public void formatTest() {
final String template = "你好,我是{name},我的电话是:{phone}"; final String template = "你好,我是{name},我的电话是:{phone}";
final String result = StrUtil.format(template, Dict.create().set("name", "张三").set("phone", "13888881111")); final String result = StrUtil.format(template, Dict.of().set("name", "张三").set("phone", "13888881111"));
Assert.assertEquals("你好我是张三我的电话是13888881111", result); Assert.assertEquals("你好我是张三我的电话是13888881111", result);
final String result2 = StrUtil.format(template, Dict.create().set("name", "张三").set("phone", null)); final String result2 = StrUtil.format(template, Dict.of().set("name", "张三").set("phone", null));
Assert.assertEquals("你好,我是张三,我的电话是:{phone}", result2); Assert.assertEquals("你好,我是张三,我的电话是:{phone}", result2);
} }

View File

@ -115,7 +115,7 @@ public class XmlUtilTest {
@Test @Test
public void mapToXmlTest() { public void mapToXmlTest() {
final Map<String, Object> map = MapBuilder.create(new LinkedHashMap<String, Object>())// final Map<String, Object> map = MapBuilder.of(new LinkedHashMap<String, Object>())//
.put("name", "张三")// .put("name", "张三")//
.put("age", 12)// .put("age", 12)//
.put("game", MapUtil.builder(new LinkedHashMap<String, Object>()).put("昵称", "Looly").put("level", 14).build())// .put("game", MapUtil.builder(new LinkedHashMap<String, Object>()).put("昵称", "Looly").put("level", 14).build())//
@ -137,7 +137,7 @@ public class XmlUtilTest {
@Test @Test
public void mapToXmlTest2() { public void mapToXmlTest2() {
// 测试List // 测试List
final Map<String, Object> map = MapBuilder.create(new LinkedHashMap<String, Object>()) final Map<String, Object> map = MapBuilder.of(new LinkedHashMap<String, Object>())
.put("Town", ListUtil.of("town1", "town2")) .put("Town", ListUtil.of("town1", "town2"))
.build(); .build();
@ -171,7 +171,7 @@ public class XmlUtilTest {
@Test @Test
public void mapToXmlTestWithOmitXmlDeclaration() { public void mapToXmlTestWithOmitXmlDeclaration() {
final Map<String, Object> map = MapBuilder.create(new LinkedHashMap<String, Object>()) final Map<String, Object> map = MapBuilder.of(new LinkedHashMap<String, Object>())
.put("name", "ddatsh") .put("name", "ddatsh")
.build(); .build();
final String xml = XmlUtil.mapToXmlStr(map, true); final String xml = XmlUtil.mapToXmlStr(map, true);

View File

@ -411,7 +411,7 @@ public class Scheduler implements Serializable {
if(null == this.threadExecutor){ if(null == this.threadExecutor){
// 无界线程池确保每一个需要执行的线程都可以及时运行同时复用已有线程避免线程重复创建 // 无界线程池确保每一个需要执行的线程都可以及时运行同时复用已有线程避免线程重复创建
this.threadExecutor = ExecutorBuilder.of().useSynchronousQueue().setThreadFactory(// this.threadExecutor = ExecutorBuilder.of().useSynchronousQueue().setThreadFactory(//
ThreadFactoryBuilder.create().setNamePrefix("hutool-cron-").setDaemon(this.daemon).build()// ThreadFactoryBuilder.of().setNamePrefix("hutool-cron-").setDaemon(this.daemon).build()//
).build(); ).build();
} }
this.taskLauncherManager = new TaskLauncherManager(this); this.taskLauncherManager = new TaskLauncherManager(this);

View File

@ -19,7 +19,7 @@ public class MD5 extends Digester {
* @return MD5 * @return MD5
* @since 4.6.0 * @since 4.6.0
*/ */
public static MD5 create() { public static MD5 of() {
return new MD5(); return new MD5();
} }

View File

@ -25,7 +25,7 @@ public class SM3 extends Digester {
* @return SM3 * @return SM3
* @since 4.6.0 * @since 4.6.0
*/ */
public static SM3 create() { public static SM3 of() {
return new SM3(); return new SM3();
} }

View File

@ -582,7 +582,7 @@ public abstract class AbstractDb<R extends AbstractDb<R>> extends DefaultConnect
* @since 3.2.2 * @since 3.2.2
*/ */
public <T> List<T> find(final Entity where, final Class<T> beanClass) throws DbRuntimeException { public <T> List<T> find(final Entity where, final Class<T> beanClass) throws DbRuntimeException {
return find(where.getFieldNames(), where, BeanListHandler.create(beanClass)); return find(where.getFieldNames(), where, BeanListHandler.of(beanClass));
} }
/** /**
@ -594,7 +594,7 @@ public abstract class AbstractDb<R extends AbstractDb<R>> extends DefaultConnect
* @throws DbRuntimeException SQL执行异常 * @throws DbRuntimeException SQL执行异常
*/ */
public List<Entity> findAll(final Entity where) throws DbRuntimeException { public List<Entity> findAll(final Entity where) throws DbRuntimeException {
return find(where, EntityListHandler.create()); return find(where, EntityListHandler.of());
} }
/** /**
@ -609,7 +609,7 @@ public abstract class AbstractDb<R extends AbstractDb<R>> extends DefaultConnect
* @since 3.2.2 * @since 3.2.2
*/ */
public <T> List<T> findAll(final Entity where, final Class<T> beanClass) throws DbRuntimeException { public <T> List<T> findAll(final Entity where, final Class<T> beanClass) throws DbRuntimeException {
return find(where, BeanListHandler.create(beanClass)); return find(where, BeanListHandler.of(beanClass));
} }
/** /**

View File

@ -23,7 +23,7 @@ public class ActiveEntity extends Entity {
* *
* @return ActiveEntity * @return ActiveEntity
*/ */
public static ActiveEntity create() { public static ActiveEntity of() {
return new ActiveEntity(); return new ActiveEntity();
} }
@ -33,7 +33,7 @@ public class ActiveEntity extends Entity {
* @param tableName 表名 * @param tableName 表名
* @return ActiveEntity * @return ActiveEntity
*/ */
public static ActiveEntity create(final String tableName) { public static ActiveEntity of(final String tableName) {
return new ActiveEntity(tableName); return new ActiveEntity(tableName);
} }
@ -45,7 +45,7 @@ public class ActiveEntity extends Entity {
* @return ActiveEntity * @return ActiveEntity
*/ */
public static <T> ActiveEntity parse(final T bean) { public static <T> ActiveEntity parse(final T bean) {
return create(null).parseBean(bean); return of(null).parseBean(bean);
} }
/** /**
@ -58,7 +58,7 @@ public class ActiveEntity extends Entity {
* @return ActiveEntity * @return ActiveEntity
*/ */
public static <T> ActiveEntity parse(final T bean, final boolean isToUnderlineCase, final boolean ignoreNullValue) { public static <T> ActiveEntity parse(final T bean, final boolean isToUnderlineCase, final boolean ignoreNullValue) {
return create(null).parseBean(bean, isToUnderlineCase, ignoreNullValue); return of(null).parseBean(bean, isToUnderlineCase, ignoreNullValue);
} }
/** /**
@ -69,7 +69,7 @@ public class ActiveEntity extends Entity {
* @return ActiveEntity * @return ActiveEntity
*/ */
public static <T> ActiveEntity parseWithUnderlineCase(final T bean) { public static <T> ActiveEntity parseWithUnderlineCase(final T bean) {
return create(null).parseBean(bean, true, true); return of(null).parseBean(bean, true, true);
} }
// --------------------------------------------------------------- Static method end // --------------------------------------------------------------- Static method end

View File

@ -133,7 +133,7 @@ public interface Dialect extends Serializable {
* @throws SQLException SQL执行异常 * @throws SQLException SQL执行异常
*/ */
default PreparedStatement psForCount(final Connection conn, final Query query) throws SQLException { default PreparedStatement psForCount(final Connection conn, final Query query) throws SQLException {
return psForCount(conn, SqlBuilder.create().query(query)); return psForCount(conn, SqlBuilder.of().query(query));
} }
/** /**

View File

@ -43,7 +43,7 @@ public class AnsiSqlDialect implements Dialect {
@Override @Override
public PreparedStatement psForInsert(final Connection conn, final Entity entity) throws SQLException { public PreparedStatement psForInsert(final Connection conn, final Entity entity) throws SQLException {
final SqlBuilder insert = SqlBuilder.create(wrapper).insert(entity, this.dialectName()); final SqlBuilder insert = SqlBuilder.of(wrapper).insert(entity, this.dialectName());
return StatementUtil.prepareStatement(conn, insert); return StatementUtil.prepareStatement(conn, insert);
} }
@ -54,7 +54,7 @@ public class AnsiSqlDialect implements Dialect {
throw new DbRuntimeException("Entities for batch insert is empty !"); throw new DbRuntimeException("Entities for batch insert is empty !");
} }
// 批量根据第一行数据结构生成SQL占位符 // 批量根据第一行数据结构生成SQL占位符
final SqlBuilder insert = SqlBuilder.create(wrapper).insert(entities[0], this.dialectName()); final SqlBuilder insert = SqlBuilder.of(wrapper).insert(entities[0], this.dialectName());
final Set<String> fields = CollUtil.filter(entities[0].keySet(), StrUtil::isNotBlank); final Set<String> fields = CollUtil.filter(entities[0].keySet(), StrUtil::isNotBlank);
return StatementUtil.prepareStatementForBatch(conn, insert.build(), fields, entities); return StatementUtil.prepareStatementForBatch(conn, insert.build(), fields, entities);
} }
@ -68,7 +68,7 @@ public class AnsiSqlDialect implements Dialect {
// 对于无条件的删除语句直接抛出异常禁止防止误删除 // 对于无条件的删除语句直接抛出异常禁止防止误删除
throw new SQLException("No 'WHERE' condition, we can't prepared statement for delete everything."); throw new SQLException("No 'WHERE' condition, we can't prepared statement for delete everything.");
} }
final SqlBuilder delete = SqlBuilder.create(wrapper).delete(query.getFirstTableName()).where(where); final SqlBuilder delete = SqlBuilder.of(wrapper).delete(query.getFirstTableName()).where(where);
return StatementUtil.prepareStatement(conn, delete); return StatementUtil.prepareStatement(conn, delete);
} }
@ -83,7 +83,7 @@ public class AnsiSqlDialect implements Dialect {
throw new SQLException("No 'WHERE' condition, we can't prepare statement for update everything."); throw new SQLException("No 'WHERE' condition, we can't prepare statement for update everything.");
} }
final SqlBuilder update = SqlBuilder.create(wrapper).update(entity).where(where); final SqlBuilder update = SqlBuilder.of(wrapper).update(entity).where(where);
return StatementUtil.prepareStatement(conn, update); return StatementUtil.prepareStatement(conn, update);
} }
@ -100,7 +100,7 @@ public class AnsiSqlDialect implements Dialect {
throw new DbRuntimeException("Table name must be not empty !"); throw new DbRuntimeException("Table name must be not empty !");
} }
final SqlBuilder find = SqlBuilder.create(wrapper).query(query); final SqlBuilder find = SqlBuilder.of(wrapper).query(query);
return psForPage(conn, find, query.getPage()); return psForPage(conn, find, query.getPage());
} }

View File

@ -40,7 +40,7 @@ public class H2Dialect extends AnsiSqlDialect {
public PreparedStatement psForUpsert(final Connection conn, final Entity entity, final String... keys) throws SQLException { public PreparedStatement psForUpsert(final Connection conn, final Entity entity, final String... keys) throws SQLException {
Assert.notEmpty(keys, "Keys must be not empty for H2 MERGE SQL."); Assert.notEmpty(keys, "Keys must be not empty for H2 MERGE SQL.");
SqlBuilder.validateEntity(entity); SqlBuilder.validateEntity(entity);
final SqlBuilder builder = SqlBuilder.create(wrapper); final SqlBuilder builder = SqlBuilder.of(wrapper);
final StringBuilder fieldsPart = new StringBuilder(); final StringBuilder fieldsPart = new StringBuilder();
final StringBuilder placeHolder = new StringBuilder(); final StringBuilder placeHolder = new StringBuilder();

View File

@ -51,7 +51,7 @@ public class MysqlDialect extends AnsiSqlDialect{
@Override @Override
public PreparedStatement psForUpsert(final Connection conn, final Entity entity, final String... keys) throws SQLException { public PreparedStatement psForUpsert(final Connection conn, final Entity entity, final String... keys) throws SQLException {
SqlBuilder.validateEntity(entity); SqlBuilder.validateEntity(entity);
final SqlBuilder builder = SqlBuilder.create(wrapper); final SqlBuilder builder = SqlBuilder.of(wrapper);
final StringBuilder fieldsPart = new StringBuilder(); final StringBuilder fieldsPart = new StringBuilder();
final StringBuilder placeHolder = new StringBuilder(); final StringBuilder placeHolder = new StringBuilder();

View File

@ -35,7 +35,7 @@ public class PostgresqlDialect extends AnsiSqlDialect{
public PreparedStatement psForUpsert(final Connection conn, final Entity entity, final String... keys) throws SQLException { public PreparedStatement psForUpsert(final Connection conn, final Entity entity, final String... keys) throws SQLException {
Assert.notEmpty(keys, "Keys must be not empty for Postgres."); Assert.notEmpty(keys, "Keys must be not empty for Postgres.");
SqlBuilder.validateEntity(entity); SqlBuilder.validateEntity(entity);
final SqlBuilder builder = SqlBuilder.create(wrapper); final SqlBuilder builder = SqlBuilder.of(wrapper);
final StringBuilder fieldsPart = new StringBuilder(); final StringBuilder fieldsPart = new StringBuilder();
final StringBuilder placeHolder = new StringBuilder(); final StringBuilder placeHolder = new StringBuilder();

View File

@ -136,7 +136,7 @@ public abstract class DSFactory implements Closeable, Serializable{
* @param setting 数据库配置项 * @param setting 数据库配置项
* @return 日志实现类 * @return 日志实现类
*/ */
public static DSFactory create(final Setting setting) { public static DSFactory of(final Setting setting) {
final DSFactory dsFactory = doCreate(setting); final DSFactory dsFactory = doCreate(setting);
log.debug("Use [{}] DataSource As Default", dsFactory.dataSourceName); log.debug("Use [{}] DataSource As Default", dsFactory.dataSourceName);
return dsFactory; return dsFactory;

View File

@ -42,7 +42,7 @@ public class GlobalDSFactory {
if (null == factory) { if (null == factory) {
synchronized (lock) { synchronized (lock) {
if (null == factory) { if (null == factory) {
factory = DSFactory.create(null); factory = DSFactory.of(null);
} }
} }
} }

View File

@ -23,7 +23,7 @@ public class BeanHandler<E> implements RsHandler<E>{
* @param beanType Bean类型 * @param beanType Bean类型
* @return BeanHandler对象 * @return BeanHandler对象
*/ */
public static <E> BeanHandler<E> create(final Class<E> beanType) { public static <E> BeanHandler<E> of(final Class<E> beanType) {
return new BeanHandler<>(beanType); return new BeanHandler<>(beanType);
} }

View File

@ -24,7 +24,7 @@ public class BeanListHandler<E> implements RsHandler<List<E>> {
* @param beanType Bean类型 * @param beanType Bean类型
* @return BeanListHandler对象 * @return BeanListHandler对象
*/ */
public static <E> BeanListHandler<E> create(final Class<E> beanType) { public static <E> BeanListHandler<E> of(final Class<E> beanType) {
return new BeanListHandler<>(beanType); return new BeanListHandler<>(beanType);
} }

View File

@ -22,7 +22,7 @@ public class EntityHandler implements RsHandler<Entity>{
* 创建一个 EntityHandler对象 * 创建一个 EntityHandler对象
* @return EntityHandler对象 * @return EntityHandler对象
*/ */
public static EntityHandler create() { public static EntityHandler of() {
return new EntityHandler(); return new EntityHandler();
} }

View File

@ -22,7 +22,7 @@ public class EntityListHandler implements RsHandler<List<Entity>>{
* 创建一个 EntityListHandler对象 * 创建一个 EntityListHandler对象
* @return EntityListHandler对象 * @return EntityListHandler对象
*/ */
public static EntityListHandler create() { public static EntityListHandler of() {
return new EntityListHandler(); return new EntityListHandler();
} }

View File

@ -21,7 +21,7 @@ public class EntitySetHandler implements RsHandler<LinkedHashSet<Entity>>{
* 创建一个 EntityHandler对象 * 创建一个 EntityHandler对象
* @return EntityHandler对象 * @return EntityHandler对象
*/ */
public static EntitySetHandler create() { public static EntitySetHandler of() {
return new EntitySetHandler(); return new EntitySetHandler();
} }

View File

@ -15,7 +15,7 @@ public class NumberHandler implements RsHandler<Number>{
* 创建一个 NumberHandler对象 * 创建一个 NumberHandler对象
* @return NumberHandler对象 * @return NumberHandler对象
*/ */
public static NumberHandler create() { public static NumberHandler of() {
return new NumberHandler(); return new NumberHandler();
} }

View File

@ -27,7 +27,7 @@ public class PageResultHandler implements RsHandler<PageResult<Entity>> {
* @param pageResult 分页结果集空对象 * @param pageResult 分页结果集空对象
* @return EntityHandler对象 * @return EntityHandler对象
*/ */
public static PageResultHandler create(final PageResult<Entity> pageResult) { public static PageResultHandler of(final PageResult<Entity> pageResult) {
return new PageResultHandler(pageResult); return new PageResultHandler(pageResult);
} }

View File

@ -15,7 +15,7 @@ public class StringHandler implements RsHandler<String>{
* 创建一个 NumberHandler对象 * 创建一个 NumberHandler对象
* @return NumberHandler对象 * @return NumberHandler对象
*/ */
public static StringHandler create() { public static StringHandler of() {
return new StringHandler(); return new StringHandler();
} }

View File

@ -17,7 +17,7 @@ public class ValueListHandler implements RsHandler<List<List<Object>>>{
* 创建一个 EntityListHandler对象 * 创建一个 EntityListHandler对象
* @return EntityListHandler对象 * @return EntityListHandler对象
*/ */
public static ValueListHandler create() { public static ValueListHandler of() {
return new ValueListHandler(); return new ValueListHandler();
} }

View File

@ -70,7 +70,7 @@ public class Column implements Serializable, Cloneable {
* @return 列对象 * @return 列对象
* @since 5.4.3 * @since 5.4.3
*/ */
public static Column create(final Table table, final ResultSet columnMetaRs) { public static Column of(final Table table, final ResultSet columnMetaRs) {
return new Column(table, columnMetaRs); return new Column(table, columnMetaRs);
} }

View File

@ -21,7 +21,7 @@ public class ColumnIndexInfo implements Serializable, Cloneable {
* @param rs 结果集通过DatabaseMetaData#getIndexInfo获取 * @param rs 结果集通过DatabaseMetaData#getIndexInfo获取
* @return ColumnIndexInfo * @return ColumnIndexInfo
*/ */
public static ColumnIndexInfo create(final ResultSet rs) { public static ColumnIndexInfo of(final ResultSet rs) {
try { try {
return new ColumnIndexInfo( return new ColumnIndexInfo(
rs.getString("COLUMN_NAME"), rs.getString("COLUMN_NAME"),

View File

@ -207,7 +207,7 @@ public class MetaUtil {
* @since 5.7.22 * @since 5.7.22
*/ */
public static Table getTableMeta(final DataSource ds, String catalog, String schema, final String tableName) { public static Table getTableMeta(final DataSource ds, String catalog, String schema, final String tableName) {
final Table table = Table.create(tableName); final Table table = Table.of(tableName);
Connection conn = null; Connection conn = null;
try { try {
conn = ds.getConnection(); conn = ds.getConnection();
@ -246,7 +246,7 @@ public class MetaUtil {
try (final ResultSet rs = metaData.getColumns(catalog, schema, tableName, null)) { try (final ResultSet rs = metaData.getColumns(catalog, schema, tableName, null)) {
if (null != rs) { if (null != rs) {
while (rs.next()) { while (rs.next()) {
table.setColumn(Column.create(table, rs)); table.setColumn(Column.of(table, rs));
} }
} }
} }
@ -269,7 +269,7 @@ public class MetaUtil {
indexInfo = new IndexInfo(rs.getBoolean("NON_UNIQUE"), indexName, tableName, schema, catalog); indexInfo = new IndexInfo(rs.getBoolean("NON_UNIQUE"), indexName, tableName, schema, catalog);
indexInfoMap.put(key, indexInfo); indexInfoMap.put(key, indexInfo);
} }
indexInfo.getColumnIndexInfoList().add(ColumnIndexInfo.create(rs)); indexInfo.getColumnIndexInfoList().add(ColumnIndexInfo.of(rs));
} }
} }
table.setIndexInfoList(ListUtil.of(indexInfoMap.values())); table.setIndexInfoList(ListUtil.of(indexInfoMap.values()));

View File

@ -45,7 +45,7 @@ public class Table implements Serializable, Cloneable {
*/ */
private final Map<String, Column> columns = new LinkedHashMap<>(); private final Map<String, Column> columns = new LinkedHashMap<>();
public static Table create(final String tableName) { public static Table of(final String tableName) {
return new Table(tableName); return new Table(tableName);
} }

View File

@ -32,7 +32,7 @@ public class SqlBuilder implements Builder<String> {
* *
* @return SQL构建器 * @return SQL构建器
*/ */
public static SqlBuilder create() { public static SqlBuilder of() {
return new SqlBuilder(); return new SqlBuilder();
} }
@ -42,7 +42,7 @@ public class SqlBuilder implements Builder<String> {
* @param wrapper 包装器 * @param wrapper 包装器
* @return SQL构建器 * @return SQL构建器
*/ */
public static SqlBuilder create(final Wrapper wrapper) { public static SqlBuilder of(final Wrapper wrapper) {
return new SqlBuilder(wrapper); return new SqlBuilder(wrapper);
} }
@ -54,7 +54,7 @@ public class SqlBuilder implements Builder<String> {
* @since 5.5.3 * @since 5.5.3
*/ */
public static SqlBuilder of(final CharSequence sql) { public static SqlBuilder of(final CharSequence sql) {
return create().append(sql); return of().append(sql);
} }
/** /**

View File

@ -23,9 +23,9 @@ public class OracleTest {
final Query query = new Query(SqlUtil.buildConditions(where), where.getTableName()); final Query query = new Query(SqlUtil.buildConditions(where), where.getTableName());
query.setPage(page); query.setPage(page);
final SqlBuilder find = SqlBuilder.create(null).query(query).orderBy(page.getOrders()); final SqlBuilder find = SqlBuilder.of(null).query(query).orderBy(page.getOrders());
final int[] startEnd = page.getStartEnd(); final int[] startEnd = page.getStartEnd();
final SqlBuilder builder = SqlBuilder.create(null).append("SELECT * FROM ( SELECT row_.*, rownum rownum_ from ( ")// final SqlBuilder builder = SqlBuilder.of(null).append("SELECT * FROM ( SELECT row_.*, rownum rownum_ from ( ")//
.append(find)// .append(find)//
.append(" ) row_ where rownum <= ").append(startEnd[1])// .append(" ) row_ where rownum <= ").append(startEnd[1])//
.append(") table_alias")// .append(") table_alias")//

View File

@ -7,22 +7,22 @@ public class SqlBuilderTest {
@Test @Test
public void queryNullTest() { public void queryNullTest() {
final SqlBuilder builder = SqlBuilder.create().select().from("user").where(new Condition("name", "= null")); final SqlBuilder builder = SqlBuilder.of().select().from("user").where(new Condition("name", "= null"));
Assert.assertEquals("SELECT * FROM user WHERE name IS NULL", builder.build()); Assert.assertEquals("SELECT * FROM user WHERE name IS NULL", builder.build());
final SqlBuilder builder2 = SqlBuilder.create().select().from("user").where(new Condition("name", "is null")); final SqlBuilder builder2 = SqlBuilder.of().select().from("user").where(new Condition("name", "is null"));
Assert.assertEquals("SELECT * FROM user WHERE name IS NULL", builder2.build()); Assert.assertEquals("SELECT * FROM user WHERE name IS NULL", builder2.build());
final SqlBuilder builder3 = SqlBuilder.create().select().from("user").where(new Condition("name", "!= null")); final SqlBuilder builder3 = SqlBuilder.of().select().from("user").where(new Condition("name", "!= null"));
Assert.assertEquals("SELECT * FROM user WHERE name IS NOT NULL", builder3.build()); Assert.assertEquals("SELECT * FROM user WHERE name IS NOT NULL", builder3.build());
final SqlBuilder builder4 = SqlBuilder.create().select().from("user").where(new Condition("name", "is not null")); final SqlBuilder builder4 = SqlBuilder.of().select().from("user").where(new Condition("name", "is not null"));
Assert.assertEquals("SELECT * FROM user WHERE name IS NOT NULL", builder4.build()); Assert.assertEquals("SELECT * FROM user WHERE name IS NOT NULL", builder4.build());
} }
@Test @Test
public void orderByTest() { public void orderByTest() {
final SqlBuilder builder = SqlBuilder.create().select("id", "username").from("user") final SqlBuilder builder = SqlBuilder.of().select("id", "username").from("user")
.join("role", SqlBuilder.Join.INNER) .join("role", SqlBuilder.Join.INNER)
.on("user.id = role.user_id") .on("user.id = role.user_id")
.where(new Condition("age", ">=", 18), .where(new Condition("age", ">=", 18),

View File

@ -59,7 +59,7 @@ public abstract class ProxyFactory implements Serializable {
* @return 代理对象 * @return 代理对象
*/ */
public static <T> T createProxy(final T target, final Aspect aspect) { public static <T> T createProxy(final T target, final Aspect aspect) {
return create().proxy(target, aspect); return of().proxy(target, aspect);
} }
/** /**
@ -67,7 +67,7 @@ public abstract class ProxyFactory implements Serializable {
* *
* @return 代理工厂 * @return 代理工厂
*/ */
public static ProxyFactory create() { public static ProxyFactory of() {
return ServiceLoaderUtil.loadFirstAvailable(ProxyFactory.class); return ServiceLoaderUtil.loadFirstAvailable(ProxyFactory.class);
} }
} }

View File

@ -105,7 +105,7 @@ public class CompressUtil {
if (ArchiveStreamFactory.SEVEN_Z.equalsIgnoreCase(archiverName)) { if (ArchiveStreamFactory.SEVEN_Z.equalsIgnoreCase(archiverName)) {
return new SevenZArchiver(file); return new SevenZArchiver(file);
} }
return StreamArchiver.create(charset, archiverName, file); return StreamArchiver.of(charset, archiverName, file);
} }
/** /**
@ -128,7 +128,7 @@ public class CompressUtil {
if (ArchiveStreamFactory.SEVEN_Z.equalsIgnoreCase(archiverName)) { if (ArchiveStreamFactory.SEVEN_Z.equalsIgnoreCase(archiverName)) {
return new SevenZArchiver(out); return new SevenZArchiver(out);
} }
return StreamArchiver.create(charset, archiverName, out); return StreamArchiver.of(charset, archiverName, out);
} }
/** /**

View File

@ -41,7 +41,7 @@ public class StreamArchiver implements Archiver {
* @param file 归档输出的文件 * @param file 归档输出的文件
* @return StreamArchiver * @return StreamArchiver
*/ */
public static StreamArchiver create(final Charset charset, final String archiverName, final File file) { public static StreamArchiver of(final Charset charset, final String archiverName, final File file) {
return new StreamArchiver(charset, archiverName, file); return new StreamArchiver(charset, archiverName, file);
} }
@ -53,7 +53,7 @@ public class StreamArchiver implements Archiver {
* @param out 归档输出的流 * @param out 归档输出的流
* @return StreamArchiver * @return StreamArchiver
*/ */
public static StreamArchiver create(final Charset charset, final String archiverName, final OutputStream out) { public static StreamArchiver of(final Charset charset, final String archiverName, final OutputStream out) {
return new StreamArchiver(charset, archiverName, out); return new StreamArchiver(charset, archiverName, out);
} }

View File

@ -22,7 +22,7 @@ public class ExpressionFactory {
* @return 单例的{@link ExpressionEngine} * @return 单例的{@link ExpressionEngine}
*/ */
public static ExpressionEngine get(){ public static ExpressionEngine get(){
return Singleton.get(ExpressionEngine.class.getName(), ExpressionFactory::create); return Singleton.get(ExpressionEngine.class.getName(), ExpressionFactory::of);
} }
/** /**
@ -31,7 +31,7 @@ public class ExpressionFactory {
* *
* @return {@link ExpressionEngine} * @return {@link ExpressionEngine}
*/ */
public static ExpressionEngine create() { public static ExpressionEngine of() {
final ExpressionEngine engine = doCreate(); final ExpressionEngine engine = doCreate();
StaticLog.debug("Use [{}] Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine")); StaticLog.debug("Use [{}] Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine"));
return engine; return engine;

View File

@ -141,7 +141,7 @@ public class Ftp extends AbstractFtp {
* @since 5.7.22 * @since 5.7.22
*/ */
public Ftp(final FTPClient client) { public Ftp(final FTPClient client) {
super(FtpConfig.create()); super(FtpConfig.of());
this.client = client; this.client = client;
} }

View File

@ -11,7 +11,7 @@ import java.nio.charset.Charset;
public class FtpConfig implements Serializable { public class FtpConfig implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public static FtpConfig create() { public static FtpConfig of() {
return new FtpConfig(); return new FtpConfig();
} }

View File

@ -32,7 +32,7 @@ public class SimpleFtpServer {
* *
* @return SimpleFtpServer * @return SimpleFtpServer
*/ */
public static SimpleFtpServer create() { public static SimpleFtpServer of() {
return new SimpleFtpServer(); return new SimpleFtpServer();
} }

View File

@ -91,7 +91,7 @@ public class Mail implements Builder<MimeMessage> {
* @param mailAccount 邮件帐号 * @param mailAccount 邮件帐号
* @return Mail * @return Mail
*/ */
public static Mail create(final MailAccount mailAccount) { public static Mail of(final MailAccount mailAccount) {
return new Mail(mailAccount); return new Mail(mailAccount);
} }
@ -100,7 +100,7 @@ public class Mail implements Builder<MimeMessage> {
* *
* @return Mail * @return Mail
*/ */
public static Mail create() { public static Mail of() {
return new Mail(); return new Mail();
} }

View File

@ -388,7 +388,7 @@ public class MailUtil {
*/ */
private static String send(final MailAccount mailAccount, final boolean useGlobalSession, final Collection<String> tos, final Collection<String> ccs, final Collection<String> bccs, final String subject, final String content, private static String send(final MailAccount mailAccount, final boolean useGlobalSession, final Collection<String> tos, final Collection<String> ccs, final Collection<String> bccs, final String subject, final String content,
final Map<String, InputStream> imageMap, final boolean isHtml, final File... files) { final Map<String, InputStream> imageMap, final boolean isHtml, final File... files) {
final Mail mail = Mail.create(mailAccount).setUseGlobalSession(useGlobalSession); final Mail mail = Mail.of(mailAccount).setUseGlobalSession(useGlobalSession);
// 可选抄送人 // 可选抄送人
if (CollUtil.isNotEmpty(ccs)) { if (CollUtil.isNotEmpty(ccs)) {

View File

@ -21,7 +21,7 @@ public class PinyinFactory {
* @return 单例的PinyinEngine * @return 单例的PinyinEngine
*/ */
public static PinyinEngine get(){ public static PinyinEngine get(){
return Singleton.get(PinyinEngine.class.getName(), PinyinFactory::create); return Singleton.get(PinyinEngine.class.getName(), PinyinFactory::of);
} }
/** /**
@ -30,7 +30,7 @@ public class PinyinFactory {
* *
* @return {@link PinyinEngine} * @return {@link PinyinEngine}
*/ */
public static PinyinEngine create() { public static PinyinEngine of() {
final PinyinEngine engine = doCreate(); final PinyinEngine engine = doCreate();
StaticLog.debug("Use [{}] Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine")); StaticLog.debug("Use [{}] Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine"));
return engine; return engine;

View File

@ -50,7 +50,7 @@ public class QrConfig {
* @return QrConfig * @return QrConfig
* @since 4.1.14 * @since 4.1.14
*/ */
public static QrConfig create() { public static QrConfig of() {
return new QrConfig(); return new QrConfig();
} }

View File

@ -111,7 +111,7 @@ public class Sftp extends AbstractFtp {
* @since 4.1.14 * @since 4.1.14
*/ */
public Sftp(final Session session, final Charset charset) { public Sftp(final Session session, final Charset charset) {
super(FtpConfig.create().setCharset(charset)); super(FtpConfig.of().setCharset(charset));
init(session, charset); init(session, charset);
} }
@ -122,7 +122,7 @@ public class Sftp extends AbstractFtp {
* @param charset 编码 * @param charset 编码
*/ */
public Sftp(final ChannelSftp channel, final Charset charset) { public Sftp(final ChannelSftp channel, final Charset charset) {
super(FtpConfig.create().setCharset(charset)); super(FtpConfig.of().setCharset(charset));
init(channel, charset); init(channel, charset);
} }
@ -135,7 +135,7 @@ public class Sftp extends AbstractFtp {
* @since 5.8.4 * @since 5.8.4
*/ */
public Sftp(final Session session, final Charset charset, final long timeOut) { public Sftp(final Session session, final Charset charset, final long timeOut) {
super(FtpConfig.create().setCharset(charset).setConnectionTimeout(timeOut)); super(FtpConfig.of().setCharset(charset).setConnectionTimeout(timeOut));
init(session, charset); init(session, charset);
} }
@ -148,7 +148,7 @@ public class Sftp extends AbstractFtp {
* @since 5.8.4 * @since 5.8.4
*/ */
public Sftp(final ChannelSftp channel, final Charset charset, final long timeOut) { public Sftp(final ChannelSftp channel, final Charset charset, final long timeOut) {
super(FtpConfig.create().setCharset(charset).setConnectionTimeout(timeOut)); super(FtpConfig.of().setCharset(charset).setConnectionTimeout(timeOut));
init(channel, charset); init(channel, charset);
} }
// ---------------------------------------------------------------------------------------- Constructor end // ---------------------------------------------------------------------------------------- Constructor end

View File

@ -18,7 +18,7 @@ public class TemplateUtil {
* @since 4.1.11 * @since 4.1.11
*/ */
public static TemplateEngine createEngine() { public static TemplateEngine createEngine() {
return TemplateFactory.create(); return TemplateFactory.of();
} }
/** /**
@ -29,6 +29,6 @@ public class TemplateUtil {
* @return {@link TemplateEngine} * @return {@link TemplateEngine}
*/ */
public static TemplateEngine createEngine(final TemplateConfig config) { public static TemplateEngine createEngine(final TemplateConfig config) {
return TemplateFactory.create(config); return TemplateFactory.of(config);
} }
} }

View File

@ -23,7 +23,7 @@ public class TemplateFactory {
* @return 单例的TemplateEngine * @return 单例的TemplateEngine
*/ */
public static TemplateEngine get(){ public static TemplateEngine get(){
return Singleton.get(TemplateEngine.class.getName(), TemplateFactory::create); return Singleton.get(TemplateEngine.class.getName(), TemplateFactory::of);
} }
/** /**
@ -33,8 +33,8 @@ public class TemplateFactory {
* @return {@link TemplateEngine} * @return {@link TemplateEngine}
* @since 5.3.3 * @since 5.3.3
*/ */
public static TemplateEngine create() { public static TemplateEngine of() {
return create(new TemplateConfig()); return of(new TemplateConfig());
} }
/** /**
@ -44,7 +44,7 @@ public class TemplateFactory {
* @param config 模板配置包括编码模板文件path等信息 * @param config 模板配置包括编码模板文件path等信息
* @return {@link TemplateEngine} * @return {@link TemplateEngine}
*/ */
public static TemplateEngine create(final TemplateConfig config) { public static TemplateEngine of(final TemplateConfig config) {
final TemplateEngine engine = doCreate(config); final TemplateEngine engine = doCreate(config);
StaticLog.debug("Use [{}] Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine")); StaticLog.debug("Use [{}] Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine"));
return engine; return engine;

View File

@ -84,7 +84,7 @@ public class WitEngine implements TemplateEngine {
Dict dict = null; Dict dict = null;
if (null != config) { if (null != config) {
dict = Dict.create(); dict = Dict.of();
// 自定义编码 // 自定义编码
dict.set("DEFAULT_ENCODING", config.getCharset()); dict.set("DEFAULT_ENCODING", config.getCharset());

View File

@ -4,7 +4,7 @@ import cn.hutool.extra.tokenizer.engine.TokenizerFactory;
/** /**
* 分词工具类 * 分词工具类
* *
* @author looly * @author looly
* @since 4.3.3 * @since 4.3.3
*/ */
@ -12,10 +12,10 @@ public class TokenizerUtil {
/** /**
* 根据用户引入的分词引擎jar自动创建对应的分词引擎对象 * 根据用户引入的分词引擎jar自动创建对应的分词引擎对象
* *
* @return {@link TokenizerEngine} * @return {@link TokenizerEngine}
*/ */
public static TokenizerEngine createEngine() { public static TokenizerEngine createEngine() {
return TokenizerFactory.create(); return TokenizerFactory.of();
} }
} }

View File

@ -23,7 +23,7 @@ public class TokenizerFactory {
* @since 5.3.3 * @since 5.3.3
*/ */
public static TokenizerEngine get(){ public static TokenizerEngine get(){
return Singleton.get(TokenizerEngine.class.getName(), TokenizerFactory::create); return Singleton.get(TokenizerEngine.class.getName(), TokenizerFactory::of);
} }
/** /**
@ -31,7 +31,7 @@ public class TokenizerFactory {
* *
* @return {@link TokenizerEngine} * @return {@link TokenizerEngine}
*/ */
public static TokenizerEngine create() { public static TokenizerEngine of() {
final TokenizerEngine engine = doCreate(); final TokenizerEngine engine = doCreate();
StaticLog.debug("Use [{}] Tokenizer Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine")); StaticLog.debug("Use [{}] Tokenizer Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine"));
return engine; return engine;

View File

@ -16,7 +16,7 @@ public class ArchiverTest {
@Ignore @Ignore
public void zipTest(){ public void zipTest(){
final File file = FileUtil.file("d:/test/compress/test.zip"); final File file = FileUtil.file("d:/test/compress/test.zip");
StreamArchiver.create(CharsetUtil.UTF_8, ArchiveStreamFactory.ZIP, file) StreamArchiver.of(CharsetUtil.UTF_8, ArchiveStreamFactory.ZIP, file)
.add(FileUtil.file("d:/Java"), (f)->{ .add(FileUtil.file("d:/Java"), (f)->{
Console.log("Add: {}", f.getPath()); Console.log("Add: {}", f.getPath());
return true; return true;
@ -28,7 +28,7 @@ public class ArchiverTest {
@Ignore @Ignore
public void tarTest(){ public void tarTest(){
final File file = FileUtil.file("d:/test/compress/test.tar"); final File file = FileUtil.file("d:/test/compress/test.tar");
StreamArchiver.create(CharsetUtil.UTF_8, ArchiveStreamFactory.TAR, file) StreamArchiver.of(CharsetUtil.UTF_8, ArchiveStreamFactory.TAR, file)
.add(FileUtil.file("d:/Java"), (f)->{ .add(FileUtil.file("d:/Java"), (f)->{
Console.log("Add: {}", f.getPath()); Console.log("Add: {}", f.getPath());
return true; return true;
@ -40,7 +40,7 @@ public class ArchiverTest {
@Ignore @Ignore
public void cpioTest(){ public void cpioTest(){
final File file = FileUtil.file("d:/test/compress/test.cpio"); final File file = FileUtil.file("d:/test/compress/test.cpio");
StreamArchiver.create(CharsetUtil.UTF_8, ArchiveStreamFactory.CPIO, file) StreamArchiver.of(CharsetUtil.UTF_8, ArchiveStreamFactory.CPIO, file)
.add(FileUtil.file("d:/Java"), (f)->{ .add(FileUtil.file("d:/Java"), (f)->{
Console.log("Add: {}", f.getPath()); Console.log("Add: {}", f.getPath());
return true; return true;

View File

@ -21,17 +21,17 @@ public class AviatorTest {
final ExpressionEngine engine = new AviatorEngine(); final ExpressionEngine engine = new AviatorEngine();
String exp = String exp =
"\"[foo i=\"+ foo.i + \", f=\" + foo.f + \", date.year=\" + (foo.date.year+1900) + \", date.month=\" + foo.date.month + \", bars[0].name=\" + #foo.bars[0].name + \"]\""; "\"[foo i=\"+ foo.i + \", f=\" + foo.f + \", date.year=\" + (foo.date.year+1900) + \", date.month=\" + foo.date.month + \", bars[0].name=\" + #foo.bars[0].name + \"]\"";
String result = (String) engine.eval(exp, Dict.create().set("foo", foo)); String result = (String) engine.eval(exp, Dict.of().set("foo", foo));
Assert.assertEquals("[foo i=100, f=3.14, date.year=2020, date.month=10, bars[0].name=bar]", result); Assert.assertEquals("[foo i=100, f=3.14, date.year=2020, date.month=10, bars[0].name=bar]", result);
// Assignment. // Assignment.
exp = "#foo.bars[0].name='hello aviator' ; #foo.bars[0].name"; exp = "#foo.bars[0].name='hello aviator' ; #foo.bars[0].name";
result = (String) engine.eval(exp, Dict.create().set("foo", foo)); result = (String) engine.eval(exp, Dict.of().set("foo", foo));
Assert.assertEquals("hello aviator", result); Assert.assertEquals("hello aviator", result);
Assert.assertEquals("hello aviator", foo.bars[0].getName()); Assert.assertEquals("hello aviator", foo.bars[0].getName());
exp = "foo.bars[0] = nil ; foo.bars[0]"; exp = "foo.bars[0] = nil ; foo.bars[0]";
result = (String) engine.eval(exp, Dict.create().set("foo", foo)); result = (String) engine.eval(exp, Dict.of().set("foo", foo));
Console.log("Execute expression: " + exp); Console.log("Execute expression: " + exp);
Assert.assertNull(result); Assert.assertNull(result);
Assert.assertNull(foo.bars[0]); Assert.assertNull(foo.bars[0]);

View File

@ -16,7 +16,7 @@ public class ExpressionUtilTest {
@Test @Test
public void evalTest(){ public void evalTest(){
final Dict dict = Dict.create() final Dict dict = Dict.of()
.set("a", 100.3) .set("a", 100.3)
.set("b", 45) .set("b", 45)
.set("c", -199.100); .set("c", -199.100);
@ -28,7 +28,7 @@ public class ExpressionUtilTest {
public void jexlTest(){ public void jexlTest(){
final ExpressionEngine engine = new JexlEngine(); final ExpressionEngine engine = new JexlEngine();
final Dict dict = Dict.create() final Dict dict = Dict.of()
.set("a", 100.3) .set("a", 100.3)
.set("b", 45) .set("b", 45)
.set("c", -199.100); .set("c", -199.100);
@ -51,7 +51,7 @@ public class ExpressionUtilTest {
public void mvelTest(){ public void mvelTest(){
final ExpressionEngine engine = new MvelEngine(); final ExpressionEngine engine = new MvelEngine();
final Dict dict = Dict.create() final Dict dict = Dict.of()
.set("a", 100.3) .set("a", 100.3)
.set("b", 45) .set("b", 45)
.set("c", -199.100); .set("c", -199.100);
@ -63,7 +63,7 @@ public class ExpressionUtilTest {
public void jfireELTest(){ public void jfireELTest(){
final ExpressionEngine engine = new JfireELEngine(); final ExpressionEngine engine = new JfireELEngine();
final Dict dict = Dict.create() final Dict dict = Dict.of()
.set("a", 100.3) .set("a", 100.3)
.set("b", 45) .set("b", 45)
.set("c", -199.100); .set("c", -199.100);
@ -75,7 +75,7 @@ public class ExpressionUtilTest {
public void spELTest(){ public void spELTest(){
final ExpressionEngine engine = new SpELEngine(); final ExpressionEngine engine = new SpELEngine();
final Dict dict = Dict.create() final Dict dict = Dict.of()
.set("a", 100.3) .set("a", 100.3)
.set("b", 45) .set("b", 45)
.set("c", -199.100); .set("c", -199.100);
@ -87,7 +87,7 @@ public class ExpressionUtilTest {
public void rhinoTest(){ public void rhinoTest(){
final ExpressionEngine engine = new RhinoEngine(); final ExpressionEngine engine = new RhinoEngine();
final Dict dict = Dict.create() final Dict dict = Dict.of()
.set("a", 100.3) .set("a", 100.3)
.set("b", 45) .set("b", 45)
.set("c", -199.100); .set("c", -199.100);

View File

@ -4,7 +4,7 @@ public class SimpleFtpServerTest {
public static void main(final String[] args) { public static void main(final String[] args) {
SimpleFtpServer SimpleFtpServer
.create() .of()
.addAnonymous("d:/test/ftp/") .addAnonymous("d:/test/ftp/")
.start(); .start();
} }

View File

@ -47,7 +47,7 @@ public class MailAccountTest {
mailAccount.setAuth(true); mailAccount.setAuth(true);
mailAccount.setSslEnable(true); mailAccount.setSslEnable(true);
final Mail mail = Mail.create(mailAccount) final Mail mail = Mail.of(mailAccount)
.setTos("xx@xx.com") .setTos("xx@xx.com")
.setTitle("邮箱验证") .setTitle("邮箱验证")
.setContent("您的验证码是:<h3>2333</h3>") .setContent("您的验证码是:<h3>2333</h3>")

View File

@ -47,7 +47,7 @@ public class QrCodeUtilTest {
final String targetPath = FileUtil.isWindows() ? "d:/test/qrcodeWithLogo.jpg" : "~/Desktop/hutool/qrcodeWithLogo.jpg"; final String targetPath = FileUtil.isWindows() ? "d:/test/qrcodeWithLogo.jpg" : "~/Desktop/hutool/qrcodeWithLogo.jpg";
QrCodeUtil.generate(// QrCodeUtil.generate(//
"https://hutool.cn/", // "https://hutool.cn/", //
QrConfig.create().setImg(icon), // QrConfig.of().setImg(icon), //
FileUtil.touch(targetPath)); FileUtil.touch(targetPath));
} }
@ -91,7 +91,7 @@ public class QrCodeUtilTest {
@Test @Test
public void pdf417Test(){ public void pdf417Test(){
final BufferedImage image = QrCodeUtil.generate("content111", BarcodeFormat.PDF_417, QrConfig.create()); final BufferedImage image = QrCodeUtil.generate("content111", BarcodeFormat.PDF_417, QrConfig.of());
Assert.assertNotNull(image); Assert.assertNotNull(image);
} }

View File

@ -15,7 +15,7 @@ public class JetbrickTest {
.setCustomEngine(JetbrickEngine.class); .setCustomEngine(JetbrickEngine.class);
final TemplateEngine engine = TemplateUtil.createEngine(config); final TemplateEngine engine = TemplateUtil.createEngine(config);
final Template template = engine.getTemplate("jetbrick_test.jetx"); final Template template = engine.getTemplate("jetbrick_test.jetx");
final String result = template.render(Dict.create().set("name", "hutool")); final String result = template.render(Dict.of().set("name", "hutool"));
Assert.assertEquals("你好,hutool", StrUtil.trim(result)); Assert.assertEquals("你好,hutool", StrUtil.trim(result));
} }
@ -26,7 +26,7 @@ public class JetbrickTest {
.setCustomEngine(JetbrickEngine.class); .setCustomEngine(JetbrickEngine.class);
final TemplateEngine engine = TemplateUtil.createEngine(config); final TemplateEngine engine = TemplateUtil.createEngine(config);
final Template template = engine.getTemplate("hello,${name}"); final Template template = engine.getTemplate("hello,${name}");
final String result = template.render(Dict.create().set("name", "hutool")); final String result = template.render(Dict.of().set("name", "hutool"));
Assert.assertEquals("hello,hutool", StrUtil.trim(result)); Assert.assertEquals("hello,hutool", StrUtil.trim(result));
} }
} }

View File

@ -31,13 +31,13 @@ public class TemplateUtilTest {
// 字符串模板, 默认模板引擎此处为Beetl // 字符串模板, 默认模板引擎此处为Beetl
TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig()); TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig());
final Template template = engine.getTemplate("hello,${name}"); final Template template = engine.getTemplate("hello,${name}");
final String result = template.render(Dict.create().set("name", "hutool")); final String result = template.render(Dict.of().set("name", "hutool"));
Assert.assertEquals("hello,hutool", result); Assert.assertEquals("hello,hutool", result);
// classpath中获取模板 // classpath中获取模板
engine = TemplateUtil.createEngine(new TemplateConfig("templates", ResourceMode.CLASSPATH)); engine = TemplateUtil.createEngine(new TemplateConfig("templates", ResourceMode.CLASSPATH));
final Template template2 = engine.getTemplate("beetl_test.btl"); final Template template2 = engine.getTemplate("beetl_test.btl");
final String result2 = template2.render(Dict.create().set("name", "hutool")); final String result2 = template2.render(Dict.of().set("name", "hutool"));
Assert.assertEquals("hello,hutool", result2); Assert.assertEquals("hello,hutool", result2);
} }
@ -46,13 +46,13 @@ public class TemplateUtilTest {
// 字符串模板 // 字符串模板
TemplateEngine engine = new BeetlEngine(new TemplateConfig("templates")); TemplateEngine engine = new BeetlEngine(new TemplateConfig("templates"));
final Template template = engine.getTemplate("hello,${name}"); final Template template = engine.getTemplate("hello,${name}");
final String result = template.render(Dict.create().set("name", "hutool")); final String result = template.render(Dict.of().set("name", "hutool"));
Assert.assertEquals("hello,hutool", result); Assert.assertEquals("hello,hutool", result);
// classpath中获取模板 // classpath中获取模板
engine = new BeetlEngine(new TemplateConfig("templates", ResourceMode.CLASSPATH)); engine = new BeetlEngine(new TemplateConfig("templates", ResourceMode.CLASSPATH));
final Template template2 = engine.getTemplate("beetl_test.btl"); final Template template2 = engine.getTemplate("beetl_test.btl");
final String result2 = template2.render(Dict.create().set("name", "hutool")); final String result2 = template2.render(Dict.of().set("name", "hutool"));
Assert.assertEquals("hello,hutool", result2); Assert.assertEquals("hello,hutool", result2);
} }
@ -62,12 +62,12 @@ public class TemplateUtilTest {
final TemplateEngine engine = TemplateUtil.createEngine( final TemplateEngine engine = TemplateUtil.createEngine(
new TemplateConfig("templates").setCustomEngine(RythmEngine.class)); new TemplateConfig("templates").setCustomEngine(RythmEngine.class));
final Template template = engine.getTemplate("hello,@name"); final Template template = engine.getTemplate("hello,@name");
final String result = template.render(Dict.create().set("name", "hutool")); final String result = template.render(Dict.of().set("name", "hutool"));
Assert.assertEquals("hello,hutool", result); Assert.assertEquals("hello,hutool", result);
// classpath中获取模板 // classpath中获取模板
final Template template2 = engine.getTemplate("rythm_test.tmpl"); final Template template2 = engine.getTemplate("rythm_test.tmpl");
final String result2 = template2.render(Dict.create().set("name", "hutool")); final String result2 = template2.render(Dict.of().set("name", "hutool"));
Assert.assertEquals("hello,hutool", result2); Assert.assertEquals("hello,hutool", result2);
} }
@ -77,14 +77,14 @@ public class TemplateUtilTest {
TemplateEngine engine = TemplateUtil.createEngine( TemplateEngine engine = TemplateUtil.createEngine(
new TemplateConfig("templates", ResourceMode.STRING).setCustomEngine(FreemarkerEngine.class)); new TemplateConfig("templates", ResourceMode.STRING).setCustomEngine(FreemarkerEngine.class));
Template template = engine.getTemplate("hello,${name}"); Template template = engine.getTemplate("hello,${name}");
String result = template.render(Dict.create().set("name", "hutool")); String result = template.render(Dict.of().set("name", "hutool"));
Assert.assertEquals("hello,hutool", result); Assert.assertEquals("hello,hutool", result);
//ClassPath模板 //ClassPath模板
engine = TemplateUtil.createEngine( engine = TemplateUtil.createEngine(
new TemplateConfig("templates", ResourceMode.CLASSPATH).setCustomEngine(FreemarkerEngine.class)); new TemplateConfig("templates", ResourceMode.CLASSPATH).setCustomEngine(FreemarkerEngine.class));
template = engine.getTemplate("freemarker_test.ftl"); template = engine.getTemplate("freemarker_test.ftl");
result = template.render(Dict.create().set("name", "hutool")); result = template.render(Dict.of().set("name", "hutool"));
Assert.assertEquals("hello,hutool", result); Assert.assertEquals("hello,hutool", result);
} }
@ -94,18 +94,18 @@ public class TemplateUtilTest {
TemplateEngine engine = TemplateUtil.createEngine( TemplateEngine engine = TemplateUtil.createEngine(
new TemplateConfig("templates", ResourceMode.STRING).setCustomEngine(VelocityEngine.class)); new TemplateConfig("templates", ResourceMode.STRING).setCustomEngine(VelocityEngine.class));
Template template = engine.getTemplate("你好,$name"); Template template = engine.getTemplate("你好,$name");
String result = template.render(Dict.create().set("name", "hutool")); String result = template.render(Dict.of().set("name", "hutool"));
Assert.assertEquals("你好,hutool", result); Assert.assertEquals("你好,hutool", result);
//ClassPath模板 //ClassPath模板
engine = TemplateUtil.createEngine( engine = TemplateUtil.createEngine(
new TemplateConfig("templates", ResourceMode.CLASSPATH).setCustomEngine(VelocityEngine.class)); new TemplateConfig("templates", ResourceMode.CLASSPATH).setCustomEngine(VelocityEngine.class));
template = engine.getTemplate("velocity_test.vtl"); template = engine.getTemplate("velocity_test.vtl");
result = template.render(Dict.create().set("name", "hutool")); result = template.render(Dict.of().set("name", "hutool"));
Assert.assertEquals("你好,hutool", result); Assert.assertEquals("你好,hutool", result);
template = engine.getTemplate("templates/velocity_test.vtl"); template = engine.getTemplate("templates/velocity_test.vtl");
result = template.render(Dict.create().set("name", "hutool")); result = template.render(Dict.of().set("name", "hutool"));
Assert.assertEquals("你好,hutool", result); Assert.assertEquals("你好,hutool", result);
} }
@ -115,14 +115,14 @@ public class TemplateUtilTest {
TemplateEngine engine = TemplateUtil.createEngine( TemplateEngine engine = TemplateUtil.createEngine(
new TemplateConfig("templates").setCustomEngine(EnjoyEngine.class)); new TemplateConfig("templates").setCustomEngine(EnjoyEngine.class));
Template template = engine.getTemplate("#(x + 123)"); Template template = engine.getTemplate("#(x + 123)");
String result = template.render(Dict.create().set("x", 1)); String result = template.render(Dict.of().set("x", 1));
Assert.assertEquals("124", result); Assert.assertEquals("124", result);
//ClassPath模板 //ClassPath模板
engine = new EnjoyEngine( engine = new EnjoyEngine(
new TemplateConfig("templates", ResourceMode.CLASSPATH).setCustomEngine(EnjoyEngine.class)); new TemplateConfig("templates", ResourceMode.CLASSPATH).setCustomEngine(EnjoyEngine.class));
template = engine.getTemplate("enjoy_test.etl"); template = engine.getTemplate("enjoy_test.etl");
result = template.render(Dict.create().set("x", 1)); result = template.render(Dict.of().set("x", 1));
Assert.assertEquals("124", result); Assert.assertEquals("124", result);
} }
@ -132,14 +132,14 @@ public class TemplateUtilTest {
TemplateEngine engine = TemplateUtil.createEngine( TemplateEngine engine = TemplateUtil.createEngine(
new TemplateConfig("templates").setCustomEngine(ThymeleafEngine.class)); new TemplateConfig("templates").setCustomEngine(ThymeleafEngine.class));
Template template = engine.getTemplate("<h3 th:text=\"${message}\"></h3>"); Template template = engine.getTemplate("<h3 th:text=\"${message}\"></h3>");
String result = template.render(Dict.create().set("message", "Hutool")); String result = template.render(Dict.of().set("message", "Hutool"));
Assert.assertEquals("<h3>Hutool</h3>", result); Assert.assertEquals("<h3>Hutool</h3>", result);
//ClassPath模板 //ClassPath模板
engine = TemplateUtil.createEngine( engine = TemplateUtil.createEngine(
new TemplateConfig("templates", ResourceMode.CLASSPATH).setCustomEngine(ThymeleafEngine.class)); new TemplateConfig("templates", ResourceMode.CLASSPATH).setCustomEngine(ThymeleafEngine.class));
template = engine.getTemplate("thymeleaf_test.ttl"); template = engine.getTemplate("thymeleaf_test.ttl");
result = template.render(Dict.create().set("message", "Hutool")); result = template.render(Dict.of().set("message", "Hutool"));
Assert.assertEquals("<h3>Hutool</h3>", result); Assert.assertEquals("<h3>Hutool</h3>", result);
} }
@ -162,7 +162,7 @@ public class TemplateUtilTest {
.setCustomEngine(WitEngine.class); .setCustomEngine(WitEngine.class);
TemplateEngine engine = TemplateUtil.createEngine(config); TemplateEngine engine = TemplateUtil.createEngine(config);
Template template = engine.getTemplate("/wit_test.wit"); Template template = engine.getTemplate("/wit_test.wit");
String result = template.render(Dict.create().set("name", "hutool")); String result = template.render(Dict.of().set("name", "hutool"));
Assert.assertEquals("hello,hutool", StrUtil.trim(result)); Assert.assertEquals("hello,hutool", StrUtil.trim(result));
// 字符串模板 // 字符串模板
@ -170,7 +170,7 @@ public class TemplateUtilTest {
.setCustomEngine(WitEngine.class); .setCustomEngine(WitEngine.class);
engine = TemplateUtil.createEngine(config); engine = TemplateUtil.createEngine(config);
template = engine.getTemplate("<%var name;%>hello,${name}"); template = engine.getTemplate("<%var name;%>hello,${name}");
result = template.render(Dict.create().set("name", "hutool")); result = template.render(Dict.of().set("name", "hutool"));
Assert.assertEquals("hello,hutool", StrUtil.trim(result)); Assert.assertEquals("hello,hutool", StrUtil.trim(result));
} }
} }

View File

@ -45,7 +45,7 @@ public class ThymeleafTest {
// 字符串模板 // 字符串模板
final TemplateEngine engine = new ThymeleafEngine(new TemplateConfig()); final TemplateEngine engine = new ThymeleafEngine(new TemplateConfig());
final Template template = engine.getTemplate("<h3 th:each=\"item : ${list}\" th:text=\"${item.name}\"></h3>"); final Template template = engine.getTemplate("<h3 th:each=\"item : ${list}\" th:text=\"${item.name}\"></h3>");
final String render = template.render(Dict.create().set("list", list)); final String render = template.render(Dict.of().set("list", list));
Assert.assertEquals("<h3>a</h3><h3>b</h3><h3>2019-01-01 00:00:00</h3>", render); Assert.assertEquals("<h3>a</h3><h3>b</h3><h3>2019-01-01 00:00:00</h3>", render);
} }

View File

@ -15,7 +15,7 @@ public class VelocityTest {
config.setCharset(CharsetUtil.GBK); config.setCharset(CharsetUtil.GBK);
final TemplateEngine engine = TemplateUtil.createEngine(config); final TemplateEngine engine = TemplateUtil.createEngine(config);
final Template template = engine.getTemplate("velocity_test_gbk.vtl"); final Template template = engine.getTemplate("velocity_test_gbk.vtl");
final String result = template.render(Dict.create().set("name", "hutool")); final String result = template.render(Dict.of().set("name", "hutool"));
Assert.assertEquals("你好,hutool", result); Assert.assertEquals("你好,hutool", result);
} }
} }

Some files were not shown because too many files have changed in this diff Show More