Skip to content

Commit

Permalink
Uses RecordsHelper where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
jqno committed Dec 2, 2022
1 parent 281c99d commit 6a6716f
Showing 1 changed file with 1 addition and 9 deletions.
Expand Up @@ -44,20 +44,12 @@ public static <T> ObjectAccessor<T> of(T object) {
* @return An {@link ObjectAccessor} for {@link #object}.
*/
public static <T> ObjectAccessor<T> of(T object, Class<T> type) {
if (isRecord(type)) {
if (RecordsHelper.isRecord(type)) {
return new RecordObjectAccessor<T>(object, type);
}
return new InPlaceObjectAccessor<>(object, type);
}

private static boolean isRecord(Class<?> type) {
Class<?> record = Util.classForName("java.lang.Record");
if (record == null) {
return false;
}
return record.isAssignableFrom(type);
}

/**
* Returns the wrapped object.
*
Expand Down

0 comments on commit 6a6716f

Please sign in to comment.