From e470a3fded79bbff482437a3f76671c16071d33f Mon Sep 17 00:00:00 2001 From: MrNavaStar Date: Wed, 4 Sep 2024 22:10:43 -0600 Subject: [PATCH] remove the need to pass class through to `.of()` --- src/main/java/me/mrnavastar/r/R.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/mrnavastar/r/R.java b/src/main/java/me/mrnavastar/r/R.java index a209ff2..1642e85 100644 --- a/src/main/java/me/mrnavastar/r/R.java +++ b/src/main/java/me/mrnavastar/r/R.java @@ -36,8 +36,12 @@ public static R of(Class clazz) { /** * Create an instance of {@link R} from a field in another {@link R} instance */ - public R of(String name, Class type) { - return R.of(get(name, type)); + public R of(String name) { + try { + return R.of(findField(name, clazz).get(instance)); + } catch (IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } } // Search super classes for field