当前位置:网站首页>Collection object replication
Collection object replication
2022-06-26 09:22:00 【Java backend Guide】
/**
* Copy of collection data
* @param sources: The data source class
* @param target: Target class ::new(eg: UserVO::new)
* @return
*/
public static <S, T> List<T> copyListProperties(List<S> sources, Supplier<T> target) {
return copyListProperties(sources, target, null);
}
/**
* Copy of collection data with callback function ( You can customize the field copy rules )
* @param sources: The data source class
* @param target: Target class ::new(eg: UserVO::new)
* @param callBack: Callback function
* @return
*/
public static <S, T> List<T> copyListProperties(List<S> sources, Supplier<T> target, BeanCopyUtilCallBack<S, T> callBack) {
List<T> list = new ArrayList<>(sources.size());
for (S source : sources) {
T t = target.get();
copyProperties(source, t);
list.add(t);
if (callBack != null) {
// Callback
callBack.callBack(source, t);
}
}
return list;
}
@FunctionalInterface
public interface BeanCopyUtilCallBack <S, T> {
/**
* Define the default callback method
* @param t
* @param s
*/
void callBack(S t, T s);
}
边栏推荐
- 【Sensors 2021】Relation-Based Deep Attention Network with Hybrid Memory for One-Shot Person Re-Id
- Course paper: Copula modeling code of portfolio risk VaR
- Behavior tree XML file hot load
- Phpcms V9 mall module (fix the Alipay interface Bug)
- 教程1:Hello Behaviac
- Board end power hardware debugging bug
- Notes on setting qccheckbox style
- Runtimeerror: object has no attribute NMS error record when using detectron2
- Programming training 7- date conversion problem
- "One week's data collection" - logic gate
猜你喜欢

Phpcms V9 mall module (fix the Alipay interface Bug)

Nacos registry structure and the principle of massive service registration and concurrent read-write source code analysis

《一周搞定模电》-光耦等元器件

php提取txt文本存储json数据中的域名

实践是成为网工最快的方法,网络工程师实战项目整理

ThreadLocal

kubernetes集群部署(v1.23.5)

Phpcms V9 background article list adds one click push to Baidu function

Detectron2 save (according to maxap50) model during training_ best. PTH weight

《一周搞定数电》——组合逻辑电路
随机推荐
0 basic how to make a cool leadership cockpit?
thinkphp5使用composer安装插件提示php版本过高
【Open5GS】Open5GS安装配置
Edge computing is the sinking and extension of cloud computing capabilities to the edge and user sides
Practice of production control | dilemma on assembly rack
Detectron2 outputs validation loss during training
3大问题!Redis缓存异常及处理方案总结
Phpcms V9 background article list adds one click push to Baidu function
[cloud primordial | kubernetes chapter] go deep into the foundation of all things - container (V)
kubernetes集群部署(v1.23.5)
报错ImportError: numpy.core.multiarray failed to import
运行时端常用类的介绍
Self taught programming series - 4 numpy arrays
实践是成为网工最快的方法,网络工程师实战项目整理
"One week's work on Analog Electronics" - power amplifier
Which software is safer to open an account on
Edit type information
简析ROS计算图级
How to view the data mini map quickly and conveniently after importing data in origin
【开源】使用PhenoCV-WeedCam进行更智能、更精确的杂草管理