mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user