# Class JobStateReasons

java.lang.Object
java.util.AbstractCollection<JobStateReason>
java.util.AbstractSet<JobStateReason>
java.util.HashSet<JobStateReason>
javax.print.attribute.standard.JobStateReasons

All Implemented Interfaces:
  `Serializable, Cloneable, Iterable<JobStateReason>, Collection<JobStateReason>, Set<JobStateReason>, Attribute, PrintJobAttribute`

public final class JobStateReasons extends HashSet<JobStateReason> implements PrintJobAttribute
Class `JobStateReasons` is a printing attribute class, a set of enumeration values, that provides additional information about the job's current state, i.e., information that augments the value of the job's `JobState` attribute.

Instances of `JobStateReason` do not appear in a Print Job's attribute set directly. Rather, a `JobStateReasons` attribute appears in the Print Job's attribute set. The `JobStateReasons` attribute contains zero, one, or more than one `JobStateReason` objects which pertain to the Print Job's status. The printer adds a `JobStateReason` object to the Print Job's JobStateReasons attribute when the corresponding condition becomes true of the Print Job, and the printer removes the `JobStateReason` object again when the corresponding condition becomes false, regardless of whether the Print Job's overall `JobState` also changed.

Class `JobStateReasons` inherits its implementation from class `java.util.HashSet`. Unlike most printing attributes which are immutable once constructed, class `JobStateReasons` is designed to be mutable; you can add `JobStateReason` objects to an existing `JobStateReasons` object and remove them again. However, like class `java.util.HashSet`, class `JobStateReasons` is not multiple thread safe. If a `JobStateReasons` object will be used by multiple threads, be sure to synchronize its operations (e.g., using a synchronized set view obtained from class `java.util.Collections`).

IPP Compatibility: The string value returned by each individual `JobStateReason` object's `toString()` method gives the IPP keyword value. The category name returned by `getName()` gives the IPP attribute name.

See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JobStateReasons()`
  Construct a new, empty job state reasons attribute; the underlying hash set has the default initial capacity and load factor.
  `JobStateReasons(int initialCapacity)`
  Construct a new, empty job state reasons attribute; the underlying hash set has the given initial capacity and the default load factor.
  `JobStateReasons(int initialCapacity, float loadFactor)`
  Construct a new, empty job state reasons attribute; the underlying hash set has the given initial capacity and load factor.
  `JobStateReasons(Collection<JobStateReason> collection)`
  Construct a new job state reasons attribute that contains the same `JobStateReason` objects as the given collection.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `add(JobStateReason o)`
  Adds the specified element to this job state reasons attribute if it is not already present.
  `final Class<? extends Attribute>`
  `getCategory()`
  Get the printing attribute class which is to be used as the "category" for this printing attribute value.
  `final String`
  `getName()`
  Get the name of the category of which this attribute value is an instance.

  ### Methods declared in class HashSet

  `clear, clone, contains, isEmpty, iterator, newHashSet, remove, size, spliterator, toArray, toArray`
  Modifier and Type
  Method
  Description
  `void`
  `clear()`
  Removes all of the elements from this set.
  `Object`
  `clone()`
  Returns a shallow copy of this `HashSet` instance: the elements themselves are not cloned.
  `boolean`
  `contains(Object o)`
  Returns `true` if this set contains the specified element.
  `boolean`
  `isEmpty()`
  Returns `true` if this set contains no elements.
  `Iterator<JobStateReason>`
  `iterator()`
  Returns an iterator over the elements in this set.
  `static <T> HashSet<T>`
  `newHashSet(int numElements)`
  Creates a new, empty HashSet suitable for the expected number of elements.
  `boolean`
  `remove(Object o)`
  Removes the specified element from this set if it is present.
  `int`
  `size()`
  Returns the number of elements in this set (its cardinality).
  `Spliterator<JobStateReason>`
  `spliterator()`
  Creates a late-binding and fail-fast `Spliterator` over the elements in this set.
  `Object[]`
  `toArray()`
  Returns an array containing all of the elements in this collection.
  `<T> T[]`
  `toArray(T[] a)`
  Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.

  ### Methods declared in class AbstractSet

  `equals, hashCode, removeAll`
  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object o)`
  Compares the specified object with this set for equality.
  `int`
  `hashCode()`
  Returns the hash code value for this set.
  `boolean`
  `removeAll(Collection<?> c)`
  Removes from this set all of its elements that are contained in the specified collection (optional operation).

  ### Methods declared in class AbstractCollection

  `addAll, containsAll, retainAll, toArray, toArray, toString`
  Modifier and Type
  Method
  Description
  `boolean`
  `addAll(Collection<? extends JobStateReason> c)`
  Adds all of the elements in the specified collection to this collection (optional operation).
  `boolean`
  `containsAll(Collection<?> c)`
  Returns `true` if this collection contains all of the elements in the specified collection.
  `boolean`
  `retainAll(Collection<?> c)`
  Retains only the elements in this collection that are contained in the specified collection (optional operation).
  `Object[]`
  `toArray()`
  Returns an array containing all of the elements in this collection.
  `<T> T[]`
  `toArray(T[] a)`
  Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
  `String`
  `toString()`
  Returns a string representation of this collection.

  ### Methods declared in class Object

  `finalize, getClass, notify, notifyAll, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected void`
  `finalize()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Finalization is deprecated and subject to removal in a future release.
  `final Class<?>`
  `getClass()`
  Returns the runtime class of this `Object`.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `final void`
  `wait()`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
  `final void`
  `wait(long timeoutMillis)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
  `final void`
  `wait(long timeoutMillis, int nanos)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

  ### Methods declared in interface Collection

  `parallelStream, removeIf, stream, toArray`
  Modifier and Type
  Method
  Description
  `default Stream<JobStateReason>`
  `parallelStream()`
  Returns a possibly parallel `Stream` with this collection as its source.
  `default boolean`
  `removeIf(Predicate<? super JobStateReason> filter)`
  Removes all of the elements of this collection that satisfy the given predicate (optional operation).
  `default Stream<JobStateReason>`
  `stream()`
  Returns a sequential `Stream` with this collection as its source.
  `default <T> T[]`
  `toArray(IntFunction<T[]> generator)`
  Returns an array containing all of the elements in this collection, using the provided `generator` function to allocate the returned array.

  ### Methods declared in interface Iterable

  `forEach`
  Modifier and Type
  Method
  Description
  `default void`
  `forEach(Consumer<? super JobStateReason> action)`
  Performs the given action for each element of the `Iterable` until all elements have been processed or the action throws an exception.

  ### Methods declared in interface Set

  `addAll, containsAll, retainAll`
  Modifier and Type
  Method
  Description
  `boolean`
  `addAll(Collection<? extends JobStateReason> c)`
  Adds all of the elements in the specified collection to this set if they're not already present (optional operation).
  `boolean`
  `containsAll(Collection<?> c)`
  Returns `true` if this set contains all of the elements of the specified collection.
  `boolean`
  `retainAll(Collection<?> c)`
  Retains only the elements in this set that are contained in the specified collection (optional operation).

- ## Constructor Details

  - ### JobStateReasons

    public JobStateReasons()
    Construct a new, empty job state reasons attribute; the underlying hash set has the default initial capacity and load factor.

  - ### JobStateReasons

    public JobStateReasons(int initialCapacity)
    Construct a new, empty job state reasons attribute; the underlying hash set has the given initial capacity and the default load factor.
    Parameters:
      `initialCapacity` - initial capacity
    Throws:
      `IllegalArgumentException` - if the initial capacity is negative

  - ### JobStateReasons

    public JobStateReasons(int initialCapacity, float loadFactor)
    Construct a new, empty job state reasons attribute; the underlying hash set has the given initial capacity and load factor.
    Parameters:
      `initialCapacity` - initial capacity
      `loadFactor` - load factor
    Throws:
      `IllegalArgumentException` - if the initial capacity is negative

  - ### JobStateReasons

    public JobStateReasons(Collection<JobStateReason> collection)
    Construct a new job state reasons attribute that contains the same `JobStateReason` objects as the given collection. The underlying hash set's initial capacity and load factor are as specified in the superclass constructor `HashSet(Collection)`.
    Parameters:
      `collection` - collection to copy
    Throws:
      `NullPointerException` - if `collection` is `null` or if any element in `collection` is `null`
      `ClassCastException` - if any element in `collection` is not an instance of class `JobStateReason`

- ## Method Details

  - ### add

    public boolean add(JobStateReason o)
    Adds the specified element to this job state reasons attribute if it is not already present. The element to be added must be an instance of class `JobStateReason`. If this job state reasons attribute already contains the specified element, the call leaves this job state reasons attribute unchanged and returns `false`.
    Specified by:
      `add` in interface `Collection<JobStateReason>`
    Specified by:
      `add` in interface `Set<JobStateReason>`
    Overrides:
      `add` in class `HashSet<JobStateReason>`
    Parameters:
      `o` - element to be added to this job state reasons attribute
    Returns:
      `true` if this job state reasons attribute did not already contain the specified element
    Throws:
      `NullPointerException` - if the specified element is `null`
      `ClassCastException` - if the specified element is not an instance of class `JobStateReason`
    Since:
      1.5

  - ### getCategory

    public final Class<? extends Attribute> getCategory()
    Get the printing attribute class which is to be used as the "category" for this printing attribute value.

    For class `JobStateReasons`, the category is class JobStateReasons itself.

    Specified by:
      `getCategory` in interface `Attribute`
    Returns:
      printing attribute class (category), an instance of class `java.lang.Class`

  - ### getName

    public final String getName()
    Get the name of the category of which this attribute value is an instance.

    For class JobStateReasons, the category name is `"job-state-reasons"`.

    Specified by:
      `getName` in interface `Attribute`
    Returns:
      attribute category name