mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-24 18:04:54 +08:00
Merge branch 'v6-dev' of gitee.com:dromara/hutool into v6-dev
This commit is contained in:
commit
671c4031d7
@ -680,8 +680,7 @@ public class BeanUtil {
|
||||
return (T) RecordConverter.INSTANCE.convert(tClass, source);
|
||||
}
|
||||
final T target = ConstructorUtil.newInstanceIfPossible(tClass);
|
||||
copyProperties(source, target, CopyOptions.of().setIgnoreProperties(ignoreProperties));
|
||||
return target;
|
||||
return copyProperties(source, target, CopyOptions.of().setIgnoreProperties(ignoreProperties));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -692,8 +691,8 @@ public class BeanUtil {
|
||||
* @param target 目标Bean对象
|
||||
* @param ignoreProperties 不拷贝的的属性列表
|
||||
*/
|
||||
public static void copyProperties(final Object source, final Object target, final String... ignoreProperties) {
|
||||
copyProperties(source, target, CopyOptions.of().setIgnoreProperties(ignoreProperties));
|
||||
public static <T> T copyProperties(final Object source, final T target, final String... ignoreProperties) {
|
||||
return copyProperties(source, target, CopyOptions.of().setIgnoreProperties(ignoreProperties));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -703,8 +702,8 @@ public class BeanUtil {
|
||||
* @param target 目标Bean对象
|
||||
* @param ignoreCase 是否忽略大小写
|
||||
*/
|
||||
public static void copyProperties(final Object source, final Object target, final boolean ignoreCase) {
|
||||
BeanCopier.of(source, target, CopyOptions.of().setIgnoreCase(ignoreCase)).copy();
|
||||
public static <T> T copyProperties(final Object source, final T target, final boolean ignoreCase) {
|
||||
return BeanCopier.of(source, target, CopyOptions.of().setIgnoreCase(ignoreCase)).copy();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -715,11 +714,11 @@ public class BeanUtil {
|
||||
* @param target 目标Bean对象
|
||||
* @param copyOptions 拷贝选项,见 {@link CopyOptions}
|
||||
*/
|
||||
public static void copyProperties(final Object source, final Object target, final CopyOptions copyOptions) {
|
||||
public static <T> T copyProperties(final Object source, final T target, final CopyOptions copyOptions) {
|
||||
if (null == source || null == target) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
BeanCopier.of(source, target, ObjUtil.defaultIfNull(copyOptions, CopyOptions::of)).copy();
|
||||
return BeanCopier.of(source, target, ObjUtil.defaultIfNull(copyOptions, CopyOptions::of)).copy();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,6 @@
|
||||
package org.dromara.hutool.db.driver;
|
||||
|
||||
import org.dromara.hutool.core.util.RandomUtil;
|
||||
import org.dromara.hutool.db.driver.DriverUtil;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@ -25,7 +24,7 @@ public class DriverUtilTest {
|
||||
@Test
|
||||
public void identifyH2DriverTest(){
|
||||
final String url = "jdbc:h2:file:./db/test;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE;MODE=MYSQL";
|
||||
final String driver = DriverUtil.identifyDriver(url); // driver 返回 mysql 的 driver
|
||||
final String driver = DriverUtil.identifyDriver(url); // driver 返回 h2 的 driver
|
||||
Assertions.assertEquals("org.h2.Driver", driver);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user