001    /*******************************************************************************
002     * Portions created by Sebastian Thomschke are copyright (c) 2005-2011 Sebastian
003     * Thomschke.
004     * 
005     * All Rights Reserved. This program and the accompanying materials
006     * are made available under the terms of the Eclipse Public License v1.0
007     * which accompanies this distribution, and is available at
008     * http://www.eclipse.org/legal/epl-v10.html
009     * 
010     * Contributors:
011     *     Sebastian Thomschke - initial implementation.
012     *******************************************************************************/
013    package net.sf.oval.collection;
014    
015    import java.util.ArrayList;
016    import java.util.LinkedHashMap;
017    import java.util.LinkedHashSet;
018    import java.util.List;
019    import java.util.Map;
020    import java.util.Set;
021    
022    /**
023     * @author Sebastian Thomschke
024     */
025    public class CollectionFactoryJDKImpl implements CollectionFactory
026    {
027            /**
028             * {@inheritDoc}
029             */
030            public <ValueType> List<ValueType> createList()
031            {
032                    return new ArrayList<ValueType>();
033            }
034    
035            /**
036             * {@inheritDoc}
037             */
038            public <ValueType> List<ValueType> createList(final int initialCapacity)
039            {
040                    return new ArrayList<ValueType>(initialCapacity);
041            }
042    
043            /**
044             * {@inheritDoc}
045             */
046            public <KeyType, ValueType> Map<KeyType, ValueType> createMap()
047            {
048                    return new LinkedHashMap<KeyType, ValueType>();
049            }
050    
051            /**
052             * {@inheritDoc}
053             */
054            public <KeyType, ValueType> Map<KeyType, ValueType> createMap(final int initialCapacity)
055            {
056                    return new LinkedHashMap<KeyType, ValueType>(initialCapacity);
057            }
058    
059            /**
060             * {@inheritDoc}
061             */
062            public <ValueType> Set<ValueType> createSet()
063            {
064                    return new LinkedHashSet<ValueType>();
065            }
066    
067            /**
068             * {@inheritDoc}
069             */
070            public <ValueType> Set<ValueType> createSet(final int initialCapacity)
071            {
072                    return new LinkedHashSet<ValueType>(initialCapacity);
073            }
074    }