ResourceSet (Apache Tomcat 10.1.54 API Documentation)
Description: declaration: package: org.apache.catalina.util, class: ResourceSet

# Class ResourceSet<T>

java.lang.Object
java.util.AbstractCollection<T>
java.util.AbstractSet<T>
java.util.HashSet<T>
org.apache.catalina.util.ResourceSet<T>

Type Parameters:
  `T` - The type of elements in the Set

All Implemented Interfaces:
  `Serializable, Cloneable, Iterable<T>, Collection<T>, Set<T>`

public final class ResourceSet<T> extends 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 `ResourceMap` 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(Collection<T> coll)`
  Construct a new set with the same contents as the existing collection.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `add(T o)`
  `void`
  `clear()`
  `boolean`
  `isLocked()`
  `boolean`
  `remove(Object o)`
  `void`
  `setLocked(boolean locked)`
  Set the locked state of this parameter map.

  ### Methods inherited from class HashSet

  `clone, contains, isEmpty, iterator, newHashSet, size, spliterator, toArray, toArray`

  ### Methods inherited from class AbstractSet

  `equals, hashCode, removeAll`

  ### Methods inherited from class AbstractCollection

  `addAll, containsAll, retainAll, toString`

  ### Methods inherited from class Object

  `finalize, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface Collection

  `parallelStream, removeIf, stream, toArray`

  ### Methods inherited from interface Iterable

  `forEach`

  ### Methods inherited from interface Set

  `addAll, containsAll, equals, hashCode, removeAll, retainAll`

- ## Constructor Details

  - ### 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(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 Details

  - ### isLocked

    public boolean isLocked()
    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 `Collection<T>`
    Specified by:
      `add` in interface `Set<T>`
    Overrides:
      `add` in class `HashSet<T>`
    Throws:
      `IllegalStateException` - if this set is currently locked

  - ### clear

    public void clear()
    Specified by:
      `clear` in interface `Collection<T>`
    Specified by:
      `clear` in interface `Set<T>`
    Overrides:
      `clear` in class `HashSet<T>`
    Throws:
      `IllegalStateException` - if this set is currently locked

  - ### remove

    public boolean remove(Object o)
    Specified by:
      `remove` in interface `Collection<T>`
    Specified by:
      `remove` in interface `Set<T>`
    Overrides:
      `remove` in class `HashSet<T>`
    Throws:
      `IllegalStateException` - if this set is currently locked