mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
package cn.hutool.core.util;
|
||||
package cn.hutool.core.classloader;
|
||||
|
||||
import cn.hutool.core.convert.BasicType;
|
||||
import cn.hutool.core.exceptions.UtilException;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.lang.JarClassLoader;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import cn.hutool.core.map.WeakConcurrentMap;
|
||||
import cn.hutool.core.text.CharPool;
|
@@ -1,4 +1,4 @@
|
||||
package cn.hutool.core.lang;
|
||||
package cn.hutool.core.classloader;
|
||||
|
||||
import cn.hutool.core.exceptions.UtilException;
|
||||
import cn.hutool.core.io.FileUtil;
|
@@ -1,7 +1,6 @@
|
||||
package cn.hutool.core.lang;
|
||||
package cn.hutool.core.classloader;
|
||||
|
||||
import cn.hutool.core.io.resource.Resource;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
|
||||
import java.security.SecureClassLoader;
|
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* 类加载相关封装和工具
|
||||
*
|
||||
* @author looly
|
||||
*
|
||||
*/
|
||||
package cn.hutool.core.classloader;
|
@@ -1,8 +1,8 @@
|
||||
package cn.hutool.core.compiler;
|
||||
|
||||
import cn.hutool.core.io.resource.FileObjectResource;
|
||||
import cn.hutool.core.lang.ResourceClassLoader;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ResourceClassLoader;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
|
||||
import javax.tools.FileObject;
|
||||
|
@@ -9,7 +9,7 @@ import cn.hutool.core.io.resource.StringResource;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.net.URLUtil;
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.hutool.core.convert.impl;
|
||||
|
||||
import cn.hutool.core.convert.AbstractConverter;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
|
||||
/**
|
||||
* 类转换器<br>
|
||||
|
@@ -7,7 +7,7 @@ import cn.hutool.core.date.format.GlobalCustomFormat;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.core.util.SystemPropsUtil;
|
||||
import cn.hutool.core.util.SystemUtil;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.text.DateFormat;
|
||||
@@ -311,7 +311,7 @@ public class DateTime extends Date {
|
||||
* @see DatePattern
|
||||
*/
|
||||
public DateTime(CharSequence dateStr, DateParser dateParser) {
|
||||
this(dateStr, dateParser, SystemPropsUtil.getBoolean(SystemPropsUtil.HUTOOL_DATE_LENIENT, true));
|
||||
this(dateStr, dateParser, SystemUtil.getBoolean(SystemUtil.HUTOOL_DATE_LENIENT, true));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -5,7 +5,7 @@ import cn.hutool.core.collection.IterUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.core.net.URLUtil;
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.hutool.core.io.resource;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.reflect.ReflectUtil;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package cn.hutool.core.lang;
|
||||
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.EnumerationIter;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
|
@@ -14,6 +14,8 @@ import java.net.MalformedURLException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static cn.hutool.core.regex.PatternPool.*;
|
||||
|
||||
/**
|
||||
* 字段验证器(验证器),分两种类型的验证:
|
||||
*
|
||||
@@ -28,85 +30,6 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class Validator {
|
||||
|
||||
/**
|
||||
* 英文字母 、数字和下划线
|
||||
*/
|
||||
public final static Pattern GENERAL = PatternPool.GENERAL;
|
||||
/**
|
||||
* 数字
|
||||
*/
|
||||
public final static Pattern NUMBERS = PatternPool.NUMBERS;
|
||||
/**
|
||||
* 分组
|
||||
*/
|
||||
public final static Pattern GROUP_VAR = PatternPool.GROUP_VAR;
|
||||
/**
|
||||
* IP v4
|
||||
*/
|
||||
public final static Pattern IPV4 = PatternPool.IPV4;
|
||||
/**
|
||||
* IP v6
|
||||
*/
|
||||
public final static Pattern IPV6 = PatternPool.IPV6;
|
||||
/**
|
||||
* 货币
|
||||
*/
|
||||
public final static Pattern MONEY = PatternPool.MONEY;
|
||||
/**
|
||||
* 邮件
|
||||
*/
|
||||
public final static Pattern EMAIL = PatternPool.EMAIL;
|
||||
/**
|
||||
* 移动电话
|
||||
*/
|
||||
public final static Pattern MOBILE = PatternPool.MOBILE;
|
||||
|
||||
/**
|
||||
* 身份证号码
|
||||
*/
|
||||
public final static Pattern CITIZEN_ID = PatternPool.CITIZEN_ID;
|
||||
|
||||
/**
|
||||
* 邮编
|
||||
*/
|
||||
public final static Pattern ZIP_CODE = PatternPool.ZIP_CODE;
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
public final static Pattern BIRTHDAY = PatternPool.BIRTHDAY;
|
||||
/**
|
||||
* URL
|
||||
*/
|
||||
public final static Pattern URL = PatternPool.URL;
|
||||
/**
|
||||
* Http URL
|
||||
*/
|
||||
public final static Pattern URL_HTTP = PatternPool.URL_HTTP;
|
||||
/**
|
||||
* 中文字、英文字母、数字和下划线
|
||||
*/
|
||||
public final static Pattern GENERAL_WITH_CHINESE = PatternPool.GENERAL_WITH_CHINESE;
|
||||
/**
|
||||
* UUID
|
||||
*/
|
||||
public final static Pattern UUID = PatternPool.UUID;
|
||||
/**
|
||||
* 不带横线的UUID
|
||||
*/
|
||||
public final static Pattern UUID_SIMPLE = PatternPool.UUID_SIMPLE;
|
||||
/**
|
||||
* 中国车牌号码
|
||||
*/
|
||||
public final static Pattern PLATE_NUMBER = PatternPool.PLATE_NUMBER;
|
||||
/**
|
||||
* 车架号;别名:车辆识别代号 车辆识别码;十七位码
|
||||
*/
|
||||
public final static Pattern CAR_VIN = PatternPool.CAR_VIN;
|
||||
/**
|
||||
* 驾驶证 别名:驾驶证档案编号、行驶证编号;12位数字字符串;仅限:中国驾驶证档案编号
|
||||
*/
|
||||
public final static Pattern CAR_DRIVING_LICENCE = PatternPool.CAR_DRIVING_LICENCE;
|
||||
|
||||
/**
|
||||
* 给定值是否为{@code true}
|
||||
*
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.hutool.core.lang.id;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.RuntimeUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
|
@@ -4,7 +4,7 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.getter.OptNullBasicTypeFromObjectGetter;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@@ -8,7 +8,7 @@ import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.net.url.UrlQuery;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
@@ -205,7 +205,7 @@ public class ByteUtil {
|
||||
/**
|
||||
* long转byte数组<br>
|
||||
* 默认以小端序转换<br>
|
||||
* from: https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java
|
||||
* from: <a href="https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java">https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java</a>
|
||||
*
|
||||
* @param longValue long值
|
||||
* @return byte数组
|
||||
@@ -217,7 +217,7 @@ public class ByteUtil {
|
||||
/**
|
||||
* long转byte数组<br>
|
||||
* 自定义端序<br>
|
||||
* from: https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java
|
||||
* from: <a href="https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java">https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java</a>
|
||||
*
|
||||
* @param longValue long值
|
||||
* @param byteOrder 端序
|
||||
@@ -242,7 +242,7 @@ public class ByteUtil {
|
||||
/**
|
||||
* byte数组转long<br>
|
||||
* 默认以小端序转换<br>
|
||||
* from: https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java
|
||||
* from: <a href="https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java">https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java</a>
|
||||
*
|
||||
* @param bytes byte数组
|
||||
* @return long值
|
||||
@@ -254,7 +254,7 @@ public class ByteUtil {
|
||||
/**
|
||||
* byte数组转long<br>
|
||||
* 自定义端序<br>
|
||||
* from: https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java
|
||||
* from: <a href="https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java">https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java</a>
|
||||
*
|
||||
* @param bytes byte数组
|
||||
* @param byteOrder 端序
|
||||
@@ -267,7 +267,7 @@ public class ByteUtil {
|
||||
/**
|
||||
* byte数组转long<br>
|
||||
* 自定义端序<br>
|
||||
* from: https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java
|
||||
* from: <a href="https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java">https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java</a>
|
||||
*
|
||||
* @param bytes byte数组
|
||||
* @param start 计算数组开始位置
|
||||
@@ -354,7 +354,7 @@ public class ByteUtil {
|
||||
/**
|
||||
* double转byte数组<br>
|
||||
* 自定义端序<br>
|
||||
* from: https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java
|
||||
* from: <a href="https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java">https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java</a>
|
||||
*
|
||||
* @param doubleValue double值
|
||||
* @param byteOrder 端序
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package cn.hutool.core.util;
|
||||
|
||||
import cn.hutool.core.bean.NullWrapperBean;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.convert.BasicType;
|
||||
import cn.hutool.core.exceptions.UtilException;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package cn.hutool.core.util;
|
||||
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
@@ -17,7 +17,7 @@ import java.util.Properties;
|
||||
* @author looly
|
||||
* @since 5.7.16
|
||||
*/
|
||||
public class SystemPropsUtil {
|
||||
public class SystemUtil {
|
||||
|
||||
/** Hutool自定义系统属性:是否解析日期字符串采用严格模式 */
|
||||
public static String HUTOOL_DATE_LENIENT = "hutool.date.lenient";
|
@@ -243,8 +243,8 @@ public class ValidatorTest {
|
||||
String content = "https://detail.tmall.com/item.htm?" +
|
||||
"id=639428931841&ali_refid=a3_430582_1006:1152464078:N:Sk5vwkMVsn5O6DcnvicELrFucL21A32m:0af8611e23c1d07697e";
|
||||
|
||||
Assert.assertTrue(Validator.isMatchRegex(Validator.URL, content));
|
||||
Assert.assertTrue(Validator.isMatchRegex(Validator.URL_HTTP, content));
|
||||
Assert.assertTrue(Validator.isMatchRegex(PatternPool.URL, content));
|
||||
Assert.assertTrue(Validator.isMatchRegex(PatternPool.URL_HTTP, content));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -2,7 +2,7 @@ package cn.hutool.core.lang.reflect;
|
||||
|
||||
import cn.hutool.core.reflect.MethodHandleUtil;
|
||||
import cn.hutool.core.reflect.ReflectUtil;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@@ -1,15 +1,16 @@
|
||||
package cn.hutool.core.util;
|
||||
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ClassLoaderUtilTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void loadClassTest() {
|
||||
String name = ClassLoaderUtil.loadClass("java.lang.Thread.State").getName();
|
||||
Assert.assertEquals("java.lang.Thread$State", name);
|
||||
|
||||
|
||||
name = ClassLoaderUtil.loadClass("java.lang.Thread$State").getName();
|
||||
Assert.assertEquals("java.lang.Thread$State", name);
|
||||
}
|
||||
|
Reference in New Issue
Block a user