org.assertj.swing.hierarchy
Class SingleComponentHierarchy

java.lang.Object
  extended by org.assertj.swing.hierarchy.SingleComponentHierarchy
All Implemented Interfaces:
ComponentHierarchy

public final class SingleComponentHierarchy
extends Object
implements ComponentHierarchy

A ComponentHierarchy created with a specified AWT or Swing Component as root.

Author:
Alex Ruiz

Constructor Summary
SingleComponentHierarchy(Container root, ComponentHierarchy hierarchy)
          Creates a new SingleComponentHierarchy.
 
Method Summary
 Collection<Component> childrenOf(Component c)
          Returns all the children of the given AWT or Swing Component.
 boolean contains(Component c)
          Indicates whether this ComponentHierarchy contains the given AWT or Swing Component.
 void dispose(Window w)
          Provides proper disposal of the given AWT or Swing Window, appropriate to this ComponentHierarchy.
 Container parentOf(Component c)
          Returns the parent for the given AWT or Swing Component.
 Container root()
           
 Collection<Container> roots()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingleComponentHierarchy

public SingleComponentHierarchy(@Nonnull
                                Container root,
                                @Nonnull
                                ComponentHierarchy hierarchy)
Creates a new SingleComponentHierarchy.

Parameters:
root - the root Component for this hierarchy.
hierarchy - the base ComponentHierarchy.
Method Detail

root

public Container root()
Returns:
the root Component in this hierarchy.

parentOf

@Nullable
public Container parentOf(@Nonnull
                                   Component c)
Returns the parent for the given AWT or Swing Component.

Specified by:
parentOf in interface ComponentHierarchy
Parameters:
c - the given Component.
Returns:
the parent component for the given Component.

roots

@Nonnull
public Collection<Container> roots()
Specified by:
roots in interface ComponentHierarchy
Returns:
a collection containing only the root Component in this hierarchy.

childrenOf

@Nonnull
public Collection<Component> childrenOf(@Nonnull
                                                Component c)
Description copied from interface: ComponentHierarchy
Returns all the children of the given AWT or Swing Component.

Specified by:
childrenOf in interface ComponentHierarchy
Parameters:
c - the given Component.
Returns:
all the children of the given Component.

contains

public boolean contains(@Nonnull
                        Component c)
Description copied from interface: ComponentHierarchy
Indicates whether this ComponentHierarchy contains the given AWT or Swing Component.

Specified by:
contains in interface ComponentHierarchy
Parameters:
c - the given Component.
Returns:
true if this ComponentHierarchy contains the given Component, false otherwise.

dispose

public void dispose(@Nonnull
                    Window w)
Description copied from interface: ComponentHierarchy
Provides proper disposal of the given AWT or Swing Window, appropriate to this ComponentHierarchy. After disposal, the Window and its descendants will no longer be reachable from this ComponentHierarchy.

Specified by:
dispose in interface ComponentHierarchy
Parameters:
w - the Window to dispose.


Copyright © 2014–2015 AssertJ. All rights reserved.