Java Collection Element Get getEnumNames( Collection values)

Here you can find the source of getEnumNames( Collection values)

Description

Extracts the names of the given enum elements and returns them as string.

License

Open Source License

Parameter

Parameter Description
values the enum values

Return

the names of the given enum elements

Declaration

public static List<String> getEnumNames(
        Collection<? extends Enum> values) 

Method Source Code

//package com.java2s;
/***************************************************************
 *  This file is part of the [fleXive](R) framework.
 *
 *  Copyright (c) 1999-2014/* w w  w.ja  v  a  2s .c om*/
 *  UCS - unique computing solutions gmbh (http://www.ucs.at)
 *  All rights reserved
 *
 *  The [fleXive](R) project is free software; you can redistribute
 *  it and/or modify it under the terms of the GNU Lesser General Public
 *  License version 2.1 or higher as published by the Free Software Foundation.
 *
 *  The GNU Lesser General Public License can be found at
 *  http://www.gnu.org/licenses/lgpl.html.
 *  A copy is found in the textfile LGPL.txt and important notices to the
 *  license from the author are found in LICENSE.txt distributed with
 *  these libraries.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  For further information about UCS - unique computing solutions gmbh,
 *  please see the company website: http://www.ucs.at
 *
 *  For further information about [fleXive](R), please see the
 *  project website: http://www.flexive.org
 *
 *
 *  This copyright notice MUST APPEAR in all copies of the file!
 ***************************************************************/

import java.util.*;

public class Main {
    /**
     * Extracts the names of the given enum elements and returns them as string.
     * Useful if the toString() method of the Enum class was overwritten.
     *
     * @param values the enum values
     * @return the names of the given enum elements
     */
    public static List<String> getEnumNames(
            Collection<? extends Enum> values) {
        final List<String> result = new ArrayList<String>(values.size());
        for (final Enum value : values) {
            result.add(value.name());
        }
        return result;
    }
}

Related

  1. getDocIdString(Collection docIds)
  2. getElement(final int index, final Collection coll)
  3. getElementClass(Collection collection)
  4. getElementFromSize1(Collection collection)
  5. getEntropy(Collection values)
  6. getFlatString(Collection elements)
  7. getGivenClassObject(Collection coll, Class clazz)
  8. getHighest(final Collection elements, final Comparator c)
  9. getImplement(Class aClass, Collection> classCollection)