Package java.util

Examples of java.util.EnumMap.keySet()


    @SuppressWarnings( { "unchecked", "boxing" })
    public void test_keySet() {
        EnumMap enumSizeMap = new EnumMap(Size.class);
        enumSizeMap.put(Size.Middle, 2);
        enumSizeMap.put(Size.Big, null);
        Set set = enumSizeMap.keySet();

        Set set1 = enumSizeMap.keySet();
        assertSame("Should be same", set1, set); //$NON-NLS-1$
        try {
            set.add(Size.Big);
View Full Code Here


        EnumMap enumSizeMap = new EnumMap(Size.class);
        enumSizeMap.put(Size.Middle, 2);
        enumSizeMap.put(Size.Big, null);
        Set set = enumSizeMap.keySet();

        Set set1 = enumSizeMap.keySet();
        assertSame("Should be same", set1, set); //$NON-NLS-1$
        try {
            set.add(Size.Big);
            fail("Should throw UnsupportedOperationException"); //$NON-NLS-1$
        } catch (UnsupportedOperationException e) {
View Full Code Here

        assertEquals("Wrong size", 0, set.size()); //$NON-NLS-1$

        enumSizeMap = new EnumMap(Size.class);
        enumSizeMap.put(Size.Middle, 1);
        enumSizeMap.put(Size.Big, null);
        set = enumSizeMap.keySet();
        Collection c = new ArrayList();
        c.add(Size.Big);
        assertTrue("Should return true", set.containsAll(c)); //$NON-NLS-1$
        c.add(Size.Small);
        assertFalse("Should return false", set.containsAll(c)); //$NON-NLS-1$
View Full Code Here

        assertEquals("Wrong key", Size.Big, array[0]); //$NON-NLS-1$

        enumSizeMap = new EnumMap(Size.class);
        enumSizeMap.put(Size.Middle, 1);
        enumSizeMap.put(Size.Big, null);
        set = enumSizeMap.keySet();
        c = new ArrayList();
        c.add(Color.Blue);
        assertFalse("Should return false", set.remove(c)); //$NON-NLS-1$
        assertEquals("Wrong size", 2, set.size()); //$NON-NLS-1$
        assertTrue("Should return true", set.retainAll(c)); //$NON-NLS-1$
View Full Code Here

        assertEquals("Wrong size", 0, set.size()); //$NON-NLS-1$

        enumSizeMap = new EnumMap(Size.class);
        enumSizeMap.put(Size.Middle, 1);
        enumSizeMap.put(Size.Big, null);
        set = enumSizeMap.keySet();

        Iterator iter = set.iterator();
        Enum enumKey = (Enum) iter.next();
        assertTrue("Returned false for contained object", set.contains(enumKey)); //$NON-NLS-1$
        enumKey = (Enum) iter.next();
View Full Code Here

        assertTrue("Returned false for contained object", set.contains(enumKey)); //$NON-NLS-1$

        enumSizeMap = new EnumMap(Size.class);
        enumSizeMap.put(Size.Middle, 1);
        enumSizeMap.put(Size.Big, null);
        set = enumSizeMap.keySet();
        iter = set.iterator();
        try {
            iter.remove();
            fail("Should throw IllegalStateException"); //$NON-NLS-1$
        } catch (IllegalStateException e) {
View Full Code Here

    @SuppressWarnings( { "unchecked", "boxing" })
    public void test_keySet() {
        EnumMap enumSizeMap = new EnumMap(Size.class);
        enumSizeMap.put(Size.Middle, 2);
        enumSizeMap.put(Size.Big, null);
        Set set = enumSizeMap.keySet();

        Set set1 = enumSizeMap.keySet();
        assertSame("Should be same", set1, set); //$NON-NLS-1$
        try {
            set.add(Size.Big);
View Full Code Here

        EnumMap enumSizeMap = new EnumMap(Size.class);
        enumSizeMap.put(Size.Middle, 2);
        enumSizeMap.put(Size.Big, null);
        Set set = enumSizeMap.keySet();

        Set set1 = enumSizeMap.keySet();
        assertSame("Should be same", set1, set); //$NON-NLS-1$
        try {
            set.add(Size.Big);
            fail("Should throw UnsupportedOperationException"); //$NON-NLS-1$
        } catch (UnsupportedOperationException e) {
View Full Code Here

        assertEquals("Wrong size", 0, set.size()); //$NON-NLS-1$

        enumSizeMap = new EnumMap(Size.class);
        enumSizeMap.put(Size.Middle, 1);
        enumSizeMap.put(Size.Big, null);
        set = enumSizeMap.keySet();
        Collection c = new ArrayList();
        c.add(Size.Big);
        assertTrue("Should return true", set.containsAll(c)); //$NON-NLS-1$
        c.add(Size.Small);
        assertFalse("Should return false", set.containsAll(c)); //$NON-NLS-1$
View Full Code Here

        assertEquals("Wrong key", Size.Big, array[0]); //$NON-NLS-1$

        enumSizeMap = new EnumMap(Size.class);
        enumSizeMap.put(Size.Middle, 1);
        enumSizeMap.put(Size.Big, null);
        set = enumSizeMap.keySet();
        c = new ArrayList();
        c.add(Color.Blue);
        assertFalse("Should return false", set.remove(c)); //$NON-NLS-1$
        assertEquals("Wrong size", 2, set.size()); //$NON-NLS-1$
        assertTrue("Should return true", set.retainAll(c)); //$NON-NLS-1$
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.