Common 常用模块

Date 日期处理

Reflection 反射

Input/Output 输入/输出

HTTP 请求

加密/解密

其他

Fields

Fields 提供字段层次查找和反射包装异常解包功能。

getSuperClassDeclaredFields(Class<?>) 返回输入类及其父类声明的字段,包括 private 字段,但不包含 Object 声明的字段。

findField(Class<?>, String) 沿相同层次查找并返回第一个匹配的 Field;找不到时返回 null。 找到非 public 字段并不会自动使其可访问。

Field field = Fields.findField(MyClass.class, "name");
if (field != null && !field.isAccessible())
    field.setAccessible(true);

getUnderLayerErr(Throwable) 解开嵌套的 InvocationTargetExceptionUndeclaredThrowableException。包装异常没有 cause 时原样返回;输入为 null 时抛出 IllegalArgumentException

getUnderLayerErrMsg(Throwable) 直接返回底层异常的 detail message。异常没有详细消息时返回空字符串, 不会把异常类名误当作消息文本。