Class CycleException

All Implemented Interfaces:
Serializable

public class CycleException extends RuntimeException
Signals that one or more cycles have been detected when attempting to topologically sort shapes in a DependencyGraph.
See Also:
  • Constructor Details

    • CycleException

      public CycleException(List<T> sortedNodes, Set<T> cyclicNodes)
      Constructs a CycleException.
      Type Parameters:
      T - The type of the node.
      Parameters:
      sortedNodes - A list of the nodes that were sorted successfully.
      cyclicNodes - A set of nodes that could not be sorted due to being part of a cycle.
  • Method Details

    • getCyclicNodes

      public <T> Set<T> getCyclicNodes(Class<T> expectedNodeType)
      Gets the set of nodes that are part of a cycle.

      This contains all nodes that are a part of any cycles. To see a list of individual cycles, use DependencyGraph.findCycles().

      Type Parameters:
      T - The type of the graph's nodes.
      Parameters:
      expectedNodeType - The expected type of the node, which will be checked to be compatible with the actual type. This is necessary because exceptions can't be generic.
      Returns:
      Returns a set of cyclic nodes.
    • getSortedNodes

      public <T> List<T> getSortedNodes(Class<T> expectedNodeType)
      Gets the list of nodes that could be sorted.
      Type Parameters:
      T - The type of the graph's nodes.
      Parameters:
      expectedNodeType - The expected type of the node, which will be checked to be compatible with the actual type. This is necessary because exceptions can't be generic.
      Returns:
      Returns the sorted list of non-cyclic nodes.