org.assertj.swing.format
Class IntrospectionComponentFormatter

java.lang.Object
  extended by org.assertj.swing.format.ComponentFormatterTemplate
      extended by org.assertj.swing.format.IntrospectionComponentFormatter
All Implemented Interfaces:
ComponentFormatter

public final class IntrospectionComponentFormatter
extends ComponentFormatterTemplate

Formatter that uses introspection to display property values of an AWT or Swing Component. This formatter does not support nested properties.

Author:
Alex Ruiz

Constructor Summary
IntrospectionComponentFormatter(Class<? extends Component> targetType, String... propertyNames)
          Creates a new IntrospectionComponentFormatter.
 
Method Summary
protected  String doFormat(Component c)
          Returns a String representation of the given AWT or Swing Component, showing only the properties specified in this formatter's constructor.
 Class<? extends Component> targetType()
          Returns the type of AWT or Swing Component this formatter supports.
 String toString()
           
 
Methods inherited from class org.assertj.swing.format.ComponentFormatterTemplate
format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntrospectionComponentFormatter

public IntrospectionComponentFormatter(@Nonnull
                                       Class<? extends Component> targetType,
                                       @Nonnull
                                       String... propertyNames)
Creates a new IntrospectionComponentFormatter.

Parameters:
targetType - the type of AWT or Swing Component that this formatter supports.
propertyNames - the property names to show as the String representation of a given Component.
Throws:
NullPointerException - if targetType is null.
Method Detail

doFormat

@RunsInCurrentThread
@Nonnull
protected String doFormat(@Nonnull
                                                      Component c)
Returns a String representation of the given AWT or Swing Component, showing only the properties specified in this formatter's constructor.

Specified by:
doFormat in class ComponentFormatterTemplate
Parameters:
c - the given Component.
Returns:
a String representation of the given Component.
Throws:
NullPointerException - if the given Component is null.
IllegalArgumentException - if the type of the given Component is not supported by this formatter.
See Also:
targetType()

targetType

@Nonnull
public Class<? extends Component> targetType()
Description copied from interface: ComponentFormatter
Returns the type of AWT or Swing Component this formatter supports.

Returns:
the type of AWT or Swing Component this formatter supports.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014–2015 AssertJ. All rights reserved.