001    /*
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.commons.collections;
018    
019    import java.util.Enumeration;
020    import java.util.List;
021    
022    import org.apache.commons.collections.iterators.EnumerationIterator;
023    
024    /**
025     * Provides utility methods for {@link Enumeration} instances.
026     * 
027     * @since Commons Collections 3.0
028     * @version $Id: EnumerationUtils.java 646777 2008-04-10 12:33:15Z niallp $
029     * 
030     * @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
031     */
032    public class EnumerationUtils {
033    
034        /**
035         * EnumerationUtils is not normally instantiated.
036         */
037        public EnumerationUtils() {
038            // no init.
039        }
040        
041        /**
042         * Creates a list based on an enumeration.
043         * 
044         * <p>As the enumeration is traversed, an ArrayList of its values is
045         * created. The new list is returned.</p>
046         *
047         * @param enumeration  the enumeration to traverse, which should not be <code>null</code>.
048         * @throws NullPointerException if the enumeration parameter is <code>null</code>.
049         */
050        public static List toList(Enumeration enumeration) {
051            return IteratorUtils.toList(new EnumerationIterator(enumeration));
052        }
053    
054    }