本次升级共有 3
处变更, 具体参见 1.14.3 milestone
1.14.3 文档地址: http://feilong-core.mydoc.io/
单元测试数 增加至 2164
个, 单元测试覆盖率 增加至 91%
,javadoc 比率 83%
com.feilong.core.util.SortUtil
新增 sortListByFixedOrderArray(List<T>, T...)
和 sortListByFixedOrderList(List<T>, List<T>)
方法
对 集合 list 按照指定的固定顺序 fixedOrderItemList
进行排序.
默认使用的是 UnknownObjectBehavior.AFTER
,不在指定固定顺序的元素将排在后面
assertThat( sortListByFixedOrderList(toList("张飞", "关羽", "刘备"), toList("刘备", "张飞", "关羽")), // contains("刘备", "张飞", "关羽"));
对于以下代码:
try{ Collections.sort( list, new FixedOrderComparator<>( StoPropertyConstants.PRPT_ITEM_HYPELAUNCH, StoPropertyConstants.PRPT_ITEM_MIADIDAS_VALUE_EN, StoPropertyConstants.PRPT_ITEM_PRESONALLZATION_CODE, StoPropertyConstants.PRPT_ITEM_PERSALES_CODE, StoPropertyConstants.PRPT_ITEM_VIP_CODE, StoPropertyConstants.PRPT_ITEM_COMINGSOON_CODE, StoPropertyConstants.PRPT_ITEM_DISCOUNT_CODE, StoPropertyConstants.PRPT_ITEM_NORMAL_CODE, StoPropertyConstants.PRPT_ITEM_NOSALE)); }catch (Exception e){ LOGGER.error("itemType sort error:{},itemType:{}", e, JsonUtil.format(itemType)); }
可以重构成:
com.feilong.core.util.SortUtil.sortListByFixedOrderList( list, toList( StoPropertyConstants.PRPT_ITEM_HYPELAUNCH, StoPropertyConstants.PRPT_ITEM_MIADIDAS_VALUE_EN, StoPropertyConstants.PRPT_ITEM_PRESONALLZATION_CODE, StoPropertyConstants.PRPT_ITEM_PERSALES_CODE, StoPropertyConstants.PRPT_ITEM_VIP_CODE, StoPropertyConstants.PRPT_ITEM_COMINGSOON_CODE, StoPropertyConstants.PRPT_ITEM_DISCOUNT_CODE, StoPropertyConstants.PRPT_ITEM_NORMAL_CODE, StoPropertyConstants.PRPT_ITEM_NOSALE));
#789
新建 ComparatorUtil
#791
新建 ContainsStringPredicate
使用场景,参考
<bean class="com.feilong.context.converter.IfStringToBeanConverter"> <property name="predicate"> <bean class="com.feilong.core.util.predicate.ContainsStringPredicate" p:searchCharSequence="TRADE_NOT_EXIST" /> </property> <property name="trueStringToBeanConverter"> <bean class="com.feilong.netpay.alipay.query.AlipayTradeNotExistStringToBeanConverter" /> </property> <property name="falseStringToBeanConverter"> <bean class="com.feilong.context.converter.XMLMapBuilderStringToBeanConverter"> <property name="beanClass" value="com.feilong.netpay.alipay.query.AlipaySingleQueryResultCommand" /> <property name="nameAndValueMapBuilder"> <bean class="com.feilong.context.converter.builder.XmlNodeNameAndValueMapBuilder" p:xpathExpression="/alipay/response/trade/*" /> </property> <property name="beanBuilder"> <bean class="com.feilong.context.converter.builder.AliasBeanBuilder" /> </property> </bean> </property> </bean>