Get the field related to a name @param aClass The class to search for the field @param fieldName the field to search for @return the field related to a name in the class
(final Class<?> aClass, final String fieldName)
| 189 | * @return the field related to a name in the class |
| 190 | */ |
| 191 | public static Object findField(final Class<?> aClass, final String fieldName) |
| 192 | { |
| 193 | try |
| 194 | { |
| 195 | Class<?> clazz = aClass; |
| 196 | while (true) |
| 197 | { |
| 198 | for (final Field f : clazz.getDeclaredFields()) |
| 199 | { |
| 200 | if (f.getName().equals(fieldName)) |
| 201 | { |
| 202 | f.setAccessible(true); |
| 203 | return f; |
| 204 | } |
| 205 | } |
| 206 | if (!"Object".equals(clazz.getName())) |
| 207 | { |
| 208 | clazz = clazz.getSuperclass(); |
| 209 | } else |
| 210 | { |
| 211 | break; |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | } catch (SecurityException e) |
| 216 | { |
| 217 | LOG.log(Level.SEVERE, "SecurityException is thrown in findField", e); |
| 218 | } |
| 219 | return null; |
| 220 | } |
| 221 | |
| 222 | /** |
| 223 | * Set the important info about a Skill |
no test coverage detected