Java常用API包及骚操作

2017/04/07 - Java

lombok(@data) https://my.oschina.net/darkness/blog/510808

org.apache.commons.lang3.StringUtils

ReflectionToStringBuilder//不用写toString了

org.apache.commons.beanutils//操作javabean

stream API

private List<CheckResult> checkResults = new ArrayList<>();
// ....
return checkResults.stream().filter(CheckResult::isSuccess).findFirst().orElse(null);

FastJSON

//com.alibaba.fastjson
configTO.setHeaderPageInfo(JSON.parseObject(configDO.getHeaderPageInfoStr(), HeaderPageInfo.class));

JSONArray jsonArray = JSON.parseArray(configDO.getBizResDataStr());
JSONObject jsonObject = jsonArray.getJSONObject(index);
BusinessResourceDO bizResDO = JSON.parseObject(JSON.toJSONString(jsonObject), BusinessResourceDO.class);

Class queryOptionClass = Class.forName(STREAM_OPTION_PACKAGE + feedStreamQueryOptionClassName);
queryOption = (MtopFeedStreamQueryOption) JSON.parseObject(JSON.toJSONString(configQueryParamsMap),queryOptionClass);

feedBackdto = JSON.parseObject(URLDecoder.decode(Submit,"utf-8"), new TypeReference<FeedBackDTO>()

map

for (Map.Entry<String,Object> entry : streamQueryParamsJO.entrySet()){
    streamQueryParamsMap.put(entry.getKey(),String.valueOf(entry.getValue()));
}

configQueryParamsMap.putAll(urlQueryParamsMap);

org.apache.commons.lang3.EnumUtils

String time = "H1";
TimeUnit timeUnit = EnumUtils.getEnum(TimeUnit.class, time);

org.apache.commons.collections.MapUtils

org.apache.commons.lang3.BooleanUtils


如果文章对您有帮助,欢迎扫描下方二维码赞助(一分也是爱噢),谢谢

Search

    一分也是爱噢 一分也是爱

    目录