Where's the javadoc for values and valueOf methods on enums?!
The static values()
and valueOf(String name)
methods available on all enum types do not have ordinary javadocs. As opposed to for instance name()
which is declared on the Enum
class, the values()
and valueOf(String name)
methods are "magically" added by the Java compiler. In other words, these methods are not found in any .java
file and therefore there's no place to put the javadoc!
This is described in JLS which in fact also includes the "hidden" javadoc:
In addition, if
E
is the name of an enum type, then that type has the following implicitly declaredstatic
methods:/** * Returns an array containing the constants of this enum * type, in the order they're declared. This method may be * used to iterate over the constants as follows: * * for(E c : E.values()) * System.out.println(c); * * @return an array containing the constants of this enum * type, in the order they're declared */ public static E[] values(); /** * Returns the enum constant of this type with the specified * name. * The string must match exactly an identifier used to declare * an enum constant in this type. (Extraneous whitespace * characters are not permitted.) * * @return the enum constant with the specified name * @throws IllegalArgumentException if this enum type has no * constant with the specified name */ public static E valueOf(String name);
Comments
Be the first to comment!