Skip to content

Commit

Permalink
Update to getGenericTypeOfReturnType
Browse files Browse the repository at this point in the history
To be able to get the generic type of the List for methods such as:
<T extends Interface1> List<T> getList();
For complicated and very rare cases such as: <T extends Interface1, Interface2,Interface3> List<T> getList();
it would just return the first interface Interface1 and not the other two.
  • Loading branch information
Elisedlund-ericsson committed Apr 5, 2023
1 parent 6273567 commit ccf57f5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/ericsson/commonlibrary/proxy/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ private static Class<?> getGenericTypeOfReturnType(Method method, Type type) {
return (Class<?>) wildType.getUpperBounds()[0];
} else if (type instanceof ParameterizedType) {
return ((Class) ((ParameterizedType) type).getRawType());
} else if (type instanceof TypeVariable) {
return (Class) ((TypeVariable) type).getBounds()[0]; //ignore the others, (typically only one anyway)
}
throw new IllegalArgumentException(
"Was not able to figure out the generic type of method: " + method.getName());
Expand Down

0 comments on commit ccf57f5

Please sign in to comment.