注释-枚举类型
/*** 发起付款申请的表名称,利息收付/本金收付/提前终止表* {@link com.luoma.finance.enums.TableTypeEnum}**/@NotBlank(message = "发起付款申请的表名称不能为空")private String payType;
注释-代码块
//#region//#endregion
StringJoiner
StringJoiner sj = new StringJoiner(",");sj.add("1");sj.add("2");//1,2System.out.println(sj.toString());
Lists.partition 自动分页
List<String> list = new ArrayList<>();for (int i = 0; i < 100; i++) {list.add(String.valueOf(i));}List<List<String>> listPages = Lists.partition(list,10);listPages.forEach(System.out::println);
输出
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9][10, 11, 12, 13, 14, 15, 16, 17, 18, 19][20, 21, 22, 23, 24, 25, 26, 27, 28, 29][30, 31, 32, 33, 34, 35, 36, 37, 38, 39][40, 41, 42, 43, 44, 45, 46, 47, 48, 49][50, 51, 52, 53, 54, 55, 56, 57, 58, 59][60, 61, 62, 63, 64, 65, 66, 67, 68, 69][70, 71, 72, 73, 74, 75, 76, 77, 78, 79][80, 81, 82, 83, 84, 85, 86, 87, 88, 89][90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
StopWatch 计时
StopWatch stopWatch = new StopWatch();stopWatch.start("test1");TimeUnit.SECONDS.sleep(1);stopWatch.stop();stopWatch.start("test2");TimeUnit.SECONDS.sleep(1);stopWatch.stop();System.out.println(stopWatch.prettyPrint());
输出
StopWatch '': 2.0131498 seconds----------------------------------------Seconds % Task name----------------------------------------1.0103674 50% test11.0027824 50% test2
StopWatch 记录耗时日志案例
import org.springframework.util.StopWatch;/*** 出队操作** @param msg 出队数据* @return 出队结果*/@Transactional(rollbackFor = Exception.class)@Overridepublic boolean consumer(Object msg) {boolean result;StopWatch queueTime = new StopWatch();queueTime.start();long getKVListTime = 0L,checkKVListTime = 0L;String traceId = UUID.randomUUID().toString().replace("-", "");try {StopWatch stopWatch = new StopWatch();stopWatch.start();//业务逻辑stopWatch.stop();getKVListTime = stopWatch.getLastTaskTimeMillis();stopWatch.start();//业务逻辑stopWatch.stop();checkKVListTime = stopWatch.getLastTaskTimeMillis();} catch (Exception e) {log.error("traceId:[{}],{}结束调用,返回结果:{},e:{}", traceId, methodName, false, ExceptionUtil.getErrorMessage(e));result = false;}queueTime.stop();DecimalFormat decimalFormat = new DecimalFormat("##.##%");log.info("traceId:[{}],获取KV集合数据,总耗时:[{}]ms,占比:[{}]", traceId, getKVListTime,decimalFormat.format((float) getKVListTime / (float) queueTime.getTotalTimeMillis()));log.info("traceId:[{}],KV数据校验去重,总耗时:[{}]ms,占比:[{}]", traceId, checkKVListTime,decimalFormat.format((float) checkKVListTime / (float) queueTime.getTotalTimeMillis()));log.info("traceId:[{}],保存发放平台支付数据队列,总耗时:[{}]ms", traceId, queueTime.getTotalTimeMillis());return true;}
原子类-AtomicReference 使用场景
ConcurrentMap
ConcurrentMap,它是一个接口,是一个能够支持并发访问的java.util.map集合;ConcurrentMap,是一个线程安全,并且是一个高效的HashMap。
private static ConcurrentMap<String, String> localMap = new ConcurrentHashMap();public static void main(String[] args) {localMap.put("testkey", "testValue");//testValueSystem.out.println(localMap.get("testkey"));}