You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2014/11/20 04:21:18 UTC
svn commit: r1640656 -
/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
Author: desruisseaux
Date: Thu Nov 20 03:21:17 2014
New Revision: 1640656
URL: http://svn.apache.org/r1640656
Log:
Allow Types.getCodeValues(Class) to work with Enum in addition to CodeList.
Modified:
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java?rev=1640656&r1=1640655&r2=1640656&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8] Thu Nov 20 03:21:17 2014
@@ -432,16 +432,22 @@ public final class Types extends Static
}
/**
- * Returns all known values for the given type of code list.
+ * Returns all known values for the given type of code list or enumeration.
* Note that the size of the returned array may growth between different invocations of this method,
* since users can add their own codes to an existing list.
*
+ * {@note This method works with both <code>Enum</code> and <code>CodeList</code>. However if the type
+ * is known to be an <code>Enum</code>, then the standard <code>Class.getEnumConstants()</code>
+ * method is more efficient.}
+ *
* @param <T> The compile-time type given as the {@code codeType} parameter.
- * @param codeType The type of code list.
- * @return The list of values for the given code list, or an empty array if none.
+ * @param codeType The type of code list or enumeration.
+ * @return The list of values for the given code list or enumeration, or an empty array if none.
+ *
+ * @see Class#getEnumConstants()
*/
@SuppressWarnings("unchecked")
- public static <T extends CodeList<?>> T[] getCodeValues(final Class<T> codeType) {
+ public static <T extends Enumerated> T[] getCodeValues(final Class<T> codeType) {
Object values;
try {
values = codeType.getMethod("values", (Class<?>[]) null).invoke(null, (Object[]) null);