Java Reflection Enum getEnumConstants(Class c)

Here you can find the source of getEnumConstants(Class c)

Description

Returns all Enum Constants in an Enum

License

Open Source License

Parameter

Parameter Description
c The Enum you are targeting

Return

An ArrayList of all Enum Constants in that Enum

Declaration

public static List<?> getEnumConstants(Class<?> c) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Arrays;

import java.util.List;

public class Main {
    /**//from www .j a  v a 2 s.c  om
     * Returns all Enum Constants in an Enum
     *
     * @param  c The Enum you are targeting
     * @return      An ArrayList of all Enum Constants in that Enum
     */
    public static List<?> getEnumConstants(Class<?> c) {
        return Arrays.asList(c.getEnumConstants());
    }
}

Related

  1. getEnumNames(Class> e)
  2. getEnumValues(Class type)
  3. getOptionsFromEnum(Class> enumClass)
  4. isLegalEnum(Class clazz, Object enuValue)