Class ResourceSet<T>

  • Type Parameters:
    T - The type of elements in the Set
    All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<T>, java.util.Collection<T>, java.util.Set<T>

    public final class ResourceSet<T>
    extends java.util.HashSet<T>
    Extended implementation of HashSet that includes a locked property. This class can be used to safely expose resource path sets to user classes without having to clone them in order to avoid modifications. When first created, a ResourceSet is not locked.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      ResourceSet()
      Construct a new, empty set with the default initial capacity and load factor.
      ResourceSet​(int initialCapacity)
      Construct a new, empty set with the specified initial capacity and default load factor.
      ResourceSet​(int initialCapacity, float loadFactor)
      Construct a new, empty set with the specified initial capacity and load factor.
      ResourceSet​(java.util.Collection<T> coll)
      Construct a new set with the same contents as the existing collection.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(T o)
      boolean addAll​(java.util.Collection<? extends T> c)
      void clear()
      boolean isLocked()
      Return the locked state of this parameter map.
      java.util.Iterator<T> iterator()
      boolean remove​(java.lang.Object o)
      boolean removeAll​(java.util.Collection<?> c)
      boolean removeIf​(java.util.function.Predicate<? super T> filter)
      boolean retainAll​(java.util.Collection<?> c)
      void setLocked​(boolean locked)
      Set the locked state of this parameter map.
      • Methods inherited from class java.util.HashSet

        clone, contains, isEmpty, size, spliterator
      • Methods inherited from class java.util.AbstractSet

        equals, hashCode
      • Methods inherited from class java.util.AbstractCollection

        containsAll, toArray, toArray, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.Set

        containsAll, equals, hashCode, toArray, toArray
    • Constructor Detail

      • ResourceSet

        public ResourceSet()
        Construct a new, empty set with the default initial capacity and load factor.
      • ResourceSet

        public ResourceSet​(int initialCapacity)
        Construct a new, empty set with the specified initial capacity and default load factor.
        Parameters:
        initialCapacity - The initial capacity of this set
      • ResourceSet

        public ResourceSet​(int initialCapacity,
                           float loadFactor)
        Construct a new, empty set with the specified initial capacity and load factor.
        Parameters:
        initialCapacity - The initial capacity of this set
        loadFactor - The load factor of this set
      • ResourceSet

        public ResourceSet​(java.util.Collection<T> coll)
        Construct a new set with the same contents as the existing collection.
        Parameters:
        coll - The collection whose contents we should copy
    • Method Detail

      • isLocked

        public boolean isLocked()
        Return the locked state of this parameter map.
        Returns:
        the locked state of this parameter map
      • setLocked

        public void setLocked​(boolean locked)
        Set the locked state of this parameter map.
        Parameters:
        locked - The new locked state
      • add

        public boolean add​(T o)
        Specified by:
        add in interface java.util.Collection<T>
        Specified by:
        add in interface java.util.Set<T>
        Overrides:
        add in class java.util.HashSet<T>
        Throws:
        java.lang.IllegalStateException - if this set is currently locked
      • addAll

        public boolean addAll​(java.util.Collection<? extends T> c)
        Specified by:
        addAll in interface java.util.Collection<T>
        Specified by:
        addAll in interface java.util.Set<T>
        Overrides:
        addAll in class java.util.AbstractCollection<T>
        Throws:
        java.lang.IllegalStateException - if this set is currently locked
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<T>
        Specified by:
        clear in interface java.util.Set<T>
        Overrides:
        clear in class java.util.HashSet<T>
        Throws:
        java.lang.IllegalStateException - if this set is currently locked
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<T>
        Specified by:
        remove in interface java.util.Set<T>
        Overrides:
        remove in class java.util.HashSet<T>
        Throws:
        java.lang.IllegalStateException - if this set is currently locked
      • removeAll

        public boolean removeAll​(java.util.Collection<?> c)
        Specified by:
        removeAll in interface java.util.Collection<T>
        Specified by:
        removeAll in interface java.util.Set<T>
        Overrides:
        removeAll in class java.util.AbstractSet<T>
        Throws:
        java.lang.IllegalStateException - if this set is currently locked
      • retainAll

        public boolean retainAll​(java.util.Collection<?> c)
        Specified by:
        retainAll in interface java.util.Collection<T>
        Specified by:
        retainAll in interface java.util.Set<T>
        Overrides:
        retainAll in class java.util.AbstractCollection<T>
        Throws:
        java.lang.IllegalStateException - if this set is currently locked
      • removeIf

        public boolean removeIf​(java.util.function.Predicate<? super T> filter)
        Throws:
        java.lang.IllegalStateException - if this set is currently locked
      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.util.Collection<T>
        Specified by:
        iterator in interface java.lang.Iterable<T>
        Specified by:
        iterator in interface java.util.Set<T>
        Overrides:
        iterator in class java.util.HashSet<T>
        Throws:
        java.lang.IllegalStateException - if this set is currently locked