Commit 466843a6d2257bf7c1adf1f69c4268e0c151662f
1 parent
8c6d09fc
Exists in
master
Adicionados comentários a alguns métodos.
Showing
1 changed file
with
26 additions
and
3 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Reflections.java
... | ... | @@ -58,7 +58,19 @@ public final class Reflections { |
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | - * TODO | |
61 | + * Return the parametized type used with a concrete implementation of | |
62 | + * a class that accepts generics. | |
63 | + * | |
64 | + * Ex: If you declare | |
65 | + * <pre><code> | |
66 | + * public class SpecializedCollection implements Collection<SpecializedType> { | |
67 | + * // ... | |
68 | + * } | |
69 | + * </code></pre> | |
70 | + * | |
71 | + * then the code <code>getGenericTypeArgument(SpecializedCollection.class , 0);</code> will | |
72 | + * return the type <code>SpecializedType</code>. | |
73 | + * | |
62 | 74 | */ |
63 | 75 | @SuppressWarnings("unchecked") |
64 | 76 | public static <T> Class<T> getGenericTypeArgument(final Class<?> clazz, final int idx) { |
... | ... | @@ -75,13 +87,24 @@ public final class Reflections { |
75 | 87 | } |
76 | 88 | |
77 | 89 | /** |
78 | - * TODO | |
90 | + * <p>Return the parametized type passed to field types that accepts Generics.</p> | |
91 | + * | |
92 | + * <p>Ex: If you declare | |
93 | + * <pre><code> | |
94 | + * public class MyClass{ | |
95 | + * private Collection<String> myStringCollection; | |
96 | + * } | |
97 | + * </code></pre> | |
98 | + * | |
99 | + * then the code <code>getGenericTypeArgument( MyClass.class.getDeclaredField("myStringCollection") , 0);</code> will | |
100 | + * return the type <code>String</code>. | |
101 | + * | |
79 | 102 | */ |
80 | 103 | @SuppressWarnings("unchecked") |
81 | 104 | public static <T> Class<T> getGenericTypeArgument(final Field field, final int idx) { |
82 | 105 | final Type type = field.getGenericType(); |
83 | 106 | final ParameterizedType paramType = (ParameterizedType) type; |
84 | - | |
107 | + | |
85 | 108 | return (Class<T>) paramType.getActualTypeArguments()[idx]; |
86 | 109 | } |
87 | 110 | ... | ... |