Class RestrictedCollections


  • public class RestrictedCollections
    extends Base
    A collection of Collection implementation classes that limit the data type.
    Author:
    cp 2001.10.09
    • Method Detail

      • getCollection

        public static Collection getCollection​(Collection col,
                                               Class clz)
        Returns a restricted instance of Collection.
        Parameters:
        col - the underlying Collection
        clz - the class of objects that may be stored in the Collection
        Returns:
        a restricted Collection that requires its contents to be of the specified class
      • getSet

        public static Set getSet​(Set set,
                                 Class clz)
        Returns a restricted instance of Set.
        Parameters:
        set - the underlying Set
        clz - the class of objects that may be stored in the Set
        Returns:
        a restricted Set that requires its contents to be of the specified class
      • getSortedSet

        public static SortedSet getSortedSet​(SortedSet set,
                                             Class clz)
        Returns a restricted instance of SortedSet.
        Parameters:
        set - the underlying SortedSet
        clz - the class of objects that may be stored in the SortedSet
        Returns:
        a restricted SortedSet that requires its contents to be of the specified class
      • getList

        public static List getList​(List list,
                                   Class clz)
        Returns a restricted instance of List.
        Parameters:
        list - the underlying List
        clz - the class of objects that may be stored in the List
        Returns:
        a restricted List that requires its contents to be of the specified class
      • getListIterator

        public static ListIterator getListIterator​(ListIterator iter,
                                                   Class clz)
        Returns a restricted instance of ListIterator.
        Parameters:
        iter - the underlying ListIterator
        clz - the class of objects that may be stored in the List
        Returns:
        a restricted ListIterator that requires its contents to be of the specified class
      • getMap

        public static Map getMap​(Map map,
                                 Class clzKey,
                                 Class clzVal)
        Returns a restricted instance of Map.
        Parameters:
        map - the underlying Map
        clzKey - the class of keys that may be stored in the Map
        clzVal - the class of values that may be stored in the Map
        Returns:
        a restricted Map that requires its keys and values to be of the specified classes
      • getSortedMap

        public static SortedMap getSortedMap​(SortedMap map,
                                             Class clzKey,
                                             Class clzVal)
        Returns a restricted instance of SortedMap.
        Parameters:
        map - the underlying SortedMap
        clzKey - the class of keys that may be stored in the SortedMap
        clzVal - the class of values that may be stored in the SortedMap
        Returns:
        a restricted SortedMap that requires its keys and values to be of the specified classes
      • getEntrySet

        public static Set getEntrySet​(Set set,
                                      Class clzKey,
                                      Class clzVal)
        Returns a restricted instance of Set that holds Entry objects for a RestrictedMap.
        Parameters:
        set - the underlying Entry Set
        clzKey - the class of keys that may be stored in the Map
        clzVal - the class of values that may be stored in the Map
        Returns:
        a restricted Set that requires its contents to be Entry objects with the specified key and value restrictions