Skip to content

Commit

Permalink
Updated VarArgsHelper for mutations.
Browse files Browse the repository at this point in the history
  • Loading branch information
knighto82 committed Jan 13, 2025
1 parent b4c4963 commit 1d9729d
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@ public static Map<String, Object> initializeMap() {
}

public static Set<String> getFieldNames(Class<?> resourceClass) {
if (null == resourceClass) return new HashSet<>();
if (resourceClass == null) {
// Explicitly return an empty set to handle null input
return Collections.emptySet();
}

// Stream the fields, map names, and filter out synthetic fields like "this$0"
return Arrays.stream(resourceClass.getDeclaredFields())
.map(Field::getName)
.filter(n -> !"this$0".equals(n))
.collect(Collectors.toSet());
.filter(name -> name != null && !name.equals("this$0")) // Null safety and exclude "this$0"
.collect(Collectors.toCollection(LinkedHashSet::new)); // Use LinkedHashSet for deterministic order
}
}

0 comments on commit 1d9729d

Please sign in to comment.