Class ContainerHelper


  • public final class ContainerHelper
    extends java.lang.Object
    Typically used only internally by the threadly library. This class is designed to help with determining if a Runnable or Callable is contained at some point within a chain of CallableContainer or RunnableContainer.
    Since:
    1.0.0
    • Constructor Summary

      Constructors 
      Constructor Description
      ContainerHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.List<java.lang.Runnable> getContainedRunnables​(java.util.List<? extends RunnableContainer> sourceList)
      Takes in a list of runnable containers, and instead makes a list of the runnables which are contained in each item of the list.
      static boolean isContained​(java.lang.Runnable startRunnable, java.lang.Runnable compareTo)
      Checks if the start runnable equals the compareTo runnable, or if the compareTo runnable is contained within a wrapper of the startRunnable.
      static boolean isContained​(java.lang.Runnable startRunnable, java.util.concurrent.Callable<?> compareTo)
      Checks if the start runnable contains the provided callable.
      static boolean remove​(java.util.Collection<? extends RunnableContainer> source, java.lang.Runnable compareTo)
      Attempts to remove the provided runnable from the source collection.
      static boolean remove​(java.util.Collection<? extends RunnableContainer> source, java.util.concurrent.Callable<?> compareTo)
      Attempts to remove the provided callable from the source collection.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ContainerHelper

        public ContainerHelper()
    • Method Detail

      • remove

        public static boolean remove​(java.util.Collection<? extends RunnableContainer> source,
                                     java.lang.Runnable compareTo)
        Attempts to remove the provided runnable from the source collection. This uses the Collection.remove(Object) function to remove the container if it is found.
        Parameters:
        source - source collection to search over
        compareTo - Runnable to compare against in search
        Returns:
        true if collection was modified
        Since:
        2.0.0
      • remove

        public static boolean remove​(java.util.Collection<? extends RunnableContainer> source,
                                     java.util.concurrent.Callable<?> compareTo)
        Attempts to remove the provided callable from the source collection. This uses the Collection.remove(Object) function to remove the container if it is found.
        Parameters:
        source - source collection to search over
        compareTo - Callable to compare against in search
        Returns:
        true if collection was modified
        Since:
        2.0.0
      • isContained

        public static boolean isContained​(java.lang.Runnable startRunnable,
                                          java.lang.Runnable compareTo)
        Checks if the start runnable equals the compareTo runnable, or if the compareTo runnable is contained within a wrapper of the startRunnable.
        Parameters:
        startRunnable - runnable to start search at
        compareTo - runnable to be comparing against
        Returns:
        true if they are equivalent, or the compareTo runnable is contained within the start
      • isContained

        public static boolean isContained​(java.lang.Runnable startRunnable,
                                          java.util.concurrent.Callable<?> compareTo)
        Checks if the start runnable contains the provided callable.
        Parameters:
        startRunnable - runnable to start search at
        compareTo - callable to be comparing against
        Returns:
        true if the compareTo runnable is contained within the runnable
      • getContainedRunnables

        public static java.util.List<java.lang.Runnable> getContainedRunnables​(java.util.List<? extends RunnableContainer> sourceList)
        Takes in a list of runnable containers, and instead makes a list of the runnables which are contained in each item of the list.
        Parameters:
        sourceList - List of runnable containers to get interior runnable from
        Returns:
        A list of runnables which were contained in the source list
        Since:
        4.0.0