Package io.csar

Class ConcernedThreadGroup

java.lang.Object
java.lang.ThreadGroup
io.csar.ConcernedThreadGroup
All Implemented Interfaces:
Concerned, Thread.UncaughtExceptionHandler

public class ConcernedThreadGroup extends ThreadGroup implements Concerned
A thread group that allows the retrieval of a concern on a per-thread-group basis.
Author:
Garret Wilson
See Also:
  • Constructor Details

    • ConcernedThreadGroup

      public ConcernedThreadGroup(@Nonnull String name, @Nonnull Concern... concerns)
      Thread group name and and concerns constructor. The current thread's thread group will be used as the parent.

      The concerns will be accessible using findConcern(Class) using the Concern.getConcernType() of each concern. If more than one concern has the same type, the latter concern has priority.

      Parameters:
      name - The name of the new thread group.
      concerns - The concerns to be retrievable from the thread group.
      Throws:
      NullPointerException - if the given name and/or concerns is null.
      SecurityException - If the current thread cannot create a thread in the specified thread group.
      See Also:
    • ConcernedThreadGroup

      public ConcernedThreadGroup(@Nonnull String name, @Nonnull Stream<Concern> concerns)
      Thread group name and and concerns constructor. The current thread's thread group will be used as the parent.

      The concerns will be accessible using findConcern(Class) using the Concern.getConcernType() of each concern. If more than one concern has the same type, the latter concern has priority.

      Parameters:
      name - The name of the new thread group.
      concerns - The concerns to be retrievable from the thread group.
      Throws:
      NullPointerException - if the given name and/or concerns is null.
      SecurityException - If the current thread cannot create a thread in the specified thread group.
      See Also:
    • ConcernedThreadGroup

      public ConcernedThreadGroup(@Nonnull ThreadGroup parent, @Nonnull String name, @Nonnull Concern... concerns)
      Thread group parent, thread group name, and concerns constructor.

      The concerns will be accessible using findConcern(Class) using the Concern.getConcernType() of each concern. If more than one concern has the same type, the latter concern has priority.

      Parameters:
      parent - The parent thread group.
      name - The name of the new thread group.
      concerns - The concerns to be retrievable from the thread group.
      Throws:
      NullPointerException - if the given parent thread group, name, and/or concerns is null.
      SecurityException - If the current thread cannot create a thread in the specified thread group.
      See Also:
    • ConcernedThreadGroup

      public ConcernedThreadGroup(@Nonnull ThreadGroup parent, @Nonnull String name, @Nonnull Stream<Concern> concerns)
      Thread group parent, thread group name, and concerns constructor.

      The concerns will be accessible using findConcern(Class) using the Concern.getConcernType() of each concern. If more than one concern has the same type, the latter concern has priority.

      Parameters:
      parent - The parent thread group.
      name - The name of the new thread group.
      concerns - The concerns to be retrievable from the thread group.
      Throws:
      NullPointerException - if the given parent thread group, name, and/or concerns is null.
      SecurityException - If the current thread cannot create a thread in the specified thread group.
      See Also:
  • Method Details

    • findConcern

      public <T extends Concern> Optional<T> findConcern(Class<T> concernType)
      Description copied from interface: Concerned
      Returns the concern for the given concern type.
      Specified by:
      findConcern in interface Concerned
      Type Parameters:
      T - The type of concern to retrieve.
      Parameters:
      concernType - The class of concern to retrieve.
      Returns:
      The concern associated with the given class.