sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1640656 - /sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
Date Thu, 20 Nov 2014 03:21:18 GMT
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);



Mime
View raw message