mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
8080a1cd83
commit
1ee014bdae
@ -63,7 +63,7 @@ public class Hutool {
|
||||
*/
|
||||
public static void printAllUtils() {
|
||||
final Set<Class<?>> allUtils = getAllUtils();
|
||||
final ConsoleTable consoleTable = ConsoleTable.create().addHeader("工具类名", "所在包");
|
||||
final ConsoleTable consoleTable = ConsoleTable.of().addHeader("工具类名", "所在包");
|
||||
for (final Class<?> clazz : allUtils) {
|
||||
consoleTable.addBody(clazz.getSimpleName(), clazz.getPackage().getName());
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public enum GlobalPruneTimer {
|
||||
* 构造
|
||||
*/
|
||||
GlobalPruneTimer() {
|
||||
create();
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,9 +50,9 @@ public enum GlobalPruneTimer {
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建定时器
|
||||
* 初始化定时器
|
||||
*/
|
||||
public void create() {
|
||||
public void init() {
|
||||
if (null != pruneTimer) {
|
||||
shutdownNow();
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class UniqueKeySet<K, V> extends AbstractSet<V> implements Serializable {
|
||||
* @param 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 唯一键生成规则函数,用于生成对象对应的唯一键
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,9 +72,9 @@ public class CompilerUtil {
|
||||
*
|
||||
* @param parent 父{@link ClassLoader}
|
||||
* @return {@link JavaSourceCompiler}
|
||||
* @see JavaSourceCompiler#create(ClassLoader)
|
||||
* @see JavaSourceCompiler#of(ClassLoader)
|
||||
*/
|
||||
public static JavaSourceCompiler getCompiler(final ClassLoader parent) {
|
||||
return JavaSourceCompiler.create(parent);
|
||||
return JavaSourceCompiler.of(parent);
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public class JavaSourceCompiler {
|
||||
* @param parent 父类加载器
|
||||
* @return Java源码编译器
|
||||
*/
|
||||
public static JavaSourceCompiler create(final ClassLoader parent) {
|
||||
public static JavaSourceCompiler of(final ClassLoader parent) {
|
||||
return new JavaSourceCompiler(parent);
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class BeanConverter implements Converter, Serializable {
|
||||
BeanUtil.isBean(value.getClass())) {
|
||||
if (value instanceof Map && targetClass.isInterface()) {
|
||||
// 将Map动态代理为Bean
|
||||
return MapProxy.create((Map<?, ?>) value).toProxyBean(targetClass);
|
||||
return MapProxy.of((Map<?, ?>) value).toProxyBean(targetClass);
|
||||
}
|
||||
|
||||
//限定被转换对象类型
|
||||
|
@ -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.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.GanZhi;
|
||||
import cn.hutool.core.date.chinese.LunarFestival;
|
@ -1,6 +1,5 @@
|
||||
package cn.hutool.core.date.chinese;
|
||||
|
||||
import cn.hutool.core.date.ChineseDate;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.math.NumberUtil;
|
||||
|
@ -222,7 +222,7 @@ public class BufferUtil {
|
||||
* @return {@link ByteBuffer}
|
||||
* @since 4.5.0
|
||||
*/
|
||||
public static ByteBuffer create(final byte[] data) {
|
||||
public static ByteBuffer of(final byte[] data) {
|
||||
return ByteBuffer.wrap(data);
|
||||
}
|
||||
|
||||
@ -234,8 +234,8 @@ public class BufferUtil {
|
||||
* @return {@link ByteBuffer}
|
||||
* @since 4.5.0
|
||||
*/
|
||||
public static ByteBuffer create(final CharSequence data, final Charset charset) {
|
||||
return create(StrUtil.bytes(data, charset));
|
||||
public static ByteBuffer of(final CharSequence data, final Charset charset) {
|
||||
return of(StrUtil.bytes(data, charset));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -246,7 +246,7 @@ public class BufferUtil {
|
||||
* @since 4.5.0
|
||||
*/
|
||||
public static ByteBuffer createUtf8(final CharSequence data) {
|
||||
return create(StrUtil.utf8Bytes(data));
|
||||
return of(StrUtil.utf8Bytes(data));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@ public class FileSystemUtil {
|
||||
* @param path 文件路径,可以是目录或Zip文件等
|
||||
* @return {@link FileSystem}
|
||||
*/
|
||||
public static FileSystem create(final String path) {
|
||||
public static FileSystem of(final String path) {
|
||||
try {
|
||||
return FileSystems.newFileSystem(
|
||||
Paths.get(path).toUri(),
|
||||
|
@ -195,8 +195,8 @@ public class WatchMonitor extends WatchServer {
|
||||
* @param watcher {@link Watcher}
|
||||
* @return WatchMonitor
|
||||
*/
|
||||
public static WatchMonitor createAll(final URI uri, final Watcher watcher) {
|
||||
return createAll(Paths.get(uri), watcher);
|
||||
public static WatchMonitor ofAll(final URI uri, final Watcher watcher) {
|
||||
return ofAll(Paths.get(uri), watcher);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -206,9 +206,9 @@ public class WatchMonitor extends WatchServer {
|
||||
* @param watcher {@link Watcher}
|
||||
* @return WatchMonitor
|
||||
*/
|
||||
public static WatchMonitor createAll(final URL url, final Watcher watcher) {
|
||||
public static WatchMonitor ofAll(final URL url, final Watcher watcher) {
|
||||
try {
|
||||
return createAll(Paths.get(url.toURI()), watcher);
|
||||
return ofAll(Paths.get(url.toURI()), watcher);
|
||||
} catch (final URISyntaxException e) {
|
||||
throw new WatchException(e);
|
||||
}
|
||||
@ -221,8 +221,8 @@ public class WatchMonitor extends WatchServer {
|
||||
* @param watcher {@link Watcher}
|
||||
* @return WatchMonitor
|
||||
*/
|
||||
public static WatchMonitor createAll(final File file, final Watcher watcher) {
|
||||
return createAll(file.toPath(), watcher);
|
||||
public static WatchMonitor ofAll(final File file, final Watcher watcher) {
|
||||
return ofAll(file.toPath(), watcher);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -232,8 +232,8 @@ public class WatchMonitor extends WatchServer {
|
||||
* @param watcher {@link Watcher}
|
||||
* @return WatchMonitor
|
||||
*/
|
||||
public static WatchMonitor createAll(final String path, final Watcher watcher) {
|
||||
return createAll(Paths.get(path), watcher);
|
||||
public static WatchMonitor ofAll(final String path, final Watcher watcher) {
|
||||
return ofAll(Paths.get(path), watcher);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -243,7 +243,7 @@ public class WatchMonitor extends WatchServer {
|
||||
* @param watcher {@link Watcher}
|
||||
* @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);
|
||||
watchMonitor.setWatcher(watcher);
|
||||
return watchMonitor;
|
||||
|
@ -145,8 +145,8 @@ public class WatchUtil {
|
||||
* @param watcher {@link Watcher}
|
||||
* @return {@link WatchMonitor}
|
||||
*/
|
||||
public static WatchMonitor createAll(final URL url, final Watcher watcher) {
|
||||
return createAll(url, 0, watcher);
|
||||
public static WatchMonitor ofAll(final URL url, final Watcher watcher) {
|
||||
return ofAll(url, 0, watcher);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -157,8 +157,8 @@ public class WatchUtil {
|
||||
* @param watcher {@link Watcher}
|
||||
* @return {@link WatchMonitor}
|
||||
*/
|
||||
public static WatchMonitor createAll(final URL url, final int maxDepth, final Watcher watcher) {
|
||||
return createAll(URLUtil.toURI(url), maxDepth, watcher);
|
||||
public static WatchMonitor ofAll(final URL url, final int maxDepth, final Watcher watcher) {
|
||||
return ofAll(URLUtil.toURI(url), maxDepth, watcher);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,8 +168,8 @@ public class WatchUtil {
|
||||
* @param watcher {@link Watcher}
|
||||
* @return {@link WatchMonitor}
|
||||
*/
|
||||
public static WatchMonitor createAll(final URI uri, final Watcher watcher) {
|
||||
return createAll(uri, 0, watcher);
|
||||
public static WatchMonitor ofAll(final URI uri, final Watcher watcher) {
|
||||
return ofAll(uri, 0, watcher);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -180,8 +180,8 @@ public class WatchUtil {
|
||||
* @param watcher {@link Watcher}
|
||||
* @return {@link WatchMonitor}
|
||||
*/
|
||||
public static WatchMonitor createAll(final URI uri, final int maxDepth, final Watcher watcher) {
|
||||
return createAll(Paths.get(uri), maxDepth, watcher);
|
||||
public static WatchMonitor ofAll(final URI uri, final int maxDepth, final Watcher watcher) {
|
||||
return ofAll(Paths.get(uri), maxDepth, watcher);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -191,8 +191,8 @@ public class WatchUtil {
|
||||
* @param watcher {@link Watcher}
|
||||
* @return {@link WatchMonitor}
|
||||
*/
|
||||
public static WatchMonitor createAll(final File file, final Watcher watcher) {
|
||||
return createAll(file, 0, watcher);
|
||||
public static WatchMonitor ofAll(final File file, final Watcher watcher) {
|
||||
return ofAll(file, 0, watcher);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -203,8 +203,8 @@ public class WatchUtil {
|
||||
* @param watcher {@link Watcher}
|
||||
* @return {@link WatchMonitor}
|
||||
*/
|
||||
public static WatchMonitor createAll(final File file, final int maxDepth, final Watcher watcher) {
|
||||
return createAll(file.toPath(), maxDepth, watcher);
|
||||
public static WatchMonitor ofAll(final File file, final int maxDepth, final Watcher watcher) {
|
||||
return ofAll(file.toPath(), maxDepth, watcher);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -214,8 +214,8 @@ public class WatchUtil {
|
||||
* @param watcher {@link Watcher}
|
||||
* @return {@link WatchMonitor}
|
||||
*/
|
||||
public static WatchMonitor createAll(final String path, final Watcher watcher) {
|
||||
return createAll(path, 0, watcher);
|
||||
public static WatchMonitor ofAll(final String path, final Watcher watcher) {
|
||||
return ofAll(path, 0, watcher);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -226,8 +226,8 @@ public class WatchUtil {
|
||||
* @param watcher {@link Watcher}
|
||||
* @return {@link WatchMonitor}
|
||||
*/
|
||||
public static WatchMonitor createAll(final String path, final int maxDepth, final Watcher watcher) {
|
||||
return createAll(Paths.get(path), maxDepth, watcher);
|
||||
public static WatchMonitor ofAll(final String path, final int maxDepth, final Watcher watcher) {
|
||||
return ofAll(Paths.get(path), maxDepth, watcher);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -237,8 +237,8 @@ public class WatchUtil {
|
||||
* @param watcher {@link Watcher}
|
||||
* @return {@link WatchMonitor}
|
||||
*/
|
||||
public static WatchMonitor createAll(final Path path, final Watcher watcher) {
|
||||
return createAll(path, 0, watcher);
|
||||
public static WatchMonitor ofAll(final Path path, final Watcher watcher) {
|
||||
return ofAll(path, 0, watcher);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -249,7 +249,7 @@ public class WatchUtil {
|
||||
* @param watcher {@link Watcher}
|
||||
* @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);
|
||||
watchMonitor.setWatcher(watcher);
|
||||
return watchMonitor;
|
||||
|
@ -26,7 +26,7 @@ public class WatcherChain implements Watcher, Chain<Watcher, WatcherChain>{
|
||||
* @param watchers 观察者列表
|
||||
* @return {@link WatcherChain}
|
||||
*/
|
||||
public static WatcherChain create(final Watcher... watchers) {
|
||||
public static WatcherChain of(final Watcher... watchers) {
|
||||
return new WatcherChain(watchers);
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class ConsoleTable {
|
||||
* @return ConsoleTable
|
||||
* @since 5.4.5
|
||||
*/
|
||||
public static ConsoleTable create() {
|
||||
public static ConsoleTable of() {
|
||||
return new ConsoleTable();
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class WeightRandom<T> implements Serializable {
|
||||
* @param <T> 权重随机获取的对象类型
|
||||
* @return WeightRandom
|
||||
*/
|
||||
public static <T> WeightRandom<T> create() {
|
||||
public static <T> WeightRandom<T> of() {
|
||||
return new WeightRandom<>();
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class CamelCaseMap<K, V> extends FuncKeyMap<K, V> {
|
||||
* @param loadFactor 加载因子
|
||||
*/
|
||||
public CamelCaseMap(final int initialCapacity, final float loadFactor) {
|
||||
this(MapBuilder.create(new HashMap<>(initialCapacity, loadFactor)));
|
||||
this(MapBuilder.of(new HashMap<>(initialCapacity, loadFactor)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,7 +62,7 @@ public class CaseInsensitiveMap<K, V> extends FuncKeyMap<K, V> {
|
||||
* @param loadFactor 加载因子
|
||||
*/
|
||||
public CaseInsensitiveMap(final int initialCapacity, final float loadFactor) {
|
||||
this(MapBuilder.create(new HashMap<>(initialCapacity, loadFactor)));
|
||||
this(MapBuilder.of(new HashMap<>(initialCapacity, loadFactor)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ public class Dict extends LinkedHashMap<String, Object> implements BasicTypeGett
|
||||
*
|
||||
* @return Dict
|
||||
*/
|
||||
public static Dict create() {
|
||||
public static Dict of() {
|
||||
return new Dict();
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ public class Dict extends LinkedHashMap<String, Object> implements BasicTypeGett
|
||||
* @return Vo
|
||||
*/
|
||||
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
|
||||
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) {
|
||||
dict.put(pair.getKey(), pair.getValue());
|
||||
}
|
||||
@ -94,7 +94,7 @@ public class Dict extends LinkedHashMap<String, Object> implements BasicTypeGett
|
||||
* @since 5.4.1
|
||||
*/
|
||||
public static Dict ofKvs(final Object... keysAndValues) {
|
||||
final Dict dict = create();
|
||||
final Dict dict = of();
|
||||
|
||||
String key = null;
|
||||
for (int i = 0; i < keysAndValues.length; i++) {
|
||||
|
@ -26,8 +26,8 @@ public class MapBuilder<K, V> implements Builder<Map<K, V>> {
|
||||
* @return MapBuilder
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public static <K, V> MapBuilder<K, V> create() {
|
||||
return create(false);
|
||||
public static <K, V> MapBuilder<K, V> of() {
|
||||
return of(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -39,8 +39,8 @@ public class MapBuilder<K, V> implements Builder<Map<K, V>> {
|
||||
* @return MapBuilder
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public static <K, V> MapBuilder<K, V> create(final boolean isLinked) {
|
||||
return create(MapUtil.newHashMap(isLinked));
|
||||
public static <K, V> MapBuilder<K, V> of(final boolean isLinked) {
|
||||
return of(MapUtil.newHashMap(isLinked));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,7 +52,7 @@ public class MapBuilder<K, V> implements Builder<Map<K, V>> {
|
||||
* @return MapBuilder
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class MapProxy implements Map<Object, Object>, OptNullBasicTypeFromObject
|
||||
* @param map 被代理的Map
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
@ -873,7 +873,7 @@ public class MapUtil {
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static MapProxy createProxy(final Map<?, ?> map) {
|
||||
return MapProxy.create(map);
|
||||
return MapProxy.of(map);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,7 +41,7 @@ public class SSLContextBuilder implements SSLProtocols, Builder<SSLContext> {
|
||||
*
|
||||
* @return SSLContextBuilder
|
||||
*/
|
||||
public static SSLContextBuilder create() {
|
||||
public static SSLContextBuilder of() {
|
||||
return new SSLContextBuilder();
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ public class SSLUtil {
|
||||
* @since 5.7.8
|
||||
*/
|
||||
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异常
|
||||
*/
|
||||
public static SSLContext createSSLContext(final String protocol, final KeyManager[] keyManagers, final TrustManager[] trustManagers) throws IORuntimeException {
|
||||
return SSLContextBuilder.create()
|
||||
return SSLContextBuilder.of()
|
||||
.setProtocol(protocol)
|
||||
.setKeyManagers(keyManagers)
|
||||
.setTrustManagers(trustManagers).build();
|
||||
|
@ -188,7 +188,7 @@ public final class UrlBuilder implements Builder<String> {
|
||||
*
|
||||
* @return UrlBuilder
|
||||
*/
|
||||
public static UrlBuilder create() {
|
||||
public static UrlBuilder of() {
|
||||
return new UrlBuilder();
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class ThreadFactoryBuilder implements Builder<ThreadFactory> {
|
||||
*
|
||||
* @return {@code ThreadFactoryBuilder}
|
||||
*/
|
||||
public static ThreadFactoryBuilder create() {
|
||||
public static ThreadFactoryBuilder of() {
|
||||
return new ThreadFactoryBuilder();
|
||||
}
|
||||
|
||||
|
@ -456,7 +456,7 @@ public class ThreadUtil {
|
||||
* @since 4.1.13
|
||||
*/
|
||||
public static ThreadFactoryBuilder createThreadFactoryBuilder() {
|
||||
return ThreadFactoryBuilder.create();
|
||||
return ThreadFactoryBuilder.of();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -468,7 +468,7 @@ public class ThreadUtil {
|
||||
* @since 5.8.0
|
||||
*/
|
||||
public static ThreadFactory createThreadFactory(final String threadNamePrefix) {
|
||||
return ThreadFactoryBuilder.create().setNamePrefix(threadNamePrefix).build();
|
||||
return ThreadFactoryBuilder.of().setNamePrefix(threadNamePrefix).build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,8 +28,8 @@ public class ReferenceUtil {
|
||||
* @param referent 被引用对象
|
||||
* @return {@link Reference}
|
||||
*/
|
||||
public static <T> Reference<T> create(final ReferenceType type, final T referent) {
|
||||
return create(type, referent, null);
|
||||
public static <T> Reference<T> of(final ReferenceType type, final T referent) {
|
||||
return of(type, referent, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,7 +41,7 @@ public class ReferenceUtil {
|
||||
* @param queue 引用队列
|
||||
* @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) {
|
||||
case SOFT:
|
||||
return new SoftReference<>(referent, queue);
|
||||
|
@ -79,7 +79,7 @@ public class BeanUtilTest {
|
||||
|
||||
@Test
|
||||
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("aGe", 12)
|
||||
.put("openId", "DFDFSDFWERWER")
|
||||
|
@ -234,8 +234,8 @@ public class CollUtilTest {
|
||||
|
||||
@Test
|
||||
public void getFieldValuesTest() {
|
||||
final Dict v1 = Dict.create().set("id", 12).set("name", "张三").set("age", 23);
|
||||
final Dict v2 = Dict.create().set("age", 13).set("id", 15).set("name", "李四");
|
||||
final Dict v1 = Dict.of().set("id", 12).set("name", "张三").set("age", 23);
|
||||
final Dict v2 = Dict.of().set("age", 13).set("id", 15).set("name", "李四");
|
||||
final ArrayList<Dict> list = ListUtil.of(v1, v2);
|
||||
|
||||
final List<Object> fieldValues = (List<Object>) CollUtil.getFieldValues(list, "name");
|
||||
@ -783,7 +783,7 @@ public class CollUtilTest {
|
||||
public void pageTest() {
|
||||
final List<Dict> objects = ListUtil.of();
|
||||
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());
|
||||
|
@ -39,7 +39,7 @@ public class MapProxyTest {
|
||||
|
||||
@Test
|
||||
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);
|
||||
Assert.assertEquals(student.getAge(), 18);
|
||||
Assert.assertEquals(student.getName(), "小明");
|
||||
|
@ -30,7 +30,7 @@ public class MapConvertTest {
|
||||
@Test
|
||||
public void mapToMapTest() {
|
||||
final Map<String, Object> srcMap = MapBuilder
|
||||
.create(new HashMap<String, Object>())
|
||||
.of(new HashMap<String, Object>())
|
||||
.put("name", "AAA")
|
||||
.put("age", 45).map();
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.hutool.core.date;
|
||||
|
||||
import cn.hutool.core.date.chinese.ChineseDate;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.hutool.core.date;
|
||||
|
||||
import cn.hutool.core.date.chinese.ChineseDate;
|
||||
import cn.hutool.core.date.chinese.GanZhi;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package cn.hutool.core.date.chinese;
|
||||
|
||||
import cn.hutool.core.date.ChineseDate;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -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.start();
|
||||
|
@ -8,7 +8,7 @@ public class ConsoleTableTest {
|
||||
@Test
|
||||
@Ignore
|
||||
public void printSBCTest() {
|
||||
ConsoleTable t = ConsoleTable.create();
|
||||
ConsoleTable t = ConsoleTable.of();
|
||||
t.addHeader("姓名", "年龄");
|
||||
t.addBody("张三", "15");
|
||||
t.addBody("李四", "29");
|
||||
@ -17,7 +17,7 @@ public class ConsoleTableTest {
|
||||
|
||||
Console.log();
|
||||
|
||||
t = ConsoleTable.create();
|
||||
t = ConsoleTable.of();
|
||||
t.addHeader("体温", "占比");
|
||||
t.addHeader("℃", "%");
|
||||
t.addBody("36.8", "10");
|
||||
@ -26,7 +26,7 @@ public class ConsoleTableTest {
|
||||
|
||||
Console.log();
|
||||
|
||||
t = ConsoleTable.create();
|
||||
t = ConsoleTable.of();
|
||||
t.addHeader("标题1", "标题2");
|
||||
t.addBody("12345", "混合321654asdfcSDF");
|
||||
t.addBody("sd e3ee ff22", "ff值");
|
||||
@ -36,7 +36,7 @@ public class ConsoleTableTest {
|
||||
@Test
|
||||
@Ignore
|
||||
public void printDBCTest() {
|
||||
ConsoleTable t = ConsoleTable.create().setSBCMode(false);
|
||||
ConsoleTable t = ConsoleTable.of().setSBCMode(false);
|
||||
t.addHeader("姓名", "年龄");
|
||||
t.addBody("张三", "15");
|
||||
t.addBody("李四", "29");
|
||||
@ -45,7 +45,7 @@ public class ConsoleTableTest {
|
||||
|
||||
Console.log();
|
||||
|
||||
t = ConsoleTable.create().setSBCMode(false);
|
||||
t = ConsoleTable.of().setSBCMode(false);
|
||||
t.addHeader("体温", "占比");
|
||||
t.addHeader("℃", "%");
|
||||
t.addBody("36.8", "10");
|
||||
|
@ -14,7 +14,7 @@ import static cn.hutool.core.lang.OptTest.User;
|
||||
public class DictTest {
|
||||
@Test
|
||||
public void dictTest(){
|
||||
final Dict dict = Dict.create()
|
||||
final Dict dict = Dict.of()
|
||||
.set("key1", 1)//int
|
||||
.set("key2", 1000L)//long
|
||||
.set("key3", DateTime.now());//Date
|
||||
@ -66,7 +66,7 @@ public class DictTest {
|
||||
@Test
|
||||
public void setFieldsTest() {
|
||||
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);
|
||||
Assert.assertEquals("hutool", dict.get("username"));
|
||||
Assert.assertNull(dict.get("nickname"));
|
||||
|
@ -8,7 +8,7 @@ public class WeightRandomTest {
|
||||
|
||||
@Test
|
||||
public void weightRandomTest() {
|
||||
final WeightRandom<String> random = WeightRandom.create();
|
||||
final WeightRandom<String> random = WeightRandom.of();
|
||||
random.add("A", 10);
|
||||
random.add("B", 50);
|
||||
random.add("C", 100);
|
||||
|
@ -9,7 +9,7 @@ public class MapBuilderTest {
|
||||
|
||||
@Test
|
||||
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(false, "b", "2")
|
||||
.put(true, "c", () -> getValue(3))
|
||||
|
@ -226,8 +226,8 @@ public class MapUtilTest {
|
||||
|
||||
@Test
|
||||
public void valuesOfKeysTest() {
|
||||
final Dict v1 = Dict.create().set("id", 12).set("name", "张三").set("age", 23);
|
||||
final Dict v2 = Dict.create().set("age", 13).set("id", 15).set("name", "李四");
|
||||
final Dict v1 = Dict.of().set("id", 12).set("name", "张三").set("age", 23);
|
||||
final Dict v2 = Dict.of().set("age", 13).set("id", 15).set("name", "李四");
|
||||
|
||||
final String[] keys = v1.keySet().toArray(new String[0]);
|
||||
final ArrayList<Object> v1s = MapUtil.valuesOfKeys(v1, keys);
|
||||
|
@ -16,7 +16,7 @@ public class UrlBuilderTest {
|
||||
|
||||
@Test
|
||||
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);
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ public class UrlBuilderTest {
|
||||
|
||||
@Test
|
||||
public void testHost() {
|
||||
final String buildUrl = UrlBuilder.create()
|
||||
final String buildUrl = UrlBuilder.of()
|
||||
.setScheme("https")
|
||||
.setHost("www.hutool.cn").build();
|
||||
Assert.assertEquals("https://www.hutool.cn/", buildUrl);
|
||||
@ -37,7 +37,7 @@ public class UrlBuilderTest {
|
||||
|
||||
@Test
|
||||
public void testHostPort() {
|
||||
final String buildUrl = UrlBuilder.create()
|
||||
final String buildUrl = UrlBuilder.of()
|
||||
.setScheme("https")
|
||||
.setHost("www.hutool.cn")
|
||||
.setPort(8080)
|
||||
@ -47,7 +47,7 @@ public class UrlBuilderTest {
|
||||
|
||||
@Test
|
||||
public void testPathAndQuery() {
|
||||
final String buildUrl = UrlBuilder.create()
|
||||
final String buildUrl = UrlBuilder.of()
|
||||
.setScheme("https")
|
||||
.setHost("www.hutool.cn")
|
||||
.addPath("/aaa").addPath("bbb")
|
||||
@ -60,7 +60,7 @@ public class UrlBuilderTest {
|
||||
|
||||
@Test
|
||||
public void testQueryWithChinese() {
|
||||
final String buildUrl = UrlBuilder.create()
|
||||
final String buildUrl = UrlBuilder.of()
|
||||
.setScheme("https")
|
||||
.setHost("www.hutool.cn")
|
||||
.addPath("/aaa").addPath("bbb")
|
||||
@ -73,7 +73,7 @@ public class UrlBuilderTest {
|
||||
|
||||
@Test
|
||||
public void testMultiQueryWithChinese() {
|
||||
final String buildUrl = UrlBuilder.create()
|
||||
final String buildUrl = UrlBuilder.of()
|
||||
.setScheme("https")
|
||||
.setHost("www.hutool.cn")
|
||||
.addPath("/s")
|
||||
@ -303,7 +303,7 @@ public class UrlBuilderTest {
|
||||
|
||||
@Test
|
||||
public void addPathEncodeTest(){
|
||||
final String url = UrlBuilder.create()
|
||||
final String url = UrlBuilder.of()
|
||||
.setScheme("https")
|
||||
.setHost("domain.cn")
|
||||
.addPath("api")
|
||||
@ -317,7 +317,7 @@ public class UrlBuilderTest {
|
||||
@Test
|
||||
public void addPathEncodeTest2(){
|
||||
// https://github.com/dromara/hutool/issues/1912
|
||||
final String url = UrlBuilder.create()
|
||||
final String url = UrlBuilder.of()
|
||||
.setScheme("https")
|
||||
.setHost("domain.cn")
|
||||
.addPath("/api/xxx/bbb")
|
||||
|
@ -9,7 +9,7 @@ public class NamingCaseTest {
|
||||
|
||||
@Test
|
||||
public void toCamelCaseTest() {
|
||||
Dict.create()
|
||||
Dict.of()
|
||||
.set("Table_Test_Of_day","tableTestOfDay")
|
||||
.set("TableTestOfDay","TableTestOfDay")
|
||||
.set("abc_1d","abc1d")
|
||||
@ -18,14 +18,14 @@ public class NamingCaseTest {
|
||||
|
||||
@Test
|
||||
public void toCamelCaseFromDashedTest() {
|
||||
Dict.create()
|
||||
Dict.of()
|
||||
.set("Table-Test-Of-day","tableTestOfDay")
|
||||
.forEach((key, value) -> Assert.assertEquals(value, NamingCase.toCamelCase(key, CharUtil.DASHED)));
|
||||
}
|
||||
|
||||
@Test
|
||||
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_")
|
||||
|
@ -15,21 +15,21 @@ public class ReferenceUtilTest {
|
||||
|
||||
@Test
|
||||
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.assertEquals(new Integer(1), integerReference.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
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.assertEquals(new Integer(1), integerReference.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
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);
|
||||
// get方法永远都返回null,PhantomReference只能用来监控对象的GC状况
|
||||
Assert.assertNull(integerReference.get());
|
||||
|
@ -123,10 +123,10 @@ public class StrUtilTest {
|
||||
@Test
|
||||
public void formatTest() {
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ public class XmlUtilTest {
|
||||
|
||||
@Test
|
||||
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("age", 12)//
|
||||
.put("game", MapUtil.builder(new LinkedHashMap<String, Object>()).put("昵称", "Looly").put("level", 14).build())//
|
||||
@ -137,7 +137,7 @@ public class XmlUtilTest {
|
||||
@Test
|
||||
public void mapToXmlTest2() {
|
||||
// 测试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"))
|
||||
.build();
|
||||
|
||||
@ -171,7 +171,7 @@ public class XmlUtilTest {
|
||||
@Test
|
||||
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")
|
||||
.build();
|
||||
final String xml = XmlUtil.mapToXmlStr(map, true);
|
||||
|
@ -411,7 +411,7 @@ public class Scheduler implements Serializable {
|
||||
if(null == this.threadExecutor){
|
||||
// 无界线程池,确保每一个需要执行的线程都可以及时运行,同时复用已有线程避免线程重复创建
|
||||
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();
|
||||
}
|
||||
this.taskLauncherManager = new TaskLauncherManager(this);
|
||||
|
@ -19,7 +19,7 @@ public class MD5 extends Digester {
|
||||
* @return MD5
|
||||
* @since 4.6.0
|
||||
*/
|
||||
public static MD5 create() {
|
||||
public static MD5 of() {
|
||||
return new MD5();
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ public class SM3 extends Digester {
|
||||
* @return SM3
|
||||
* @since 4.6.0
|
||||
*/
|
||||
public static SM3 create() {
|
||||
public static SM3 of() {
|
||||
return new SM3();
|
||||
}
|
||||
|
||||
|
@ -582,7 +582,7 @@ public abstract class AbstractDb<R extends AbstractDb<R>> extends DefaultConnect
|
||||
* @since 3.2.2
|
||||
*/
|
||||
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执行异常
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,7 +23,7 @@ public class ActiveEntity extends Entity {
|
||||
*
|
||||
* @return ActiveEntity
|
||||
*/
|
||||
public static ActiveEntity create() {
|
||||
public static ActiveEntity of() {
|
||||
return new ActiveEntity();
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ public class ActiveEntity extends Entity {
|
||||
* @param tableName 表名
|
||||
* @return ActiveEntity
|
||||
*/
|
||||
public static ActiveEntity create(final String tableName) {
|
||||
public static ActiveEntity of(final String tableName) {
|
||||
return new ActiveEntity(tableName);
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ public class ActiveEntity extends Entity {
|
||||
* @return ActiveEntity
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
|
||||
|
@ -133,7 +133,7 @@ public interface Dialect extends Serializable {
|
||||
* @throws SQLException SQL执行异常
|
||||
*/
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,7 +43,7 @@ public class AnsiSqlDialect implements Dialect {
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
@ -54,7 +54,7 @@ public class AnsiSqlDialect implements Dialect {
|
||||
throw new DbRuntimeException("Entities for batch insert is empty !");
|
||||
}
|
||||
// 批量,根据第一行数据结构生成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);
|
||||
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.");
|
||||
}
|
||||
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);
|
||||
}
|
||||
@ -83,7 +83,7 @@ public class AnsiSqlDialect implements Dialect {
|
||||
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);
|
||||
}
|
||||
@ -100,7 +100,7 @@ public class AnsiSqlDialect implements Dialect {
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class H2Dialect extends AnsiSqlDialect {
|
||||
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.");
|
||||
SqlBuilder.validateEntity(entity);
|
||||
final SqlBuilder builder = SqlBuilder.create(wrapper);
|
||||
final SqlBuilder builder = SqlBuilder.of(wrapper);
|
||||
|
||||
final StringBuilder fieldsPart = new StringBuilder();
|
||||
final StringBuilder placeHolder = new StringBuilder();
|
||||
|
@ -51,7 +51,7 @@ public class MysqlDialect extends AnsiSqlDialect{
|
||||
@Override
|
||||
public PreparedStatement psForUpsert(final Connection conn, final Entity entity, final String... keys) throws SQLException {
|
||||
SqlBuilder.validateEntity(entity);
|
||||
final SqlBuilder builder = SqlBuilder.create(wrapper);
|
||||
final SqlBuilder builder = SqlBuilder.of(wrapper);
|
||||
|
||||
final StringBuilder fieldsPart = new StringBuilder();
|
||||
final StringBuilder placeHolder = new StringBuilder();
|
||||
|
@ -35,7 +35,7 @@ public class PostgresqlDialect extends AnsiSqlDialect{
|
||||
public PreparedStatement psForUpsert(final Connection conn, final Entity entity, final String... keys) throws SQLException {
|
||||
Assert.notEmpty(keys, "Keys must be not empty for Postgres.");
|
||||
SqlBuilder.validateEntity(entity);
|
||||
final SqlBuilder builder = SqlBuilder.create(wrapper);
|
||||
final SqlBuilder builder = SqlBuilder.of(wrapper);
|
||||
|
||||
final StringBuilder fieldsPart = new StringBuilder();
|
||||
final StringBuilder placeHolder = new StringBuilder();
|
||||
|
@ -136,7 +136,7 @@ public abstract class DSFactory implements Closeable, Serializable{
|
||||
* @param setting 数据库配置项
|
||||
* @return 日志实现类
|
||||
*/
|
||||
public static DSFactory create(final Setting setting) {
|
||||
public static DSFactory of(final Setting setting) {
|
||||
final DSFactory dsFactory = doCreate(setting);
|
||||
log.debug("Use [{}] DataSource As Default", dsFactory.dataSourceName);
|
||||
return dsFactory;
|
||||
|
@ -42,7 +42,7 @@ public class GlobalDSFactory {
|
||||
if (null == factory) {
|
||||
synchronized (lock) {
|
||||
if (null == factory) {
|
||||
factory = DSFactory.create(null);
|
||||
factory = DSFactory.of(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class BeanHandler<E> implements RsHandler<E>{
|
||||
* @param beanType Bean类型
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ public class BeanListHandler<E> implements RsHandler<List<E>> {
|
||||
* @param beanType Bean类型
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class EntityHandler implements RsHandler<Entity>{
|
||||
* 创建一个 EntityHandler对象
|
||||
* @return EntityHandler对象
|
||||
*/
|
||||
public static EntityHandler create() {
|
||||
public static EntityHandler of() {
|
||||
return new EntityHandler();
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class EntityListHandler implements RsHandler<List<Entity>>{
|
||||
* 创建一个 EntityListHandler对象
|
||||
* @return EntityListHandler对象
|
||||
*/
|
||||
public static EntityListHandler create() {
|
||||
public static EntityListHandler of() {
|
||||
return new EntityListHandler();
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ public class EntitySetHandler implements RsHandler<LinkedHashSet<Entity>>{
|
||||
* 创建一个 EntityHandler对象
|
||||
* @return EntityHandler对象
|
||||
*/
|
||||
public static EntitySetHandler create() {
|
||||
public static EntitySetHandler of() {
|
||||
return new EntitySetHandler();
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ public class NumberHandler implements RsHandler<Number>{
|
||||
* 创建一个 NumberHandler对象
|
||||
* @return NumberHandler对象
|
||||
*/
|
||||
public static NumberHandler create() {
|
||||
public static NumberHandler of() {
|
||||
return new NumberHandler();
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class PageResultHandler implements RsHandler<PageResult<Entity>> {
|
||||
* @param pageResult 分页结果集空对象
|
||||
* @return EntityHandler对象
|
||||
*/
|
||||
public static PageResultHandler create(final PageResult<Entity> pageResult) {
|
||||
public static PageResultHandler of(final PageResult<Entity> pageResult) {
|
||||
return new PageResultHandler(pageResult);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ public class StringHandler implements RsHandler<String>{
|
||||
* 创建一个 NumberHandler对象
|
||||
* @return NumberHandler对象
|
||||
*/
|
||||
public static StringHandler create() {
|
||||
public static StringHandler of() {
|
||||
return new StringHandler();
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ public class ValueListHandler implements RsHandler<List<List<Object>>>{
|
||||
* 创建一个 EntityListHandler对象
|
||||
* @return EntityListHandler对象
|
||||
*/
|
||||
public static ValueListHandler create() {
|
||||
public static ValueListHandler of() {
|
||||
return new ValueListHandler();
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class Column implements Serializable, Cloneable {
|
||||
* @return 列对象
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ public class ColumnIndexInfo implements Serializable, Cloneable {
|
||||
* @param rs 结果集,通过DatabaseMetaData#getIndexInfo获取
|
||||
* @return ColumnIndexInfo
|
||||
*/
|
||||
public static ColumnIndexInfo create(final ResultSet rs) {
|
||||
public static ColumnIndexInfo of(final ResultSet rs) {
|
||||
try {
|
||||
return new ColumnIndexInfo(
|
||||
rs.getString("COLUMN_NAME"),
|
||||
|
@ -207,7 +207,7 @@ public class MetaUtil {
|
||||
* @since 5.7.22
|
||||
*/
|
||||
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;
|
||||
try {
|
||||
conn = ds.getConnection();
|
||||
@ -246,7 +246,7 @@ public class MetaUtil {
|
||||
try (final ResultSet rs = metaData.getColumns(catalog, schema, tableName, null)) {
|
||||
if (null != rs) {
|
||||
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);
|
||||
indexInfoMap.put(key, indexInfo);
|
||||
}
|
||||
indexInfo.getColumnIndexInfoList().add(ColumnIndexInfo.create(rs));
|
||||
indexInfo.getColumnIndexInfoList().add(ColumnIndexInfo.of(rs));
|
||||
}
|
||||
}
|
||||
table.setIndexInfoList(ListUtil.of(indexInfoMap.values()));
|
||||
|
@ -45,7 +45,7 @@ public class Table implements Serializable, Cloneable {
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class SqlBuilder implements Builder<String> {
|
||||
*
|
||||
* @return SQL构建器
|
||||
*/
|
||||
public static SqlBuilder create() {
|
||||
public static SqlBuilder of() {
|
||||
return new SqlBuilder();
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ public class SqlBuilder implements Builder<String> {
|
||||
* @param wrapper 包装器
|
||||
* @return SQL构建器
|
||||
*/
|
||||
public static SqlBuilder create(final Wrapper wrapper) {
|
||||
public static SqlBuilder of(final Wrapper wrapper) {
|
||||
return new SqlBuilder(wrapper);
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ public class SqlBuilder implements Builder<String> {
|
||||
* @since 5.5.3
|
||||
*/
|
||||
public static SqlBuilder of(final CharSequence sql) {
|
||||
return create().append(sql);
|
||||
return of().append(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,9 +23,9 @@ public class OracleTest {
|
||||
final Query query = new Query(SqlUtil.buildConditions(where), where.getTableName());
|
||||
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 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(" ) row_ where rownum <= ").append(startEnd[1])//
|
||||
.append(") table_alias")//
|
||||
|
@ -7,22 +7,22 @@ public class SqlBuilderTest {
|
||||
|
||||
@Test
|
||||
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());
|
||||
|
||||
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());
|
||||
|
||||
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());
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
@Test
|
||||
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)
|
||||
.on("user.id = role.user_id")
|
||||
.where(new Condition("age", ">=", 18),
|
||||
|
@ -59,7 +59,7 @@ public abstract class ProxyFactory implements Serializable {
|
||||
* @return 代理对象
|
||||
*/
|
||||
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 代理工厂
|
||||
*/
|
||||
public static ProxyFactory create() {
|
||||
public static ProxyFactory of() {
|
||||
return ServiceLoaderUtil.loadFirstAvailable(ProxyFactory.class);
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class CompressUtil {
|
||||
if (ArchiveStreamFactory.SEVEN_Z.equalsIgnoreCase(archiverName)) {
|
||||
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)) {
|
||||
return new SevenZArchiver(out);
|
||||
}
|
||||
return StreamArchiver.create(charset, archiverName, out);
|
||||
return StreamArchiver.of(charset, archiverName, out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,7 +41,7 @@ public class StreamArchiver implements Archiver {
|
||||
* @param file 归档输出的文件
|
||||
* @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);
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ public class StreamArchiver implements Archiver {
|
||||
* @param out 归档输出的流
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class ExpressionFactory {
|
||||
* @return 单例的{@link ExpressionEngine}
|
||||
*/
|
||||
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}
|
||||
*/
|
||||
public static ExpressionEngine create() {
|
||||
public static ExpressionEngine of() {
|
||||
final ExpressionEngine engine = doCreate();
|
||||
StaticLog.debug("Use [{}] Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine"));
|
||||
return engine;
|
||||
|
@ -141,7 +141,7 @@ public class Ftp extends AbstractFtp {
|
||||
* @since 5.7.22
|
||||
*/
|
||||
public Ftp(final FTPClient client) {
|
||||
super(FtpConfig.create());
|
||||
super(FtpConfig.of());
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ import java.nio.charset.Charset;
|
||||
public class FtpConfig implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static FtpConfig create() {
|
||||
public static FtpConfig of() {
|
||||
return new FtpConfig();
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class SimpleFtpServer {
|
||||
*
|
||||
* @return SimpleFtpServer
|
||||
*/
|
||||
public static SimpleFtpServer create() {
|
||||
public static SimpleFtpServer of() {
|
||||
return new SimpleFtpServer();
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ public class Mail implements Builder<MimeMessage> {
|
||||
* @param mailAccount 邮件帐号
|
||||
* @return Mail
|
||||
*/
|
||||
public static Mail create(final MailAccount mailAccount) {
|
||||
public static Mail of(final MailAccount mailAccount) {
|
||||
return new Mail(mailAccount);
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ public class Mail implements Builder<MimeMessage> {
|
||||
*
|
||||
* @return Mail
|
||||
*/
|
||||
public static Mail create() {
|
||||
public static Mail of() {
|
||||
return new Mail();
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
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)) {
|
||||
|
@ -21,7 +21,7 @@ public class PinyinFactory {
|
||||
* @return 单例的PinyinEngine
|
||||
*/
|
||||
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}
|
||||
*/
|
||||
public static PinyinEngine create() {
|
||||
public static PinyinEngine of() {
|
||||
final PinyinEngine engine = doCreate();
|
||||
StaticLog.debug("Use [{}] Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine"));
|
||||
return engine;
|
||||
|
@ -50,7 +50,7 @@ public class QrConfig {
|
||||
* @return QrConfig
|
||||
* @since 4.1.14
|
||||
*/
|
||||
public static QrConfig create() {
|
||||
public static QrConfig of() {
|
||||
return new QrConfig();
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class Sftp extends AbstractFtp {
|
||||
* @since 4.1.14
|
||||
*/
|
||||
public Sftp(final Session session, final Charset charset) {
|
||||
super(FtpConfig.create().setCharset(charset));
|
||||
super(FtpConfig.of().setCharset(charset));
|
||||
init(session, charset);
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ public class Sftp extends AbstractFtp {
|
||||
* @param charset 编码
|
||||
*/
|
||||
public Sftp(final ChannelSftp channel, final Charset charset) {
|
||||
super(FtpConfig.create().setCharset(charset));
|
||||
super(FtpConfig.of().setCharset(charset));
|
||||
init(channel, charset);
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ public class Sftp extends AbstractFtp {
|
||||
* @since 5.8.4
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ public class Sftp extends AbstractFtp {
|
||||
* @since 5.8.4
|
||||
*/
|
||||
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);
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------- Constructor end
|
||||
|
@ -18,7 +18,7 @@ public class TemplateUtil {
|
||||
* @since 4.1.11
|
||||
*/
|
||||
public static TemplateEngine createEngine() {
|
||||
return TemplateFactory.create();
|
||||
return TemplateFactory.of();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -29,6 +29,6 @@ public class TemplateUtil {
|
||||
* @return {@link TemplateEngine}
|
||||
*/
|
||||
public static TemplateEngine createEngine(final TemplateConfig config) {
|
||||
return TemplateFactory.create(config);
|
||||
return TemplateFactory.of(config);
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class TemplateFactory {
|
||||
* @return 单例的TemplateEngine
|
||||
*/
|
||||
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}
|
||||
* @since 5.3.3
|
||||
*/
|
||||
public static TemplateEngine create() {
|
||||
return create(new TemplateConfig());
|
||||
public static TemplateEngine of() {
|
||||
return of(new TemplateConfig());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -44,7 +44,7 @@ public class TemplateFactory {
|
||||
* @param config 模板配置,包括编码、模板文件path等信息
|
||||
* @return {@link TemplateEngine}
|
||||
*/
|
||||
public static TemplateEngine create(final TemplateConfig config) {
|
||||
public static TemplateEngine of(final TemplateConfig config) {
|
||||
final TemplateEngine engine = doCreate(config);
|
||||
StaticLog.debug("Use [{}] Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine"));
|
||||
return engine;
|
||||
|
@ -84,7 +84,7 @@ public class WitEngine implements TemplateEngine {
|
||||
Dict dict = null;
|
||||
|
||||
if (null != config) {
|
||||
dict = Dict.create();
|
||||
dict = Dict.of();
|
||||
// 自定义编码
|
||||
dict.set("DEFAULT_ENCODING", config.getCharset());
|
||||
|
||||
|
@ -4,7 +4,7 @@ import cn.hutool.extra.tokenizer.engine.TokenizerFactory;
|
||||
|
||||
/**
|
||||
* 分词工具类
|
||||
*
|
||||
*
|
||||
* @author looly
|
||||
* @since 4.3.3
|
||||
*/
|
||||
@ -12,10 +12,10 @@ public class TokenizerUtil {
|
||||
|
||||
/**
|
||||
* 根据用户引入的分词引擎jar,自动创建对应的分词引擎对象
|
||||
*
|
||||
*
|
||||
* @return {@link TokenizerEngine}
|
||||
*/
|
||||
public static TokenizerEngine createEngine() {
|
||||
return TokenizerFactory.create();
|
||||
return TokenizerFactory.of();
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class TokenizerFactory {
|
||||
* @since 5.3.3
|
||||
*/
|
||||
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}
|
||||
*/
|
||||
public static TokenizerEngine create() {
|
||||
public static TokenizerEngine of() {
|
||||
final TokenizerEngine engine = doCreate();
|
||||
StaticLog.debug("Use [{}] Tokenizer Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine"));
|
||||
return engine;
|
||||
|
@ -16,7 +16,7 @@ public class ArchiverTest {
|
||||
@Ignore
|
||||
public void zipTest(){
|
||||
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)->{
|
||||
Console.log("Add: {}", f.getPath());
|
||||
return true;
|
||||
@ -28,7 +28,7 @@ public class ArchiverTest {
|
||||
@Ignore
|
||||
public void tarTest(){
|
||||
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)->{
|
||||
Console.log("Add: {}", f.getPath());
|
||||
return true;
|
||||
@ -40,7 +40,7 @@ public class ArchiverTest {
|
||||
@Ignore
|
||||
public void cpioTest(){
|
||||
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)->{
|
||||
Console.log("Add: {}", f.getPath());
|
||||
return true;
|
||||
|
@ -21,17 +21,17 @@ public class AviatorTest {
|
||||
final ExpressionEngine engine = new AviatorEngine();
|
||||
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 + \"]\"";
|
||||
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);
|
||||
|
||||
// Assignment.
|
||||
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", foo.bars[0].getName());
|
||||
|
||||
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);
|
||||
Assert.assertNull(result);
|
||||
Assert.assertNull(foo.bars[0]);
|
||||
|
@ -16,7 +16,7 @@ public class ExpressionUtilTest {
|
||||
|
||||
@Test
|
||||
public void evalTest(){
|
||||
final Dict dict = Dict.create()
|
||||
final Dict dict = Dict.of()
|
||||
.set("a", 100.3)
|
||||
.set("b", 45)
|
||||
.set("c", -199.100);
|
||||
@ -28,7 +28,7 @@ public class ExpressionUtilTest {
|
||||
public void jexlTest(){
|
||||
final ExpressionEngine engine = new JexlEngine();
|
||||
|
||||
final Dict dict = Dict.create()
|
||||
final Dict dict = Dict.of()
|
||||
.set("a", 100.3)
|
||||
.set("b", 45)
|
||||
.set("c", -199.100);
|
||||
@ -51,7 +51,7 @@ public class ExpressionUtilTest {
|
||||
public void mvelTest(){
|
||||
final ExpressionEngine engine = new MvelEngine();
|
||||
|
||||
final Dict dict = Dict.create()
|
||||
final Dict dict = Dict.of()
|
||||
.set("a", 100.3)
|
||||
.set("b", 45)
|
||||
.set("c", -199.100);
|
||||
@ -63,7 +63,7 @@ public class ExpressionUtilTest {
|
||||
public void jfireELTest(){
|
||||
final ExpressionEngine engine = new JfireELEngine();
|
||||
|
||||
final Dict dict = Dict.create()
|
||||
final Dict dict = Dict.of()
|
||||
.set("a", 100.3)
|
||||
.set("b", 45)
|
||||
.set("c", -199.100);
|
||||
@ -75,7 +75,7 @@ public class ExpressionUtilTest {
|
||||
public void spELTest(){
|
||||
final ExpressionEngine engine = new SpELEngine();
|
||||
|
||||
final Dict dict = Dict.create()
|
||||
final Dict dict = Dict.of()
|
||||
.set("a", 100.3)
|
||||
.set("b", 45)
|
||||
.set("c", -199.100);
|
||||
@ -87,7 +87,7 @@ public class ExpressionUtilTest {
|
||||
public void rhinoTest(){
|
||||
final ExpressionEngine engine = new RhinoEngine();
|
||||
|
||||
final Dict dict = Dict.create()
|
||||
final Dict dict = Dict.of()
|
||||
.set("a", 100.3)
|
||||
.set("b", 45)
|
||||
.set("c", -199.100);
|
||||
|
@ -4,7 +4,7 @@ public class SimpleFtpServerTest {
|
||||
|
||||
public static void main(final String[] args) {
|
||||
SimpleFtpServer
|
||||
.create()
|
||||
.of()
|
||||
.addAnonymous("d:/test/ftp/")
|
||||
.start();
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class MailAccountTest {
|
||||
mailAccount.setAuth(true);
|
||||
mailAccount.setSslEnable(true);
|
||||
|
||||
final Mail mail = Mail.create(mailAccount)
|
||||
final Mail mail = Mail.of(mailAccount)
|
||||
.setTos("xx@xx.com")
|
||||
.setTitle("邮箱验证")
|
||||
.setContent("您的验证码是:<h3>2333</h3>")
|
||||
|
@ -47,7 +47,7 @@ public class QrCodeUtilTest {
|
||||
final String targetPath = FileUtil.isWindows() ? "d:/test/qrcodeWithLogo.jpg" : "~/Desktop/hutool/qrcodeWithLogo.jpg";
|
||||
QrCodeUtil.generate(//
|
||||
"https://hutool.cn/", //
|
||||
QrConfig.create().setImg(icon), //
|
||||
QrConfig.of().setImg(icon), //
|
||||
FileUtil.touch(targetPath));
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ public class QrCodeUtilTest {
|
||||
|
||||
@Test
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ public class JetbrickTest {
|
||||
.setCustomEngine(JetbrickEngine.class);
|
||||
final TemplateEngine engine = TemplateUtil.createEngine(config);
|
||||
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));
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ public class JetbrickTest {
|
||||
.setCustomEngine(JetbrickEngine.class);
|
||||
final TemplateEngine engine = TemplateUtil.createEngine(config);
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -31,13 +31,13 @@ public class TemplateUtilTest {
|
||||
// 字符串模板, 默认模板引擎,此处为Beetl
|
||||
TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig());
|
||||
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);
|
||||
|
||||
// classpath中获取模板
|
||||
engine = TemplateUtil.createEngine(new TemplateConfig("templates", ResourceMode.CLASSPATH));
|
||||
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);
|
||||
}
|
||||
|
||||
@ -46,13 +46,13 @@ public class TemplateUtilTest {
|
||||
// 字符串模板
|
||||
TemplateEngine engine = new BeetlEngine(new TemplateConfig("templates"));
|
||||
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);
|
||||
|
||||
// classpath中获取模板
|
||||
engine = new BeetlEngine(new TemplateConfig("templates", ResourceMode.CLASSPATH));
|
||||
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);
|
||||
}
|
||||
|
||||
@ -62,12 +62,12 @@ public class TemplateUtilTest {
|
||||
final TemplateEngine engine = TemplateUtil.createEngine(
|
||||
new TemplateConfig("templates").setCustomEngine(RythmEngine.class));
|
||||
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);
|
||||
|
||||
// classpath中获取模板
|
||||
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);
|
||||
}
|
||||
|
||||
@ -77,14 +77,14 @@ public class TemplateUtilTest {
|
||||
TemplateEngine engine = TemplateUtil.createEngine(
|
||||
new TemplateConfig("templates", ResourceMode.STRING).setCustomEngine(FreemarkerEngine.class));
|
||||
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);
|
||||
|
||||
//ClassPath模板
|
||||
engine = TemplateUtil.createEngine(
|
||||
new TemplateConfig("templates", ResourceMode.CLASSPATH).setCustomEngine(FreemarkerEngine.class));
|
||||
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);
|
||||
}
|
||||
|
||||
@ -94,18 +94,18 @@ public class TemplateUtilTest {
|
||||
TemplateEngine engine = TemplateUtil.createEngine(
|
||||
new TemplateConfig("templates", ResourceMode.STRING).setCustomEngine(VelocityEngine.class));
|
||||
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);
|
||||
|
||||
//ClassPath模板
|
||||
engine = TemplateUtil.createEngine(
|
||||
new TemplateConfig("templates", ResourceMode.CLASSPATH).setCustomEngine(VelocityEngine.class));
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -115,14 +115,14 @@ public class TemplateUtilTest {
|
||||
TemplateEngine engine = TemplateUtil.createEngine(
|
||||
new TemplateConfig("templates").setCustomEngine(EnjoyEngine.class));
|
||||
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);
|
||||
|
||||
//ClassPath模板
|
||||
engine = new EnjoyEngine(
|
||||
new TemplateConfig("templates", ResourceMode.CLASSPATH).setCustomEngine(EnjoyEngine.class));
|
||||
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);
|
||||
}
|
||||
|
||||
@ -132,14 +132,14 @@ public class TemplateUtilTest {
|
||||
TemplateEngine engine = TemplateUtil.createEngine(
|
||||
new TemplateConfig("templates").setCustomEngine(ThymeleafEngine.class));
|
||||
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);
|
||||
|
||||
//ClassPath模板
|
||||
engine = TemplateUtil.createEngine(
|
||||
new TemplateConfig("templates", ResourceMode.CLASSPATH).setCustomEngine(ThymeleafEngine.class));
|
||||
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);
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ public class TemplateUtilTest {
|
||||
.setCustomEngine(WitEngine.class);
|
||||
TemplateEngine engine = TemplateUtil.createEngine(config);
|
||||
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));
|
||||
|
||||
// 字符串模板
|
||||
@ -170,7 +170,7 @@ public class TemplateUtilTest {
|
||||
.setCustomEngine(WitEngine.class);
|
||||
engine = TemplateUtil.createEngine(config);
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class ThymeleafTest {
|
||||
// 字符串模板
|
||||
final TemplateEngine engine = new ThymeleafEngine(new TemplateConfig());
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ public class VelocityTest {
|
||||
config.setCharset(CharsetUtil.GBK);
|
||||
final TemplateEngine engine = TemplateUtil.createEngine(config);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user