diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Reflections.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Reflections.java index 1a485e1..25f1be6 100644 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Reflections.java +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Reflections.java @@ -58,7 +58,19 @@ public final class Reflections { } /** - * TODO + * Return the parametized type used with a concrete implementation of + * a class that accepts generics. + * + * Ex: If you declare + *

+	 * public class SpecializedCollection implements Collection {
+	 *   // ...
+	 * }
+	 * 
+ * + * then the code getGenericTypeArgument(SpecializedCollection.class , 0); will + * return the type SpecializedType. + * */ @SuppressWarnings("unchecked") public static Class getGenericTypeArgument(final Class clazz, final int idx) { @@ -75,13 +87,24 @@ public final class Reflections { } /** - * TODO + *

Return the parametized type passed to field types that accepts Generics.

+ * + *

Ex: If you declare + *


+	 * public class MyClass{
+	 *    private Collection<String> myStringCollection;
+	 * }
+	 * 
+ * + * then the code getGenericTypeArgument( MyClass.class.getDeclaredField("myStringCollection") , 0); will + * return the type String. + * */ @SuppressWarnings("unchecked") public static Class getGenericTypeArgument(final Field field, final int idx) { final Type type = field.getGenericType(); final ParameterizedType paramType = (ParameterizedType) type; - + return (Class) paramType.getActualTypeArguments()[idx]; } -- libgit2 0.21.2