Skip to content

Commit

Permalink
calling .generics() on an enum will now return an empty array
Browse files Browse the repository at this point in the history
  • Loading branch information
MrNavaStar committed Aug 24, 2024
1 parent 35c90b5 commit 994e977
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/me/mrnavastar/r/R.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ public R call(String name, Object... args) {
* Get a list of the generic type params of a class
*/
public Class<?>[] generics() {
if (clazz.isEnum()) return new Class[]{}; // Enums cant have generics

Type generic = clazz.getGenericSuperclass();
if (generic instanceof ParameterizedType) {
return Arrays.stream(((ParameterizedType) generic).getActualTypeArguments()).map(t -> {
Expand Down

0 comments on commit 994e977

Please sign in to comment.