ClassUtil.java代码解读
来源:互联网 发布:java unix timestamp 编辑:程序博客网 时间:2024/06/05 00:49
public static <T> T getMappingSource(MappingSource<T> source) {Class<T> clazz = source.getClazz();Map<String, String> map = source.getMapping();Map<String, String> info = source.getInfo();Method[] methods = clazz.getMethods();T t = null;try {t = clazz.newInstance();} catch (InstantiationException | IllegalAccessException e) {// TODO Auto-generated catch blocke.printStackTrace();}for (Method method : methods) {String name = method.getName();if (name.startsWith("set")) {name = lowerCaseFirstWord(name.substring(3));String arg = info.get(map.get(name));if (arg != null) {try {method.invoke(t, arg);} catch (IllegalAccessException | IllegalArgumentException| InvocationTargetException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}}return t;}
1.使用两个map类的原因,防止类中元素名与映射的不一致
2.StringUtil的常用方法
3.反射的应用
0 0
- ClassUtil.java代码解读
- 常用代码备忘录-ClassUtil.java
- ClassUtil Java
- ClassUtil
- ClassUtil
- hadoop学习之WordCount.java代码解读
- hadoop学习之WordCount.java代码解读
- hadoop学习之WordCount.java代码解读
- 代码解读
- 代码解读
- ClassUtil 类工具
- 类加载工具--ClassUtil
- 递归 ———— java代码解读(1)
- KMeans.java 代码解读与时间序列聚类
- 条码打印机代码解读!
- 解读eXtremeComponents代码结构
- FFMPEG框架代码解读
- DiskPerf代码解读
- Java小程序——petshop
- 关于AM5728评估板
- PL/SQL 连接远程oracle
- 消息队列RabbitMQ的安装
- 关于build 还有hermes流程
- ClassUtil.java代码解读
- 交换机下接非vlan1的主机,实现主机与路由器的通信配置方法
- 类和对象的区别
- Makefile中 -I -L -l区别
- android错误之解析包时出现问题
- iptables 做端口转发
- [leetcode]Letter Combinations of a Phone Number
- linux磁盘管理LVM使用指南
- git基本操作