Skip to content

Commit

Permalink
remove the need to pass class through to .of()
Browse files Browse the repository at this point in the history
  • Loading branch information
MrNavaStar committed Sep 5, 2024
1 parent 7992d6b commit e470a3f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/me/mrnavastar/r/R.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e470a3f

Please sign in to comment.