Skip to content

Commit 732f490

Browse files
committed
Types: add javadoc for field method
1 parent 213aa20 commit 732f490

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/main/java/org/scijava/util/Types.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff 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 {

0 commit comments

Comments
 (0)