File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
src/main/java/org/scijava/util Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -404,6 +404,30 @@ public static <T> T nullValue(final Class<T> type) {
404404 return result ;
405405 }
406406
407+ /**
408+ * Gets the field with the specified name, of the given class, or superclass
409+ * thereof.
410+ * <p>
411+ * Unlike {@link Class#getField(String)}, this method will return fields of
412+ * any visibility, not just {@code public}. And unlike
413+ * {@link Class#getDeclaredField(String)}, it will do so recursively,
414+ * returning the first field of the given name from the class's superclass
415+ * hierarchy.
416+ * </p>
417+ * <p>
418+ * Note that this method does not guarantee that the returned field is
419+ * accessible; if the field is not {@code public}, calling code will need to
420+ * use {@link Field#setAccessible(boolean)} in order to manipulate the field's
421+ * contents.
422+ * </p>
423+ *
424+ * @param c The class (or subclass thereof) containing the desired field.
425+ * @param name
426+ * @return The first field with the given name in the class's superclass
427+ * hierarchy.
428+ * @throws IllegalArgumentException if the specified class does not contain a
429+ * method with the given name
430+ */
407431 public static Field field (final Class <?> c , final String name ) {
408432 if (c == null ) throw new IllegalArgumentException ("No such field: " + name );
409433 try {
You can’t perform that action at this time.
0 commit comments