Class Flattener<E>

java.lang.Object
com._1c.g5.v8.dt.common.search.Flattener<E>
Direct Known Subclasses:
NodeFlattener

public abstract class Flattener<E> extends Object
Represents an abstract generic flattener of hierarchical structured objects.
Based on sequentially call of methods:
  1. accept(Object)
  2. hasChildren(Object)
  3. getChildren(Object)
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    accept(E origin)
    Uses for acceptance of object.
    Override this method to customize behaviour.
    final List<E>
    Flattens all hierarchical structured objects to the list by strategy "depth-first search" non-recursive.
    The initial capacity of the result list has designed for 100 objects.
    final List<E>
    flattenAll(Iterable<E> input, int maxDepth)
    Flattens all hierarchical structured objects to the list by strategy "depth-first search" non-recursive.
    The initial capacity of the result list has designed for 100 objects.
    protected abstract Collection<E>
    getChildren(E origin)
    Gets a collection of children.
    protected abstract boolean
    hasChildren(E origin)
    Gets a value indicating whether the specified origin is a container of objects.
    Override this method to indicate that we are interact with the container.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Flattener

      public Flattener()
  • Method Details

    • flattenAll

      public final List<E> flattenAll(Iterable<E> input)
      Flattens all hierarchical structured objects to the list by strategy "depth-first search" non-recursive.
      The initial capacity of the result list has designed for 100 objects.
      Parameters:
      input - the iterable container of hierarchical structured objects.
      Returns:
      the flat list of objects.
    • flattenAll

      public final List<E> flattenAll(Iterable<E> input, int maxDepth)
      Flattens all hierarchical structured objects to the list by strategy "depth-first search" non-recursive.
      The initial capacity of the result list has designed for 100 objects.
      Parameters:
      input - the iterable container of hierarchical structured objects.
      maxDepth - the maximum depth of hierarchy expanding. Zero or negative value is no limit.
      Returns:
      the flat list of objects.
    • accept

      protected boolean accept(E origin)
      Uses for acceptance of object.
      Override this method to customize behaviour.
      Parameters:
      origin - the origin object.
      Returns:
      true if can accept the specified origin; otherwise, false.
    • hasChildren

      protected abstract boolean hasChildren(E origin)
      Gets a value indicating whether the specified origin is a container of objects.
      Override this method to indicate that we are interact with the container.
      Parameters:
      origin - the origin object.
      Returns:
      true if the specified origin is a container of objects.
    • getChildren

      protected abstract Collection<E> getChildren(E origin)
      Gets a collection of children. This method will be called if hasChildren(Object) returns true.
      Override this method to provide children.
      Parameters:
      origin - the origin object.
      Returns:
      a collection of children, never null.
      See Also: