设计思想 - 第二篇
1)、设计思想之获取泛型T的真实类型
private Class < T > targetClass;
public GenericDAOImpl ( ) {
targetClass = ( Class < T > ) ( ( ParameterizedType ) getClass ( ) . getGenericSuperclass ( ) ) . getActualTypeArguments ( ) [ 0 ] ;
}
2)、设计思想之通过String,StringBuffer实现字符串反转
public static String reverse ( String str) {
return new StringBuffer ( str) . reverse ( ) . toString ( ) ;
}
3)、设计思想之MVC表现层框架的核心思想
1. 接收请求参数
2. 调用业务方法( xxxService.xxx() )处理请求
3. 控制界面跳转
4)、设计思想之使用fastjson获取用户open_id
字符串转换为JSON对象【使用fastjson】
String open_id = JSONObject . parseObject ( result) . get ( "openid" ) . toString ( ) ;
5)、设计思想之BigDecimal去掉多余的位数
BigDecimal b = new BigDecimal ( "2.225667" ) . setScale ( 2 , BigDecimal . ROUND_DOWN) ;
System . out. println ( b) ;
BigDecimal c = new BigDecimal ( "2.224667" ) . setScale ( 2 , BigDecimal . ROUND_UP) ;
System . out. println ( c) ;
6)、forEach新用法
List < Withdraw > withdraws = withdrawDao. findAllById ( list) ;
withdraws. forEach ( withdraw -> withdraw. setStatus ( WithdrawStatusEnum . checked. getType ( ) ) ) ;