MCPcopy Create free account
hub / github.com/PCGen/pcgen / findField

Method findField

code/src/test/pcgen/util/TestHelper.java:191–220  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 15

testConstructor001Method · 0.95
testConstructor002Method · 0.95
testConstructor003Method · 0.95
testConstructor004Method · 0.95
testConstructor005Method · 0.95
testConstructor006Method · 0.95
testConstructor007Method · 0.95
testConstructor008Method · 0.95
testConstructor009Method · 0.95
testConstructor010Method · 0.95
testConstructor011Method · 0.95
testConstructor012Method · 0.95

Calls 3

equalsMethod · 0.65
getNameMethod · 0.65
logMethod · 0.45

Tested by

no test coverage detected