# XReflect **Repository Path**: XShawnNotes/XReflect ## Basic Information - **Project Name**: XReflect - **Description**: Java反射工具 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2022-11-08 - **Last Updated**: 2023-06-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 1. 支持链式调用,支持get field时自动转型 2. 使用方法 ```java public static void test(Context context) { try { // 1. 访问静态方法 String value = XClass.wrap(SystemProperties.class) .method("get", String.class) .invoke(""); // 2. 访问非静态方法 int userId = XClass.wrap(context.getClass()) .object(context) .method("getUserId") .invoke(); // 3. 访问静态属性 HashMap sRoReads = XClass.wrap(SystemProperties.class) .field("sRoReads") .get(); // 4. 访问非静态属性 XClass.wrap(ApplicationInfo.class) .object(context.getApplicationInfo()) .field("processName") .set(context.getPackageName()); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); } } ``` # 博文公号 | 微信公号 | 语雀 | | :----------------------------------------------------------: | :----------------------------------------------------------: | | ![灰灰手记](https://cdn.nlark.com/yuque/0/2020/jpeg/2551395/1606377302887-060f9139-fbc6-4f03-9d81-3f806e1c2342.jpeg) | [灰灰手记](https://www.yuque.com/xshawn)
![邀请码](https://cdn.nlark.com/yuque/0/2020/png/2551395/1606377146823-0df87a9c-504f-4992-8e29-70656ade9a62.png) |