This is an automated email from the ASF dual-hosted git repository.
sjaranowski pushed a commit to branch maven-plugin-testing-3.x
in repository https://gitbox.apache.org/repos/asf/maven-plugin-testing.git
The following commit(s) were added to refs/heads/maven-plugin-testing-3.x by
this push:
new 77f1161 Use generics for returned type of getVariableValueFromObject
77f1161 is described below
commit 77f1161a18c38b80e1e7e0bdec50bafc232628b3
Author: Slawomir Jaranowski <[email protected]>
AuthorDate: Sun Dec 28 15:39:37 2025 +0100
Use generics for returned type of getVariableValueFromObject
---
.../main/java/org/apache/maven/api/plugin/testing/MojoExtension.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git
a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoExtension.java
b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoExtension.java
index 3461e39..6aa59ff 100644
---
a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoExtension.java
+++
b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoExtension.java
@@ -499,10 +499,11 @@ public class MojoExtension extends PlexusExtension
implements ParameterResolver
* <br>
* Note: the caller is responsible for casting to what the desired type is.
*/
- public static Object getVariableValueFromObject(Object object, String
variable) throws IllegalAccessException {
+ @SuppressWarnings("unchecked")
+ public static <T> T getVariableValueFromObject(Object object, String
variable) throws IllegalAccessException {
Field field =
ReflectionUtils.getFieldByNameIncludingSuperclasses(variable,
object.getClass());
field.setAccessible(true);
- return field.get(object);
+ return (T) field.get(object);
}
/**