Releases: ifeilong/feilong-core
1.10.0
本次升级共有34
处变更,具体参见 1.10.0 milestone
1.10.0 文档地址: http://feilong-core.mydoc.io/
1.特性 🆕
- none
2.修改
- 💩
ResourceBundleUtil.getResourceBundle(InputStream)
close InputStream fix #588 - 🎨 update some method param type from
Collection
toIterable
fix #563 - 📝 update
BeanUtil.populate
javadoc fix #561 - 📝 update error javadoc fix #560
3.移除
-
🚚 move json function fix #568
-
🔥 CollectionsUtil remove
List<O> removeAll(Collection<O> objectCollection,String propertyName,Collection<V> propertyValueList
fix #565 -
🔥 CollectionsUtil remove
List<O> removeAll(Collection<O> objectCollection,String propertyName,V...propertyValues)
fix #564 -
🚚 move
com.feilong.test
pacage to feilong-commons-test fix #578 -
➖ remove commons-lang:commons-lang fix #576
-
🔥 remove
@Deprecated
Constantscom.feilong.core.RegexPattern.AN
fix #585 -
🔥 remove
@Deprecated
Constantscom.feilong.core.RegexPattern.ANS
fix #586 -
🔥 remove
@Deprecated
Constantscom.feilong.core.RegexPattern.NUMBER
fix #587 -
🔥 remove
@Deprecated
Constantscom.feilong.core.RegexPattern.IP
fix #584 -
🔥 remove
@Deprecated
Constantscom.feilong.core.RegexPattern.LETTER_LOWERCASE
fix #583 -
🔥 remove
@Deprecated
Constantscom.feilong.core.RegexPattern.LETTER
fix #582 -
🔥 remove
@Deprecated
Constantscom.feilong.core.RegexPattern.LETTER_UPPERCASE
fix #581 -
🔥 remove
@Deprecated
Constantscom.feilong.core.RegexPattern.URLLINK
fix #580上述常量 建议使用的方案参见
RegexPattern
类上的 javadoc
4.Bug 修复 🐛
- none
1.9.6
具体参见 1.9.6 milestone
1.9.6 文档地址: http://feilong-core.mydoc.io/
1.特性 🆕
-
✨
ConvertUtil
添加Set<T> toSet(T...arrays)
方法 fix #554数组转成 Set (LinkedHashSet).
说明:
- 此方法返回的是LinkedHashSet
特别适合:
如果你要通过以下方式来构造Set:Set<String> set = new LinkedHashSet<>(); set.add("feilong1"); set.add("feilong2"); set.add("feilong2"); set.add("feilong3");
此时你可以使用:
Set<String> set = toSet("feilong1", "feilong2", "feilong2", "feilong3");
代码会更简洁
甚至于:
有很多时候,参数需要一个对象Set,构造的时候,你需要这样
Set<UserAddress> userAddresseSet = new LinkedHashSet<>(); UserAddress userAddress = new UserAddress(); userAddress.setAddress("上海"); userAddresseSet.add(userAddress);
你可以重构成:
UserAddress userAddress = new UserAddress(); userAddress.setAddress("上海"); Set<UserAddress> userAddresseSet = toSet(userAddress);
2.修改
- 📝 update javadoc fix #551
3.移除
- none
4.Bug 修复 🐛
- none
1.9.5
具体参见 1.9.5 milestone
1.特性 🆕
-
ConvertUtil
添加Map<K, V> toMap(K key1,V value1,K key2,V value2)
方法 fix #550该方法非常适合快速构造一个2个key的Map场景
比如对于以下代码:
Map<String, Long> map = new HashMap<>(); map.put("itemId", itemId); map.put("memberId", memberId); memberFavoritesDao.findMemberFavoritesByMemberIdAndItemId(map);
上面
4行
代码,可以重构成2行
:Map<String, Long> map = ConvertUtil.toMap("itemId", itemId, "memberId", memberId); memberFavoritesDao.findMemberFavoritesByMemberIdAndItemId(map);
-
BeanPredicateUtil
添加Predicate<T> equalPredicate(Map<String, ?> propertyNameAndPropertyValueMap)
方法 fix #113使用示例: 在list中查找 名字是 关羽,并且 年龄是30 的user
此时你可以:
User guanyu30 = new User("关羽", 30); List<User> list = ConvertUtil.toList(// new User("张飞", 23), new User("关羽", 24), new User("刘备", 25), guanyu30); Map<String, Object> map = ConvertUtil.toMap("name", "关羽", "age", 30); User result=com.feilong.core.util.CollectionsUtil.find(list, BeanPredicateUtil.<User> equalPredicate(map)); assertEquals(guanyu30, result);
寥寥几行代码,就可以搞定
-
BeanPredicateUtil.equalPredicate(String, V)
添加更多的 javadoc fix #546 -
添加更多的单元测试
2.修改
ConvertUtil
Map<K, V> toMap(Map.Entry<K, V>...mapEntrys)
方法重命名成Map<K, V> toMapUseEntrys(Map.Entry<K, V>...mapEntrys)
fix #549
3.移除
NumberFormatUtil
删除String format(Number value,String numberPattern)
方法, 请直接调用NumberUtil
String toString(Number value,String toStringPattern)
fix #245
4.Bug 修复 🐛
-
ParamUtil.toQueryStringUseArrayValueMap(Map<String, String[]>)
如果 map has value is null,返回paramName=
fix #372示例:
Map<String, String[]> keyAndArrayMap = new LinkedHashMap<>(); keyAndArrayMap.put("province", null); keyAndArrayMap.put("city", new String[] { "南通市" }); assertEquals("province=&city=南通市", ParamUtil.toQueryStringUseArrayValueMap(keyAndArrayMap));
1.9.4
detail see in 1.9.4 milestone
特性 🆕
- add
JsonToJavaConfig
fix #512 - add
UncapitalizeJavaIdentifierTransformer
(Singleton instance) fix #513 thanks 冯明雷 - add
DateJsonValueProcessor.DEFAULT_INSTANCE
(Singleton instance) fix #544 - add
BigDecimalJsonValueProcessor.DEFAULT_INSTANCE
(Singleton instance) fix #545 - add
SensitiveWordsJsonValueProcessor.INSTANCE
(Singleton instance) fix #514 Jsonutil
addT[] toArray(Object json,JsonToJavaConfig jsonToJavaConfig)
fix #517Jsonutil
addT toBean(Object json,JsonToJavaConfig jsonToJavaConfig)
fix #525 thanks 冯明雷Jsonutil
addList<T> toList(Object json,JsonToJavaConfig jsonToJavaConfig)
fix #520Jsonutil
addMap<String, T> toMap(Object json,JsonToJavaConfig jsonToJavaConfig)
fix #523
修改
JsonFormatConfig
rename toJavaToJsonConfig
fix #511Jsonutil
updateList<T> toList(String json,Class<T> rootClass)
toList<T> toList(Object json,Class<T> rootClass)
Jsonutil
updateMap<String, T> toMap(String json)
toMap<String, T> toMap(Object json)
fix #532
移除
- remove
JsonUtil
some method toJsonHelper
fix #534
Bug 修复 🐛
- none
1.9.3
detail see in 1.9.3 milestone
特性 🆕
-
JsonFormatConfig
addjsonTargetClassAndPropertyNameProcessorMap
property, fix #505 -
add
CapitalizePropertyNameProcessor
JsonUtil 将对象转成json 字符串的时候,支持修改属性名称
下面是使用示例:
我们这边的代码
public class CrmAddpointCommand{ // 用户编码 private String openId; // 渠道:Tmall - 天猫 JD - 京东 private String consumptionChannel; // 淘宝/京东买家账号 private String buyerId; // 电商订单编号 private String orderCode; // setter getter }
符合标准的java代码规范,如果直接使用
com.feilong.tools.jsonlib.JsonUtil.format(Object)
public void testJsonTest(){ CrmAddpointCommand crmAddpointCommand = new CrmAddpointCommand(); crmAddpointCommand.setBuyerId("123456"); crmAddpointCommand.setConsumptionChannel("feilongstore"); crmAddpointCommand.setOpenId("feilong888888ky"); crmAddpointCommand.setOrderCode("fl123456"); LOGGER.debug(JsonUtil.format(crmAddpointCommand)); }
输出结果:
{ "orderCode": "fl123456", "buyerId": "123456", "consumptionChannel": "feilongstore", "openId": "feilong888888ky" }
输出的属性大小写和
crmAddpointCommand
对象里面字段的大小写相同,但是对方接口要求首字符要大写:此时,你可以使用
public void testJsonTest(){ CrmAddpointCommand crmAddpointCommand = new CrmAddpointCommand(); crmAddpointCommand.setBuyerId("123456"); crmAddpointCommand.setConsumptionChannel("feilongstore"); crmAddpointCommand.setOpenId("feilong888888ky"); crmAddpointCommand.setOrderCode("fl123456"); //**************************************************************************************** JsonFormatConfig jsonFormatConfig = new JsonFormatConfig(); Map<Class<?>, PropertyNameProcessor> targetClassAndPropertyNameProcessorMap = newHashMap(1); targetClassAndPropertyNameProcessorMap.put(CrmAddpointCommand.class, CapitalizePropertyNameProcessor.INSTANCE); jsonFormatConfig.setJsonTargetClassAndPropertyNameProcessorMap(targetClassAndPropertyNameProcessorMap); LOGGER.debug(JsonUtil.format(crmAddpointCommand, jsonFormatConfig)); }
输出结果:
{ "OrderCode": "fl123456", "BuyerId": "123456", "ConsumptionChannel": "feilongstore", "OpenId": "feilong888888ky" }
修改
- update javadoc fix #508
移除
- none
Bug 修复 🐛
1.9.2
detail see in 1.9.2 milestone
[Feature] 🆕
ConvertUtil
addMap<I, J> toMap(Map<K, V> inputMap,final Transformer<K,I> keyTransformer, final Transformer<V, J> valueTransformer)
fix #497ConvertUtil
addMap<I, J> toMap(Map<K, V> inputMap,final Class<I> keyTargetType,final Class<J> valueTargetType)
fix #497- add
SimpleClassTransformer
example:
if you have a map that is Map<String, String>
,want to change to Map<Integer, Integer>
you can use:
Map<String, String> map = toMap("1", "2");
Map<Integer, Integer> returnMap = toMap(map, Integer.class, Integer.class);
// 输出测试
for (Map.Entry<Integer, Integer> entry : returnMap.entrySet()){
Integer key = entry.getKey();
Integer value = entry.getValue();
LOGGER.debug("key:[{}],value:[{}]", key, value);
}
output :
key:[1],value:[2]
[Update]
FieldUtil
T getFieldValue(Object obj,String fieldName)
update toprivate
, fix #493,fix #494ClassLoaderUtil
updateClassLoaderUtil.getResourceInAllClassLoader(String, Class<?>)
log level, fix #476
[Remove]
ConstructorUtil
removeT newInstance(String className,Object...parameterValues)
fix #486ClassLoaderUtil
removegetRootClassPath(ClassLoader classLoader)
method fix #477
[Fix Bug] 🐛
List<Field> getAllFieldList(final Class<?> klass,String...excludeFieldNames)
if klass is null, expect NPE,but IllegalArgumentException fix #495- update JsonUtil
Map<String, T> toMap(String json,Class<T> rootClass)
error javadoc fix #466 JsonUtil.toMap(String, Class<T>, Map<String, Class<?>>)
return type changeLinkedHashMap
instead ofHashMap
, fix #464
1.9.1
detail see in 1.9.1 milestone
[Feature] 🆕
- none
[Update]
- none
[Remove]
- none
[Fix Bug] 🐛
- ParamUtil
String addParameterSingleValueMap(String uriString,Map<String, String> singleValueMap,String charsetType)
if map is null ,same as empty map fix #460 - ParamUtil
String addParameterArrayValueMap(String uriString,Map<String, String[]> arrayValueMap,String charsetType)
if map is null ,same as empty map fix #461
1.9.0
detail see in 1.9.0 milestone
[Feature] 🆕
- none
[Update]
- update some javadoc
- add some test
BeanUtil
updatevoid setProperty(Object bean,String propertyName,Object value)
to private fix #438BeanUtil
updateString getProperty(Object bean,String propertyName)
to private fix #437ParamUtil
updateString addParameter(String uriString,String paramName,Object parameValue,String charsetType)
parameValue type from Object to String fix #448
[Remove]
ParamUtil
removeString toSafeQueryString(Map<String, String[]> arrayValueMap,String charsetType)
fix #454BeanUtil
removevoid initConverters()
fix #440BeanUtil
removevoid register(Converter converter,Class<?> klass)
fix #446,fix #447
[Fix Bug] 🐛
1.8.8
detail see in 1.8.8 milestone
[Feature] 🆕
- CollectionsUtil add
Map<T, List<O>> group(Collection<O> objectCollection,Transformer<O, T> keyTransformer)
fix #270 thanks @ananbeike - CollectionsUtil add
Map<T, List<O>> group( Collection<O> objectCollection,Predicate<O> includePredicate,Transformer<O, T> keyTransformer)
fix #270 thanks @ananbeike
[Update]
- update some javadoc
- add some test
ResourceBundleUtil
changeT readToAliasBean(ResourceBundle resourceBundle,Class<T> aliasBeanClass)
toT toAliasBean(ResourceBundle resourceBundle,Class<T> aliasBeanClass)
fix #423ResourceBundleUtil
changeProperties toProperties(ResourceBundle resourceBundle)
toProperties readToProperties(String baseName)
ResourceBundleUtil
changeResourceBundleUtil.readToMap
method toResourceBundleUtil.toMap
method
[Remove]
ResourceBundleUtil
removeString getValue(String baseName,String key,Object...arguments)
fix #410ResourceBundleUtil
removeString getValue(String baseName,Locale locale,String key,Object...arguments)
fix #411 fix #407, fix #408RandomUtil
removelong createRandom(Number minInclusiveValue,Number maxExclusiveValue)
fix #395RandomUtil
removeString createRandomFromString(String str,int minLength,int maxLength)
method ,fix #394RandomUtil
removelong createRandom(Number maxValue)
fix #296AggregateUtil
removeT getMinValue(Map<K, T> map,K...keys)
fix #347,fix #135ConvertUtil
removeMap<String, String> toMap(ResourceBundle resourceBundle)
fix #426
[Fix Bug] 🐛
- none
1.8.7
detail see in 1.8.7 milestone
[Feature] 🆕
- none
[Update]
- update some javadoc
- add some test
SortUtil
use new method name fix #366
[Remove]
- none
[Fix Bug] 🐛
- if URLUtil
URI toURI(URL url)
if url is null, will return null instead of NPE, fix #367