2
Base Utils
Calvin Xiao edited this page 2017-01-25 10:04:35 +08:00
This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

防御式编程工具集

Spring Common Lang Guava都有提供校验参数的防御式编程API选用Apache Commons Lang的Validate。

Spring的Assert很容易和junit的Assert弄乱而且校验函数没有返回输入参数的能力而且出错信息也没有格式化字符串+自定义参数的能力。

Guava的Preconditions一是名字太长了二是Validate的方法更多比如noNullElements()判断多个元素都不为空

MoreValidate主要参考Guava的MathPreconditions, 补充数字为正数或非负数的校验。

异常工具集

Springside-core自己感觉常用需求整理了Exceptions。

  • unchecked(), 将CheckedException转化为RuntimeException的方法
  • getStackTraceAsString(), 将整个Exception Stack所有消息转化为一个String
  • isCausedBy(), 判断异常是否由某些底层异常引起

系统设定工具集

Properties与SystemProperties工具集

OjbectBoolean 与 枚举工具集

自定义Annotations