Interface BeanConverter

All Known Implementing Classes:
BasicBeanConverter

public interface BeanConverter
Abstract interface for Bean-Centric Test (BCT) object conversion and property access.

This interface defines the core contract for converting objects to strings and lists, and for accessing object properties in a uniform way. It forms the foundation of the BCT testing framework, enabling consistent object introspection and value extraction across different object types and structures.

Core Conversion Operations:
stringify(Object)
Converts any object to its string representation, handling nested structures
listify(Object)
Converts collection-like objects (arrays, Collections, Iterables, etc.) to List<Object>
swap(Object)
Pre-processes objects before conversion (e.g., unwrapping Optional, calling Supplier)
getProperty(Object, String)
Accesses object properties using multiple fallback mechanisms
Property Access Strategy:

The getProperty(Object, String) method uses a comprehensive fallback approach:

Usage in BCT Framework:

This interface is used internally by BCT assertion methods like:

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Determines if an object can be converted to a list.
    getNested(Object o, org.apache.juneau.junit.bct.NestedTokenizer.Token token)
    Extracts a nested property value using structured field access syntax.
    getProperty(Object object, String name)
    Accesses a named property or field from an object.
    <T> T
    getSetting(String key, T defaultValue)
    Retrieves a configuration setting value with a fallback default.
    Converts a collection-like object to a standardized List<Object> format.
    Converts an object to its string representation for testing purposes.
    Pre-processes objects before conversion operations.
  • Method Details

    • stringify

      Converts an object to its string representation for testing purposes.
      Parameters:
      o - The object to stringify
      Returns:
      The string representation of the object
    • listify

      Converts a collection-like object to a standardized List<Object> format.
      Parameters:
      o - The object to convert to a list. Must not be null.
      Returns:
      A List containing the elements
      Throws:
      IllegalArgumentException - if the object is null or cannot be converted to a list
    • canListify

      boolean canListify(Object o)
      Determines if an object can be converted to a list.
      Parameters:
      o - The object to test. May be null.
      Returns:
      True if the object can be listified, false if null or cannot be listified
    • swap

      Pre-processes objects before conversion operations.
      Parameters:
      o - The object to swap
      Returns:
      The swapped object, or the original object if no swapping is needed
    • getProperty

      Object getProperty(Object object, String name)
      Accesses a named property or field from an object.
      Parameters:
      object - The object to access properties from
      name - The property/field name to access
      Returns:
      The property value
      Throws:
      RuntimeException - if the property cannot be found or accessed
    • getSetting

      <T> T getSetting(String key, T defaultValue)
      Retrieves a configuration setting value with a fallback default.
      Type Parameters:
      T - The type of the setting value
      Parameters:
      key - The setting key to retrieve
      defaultValue - The value to return if the setting is not found
      Returns:
      The setting value if found, otherwise the default value
    • getNested

      String getNested(Object o, org.apache.juneau.junit.bct.NestedTokenizer.Token token)
      Extracts a nested property value using structured field access syntax.
      Parameters:
      o - The object to extract nested properties from. May be null.
      token - The parsed token containing the property access structure. Must not be null.
      Returns:
      A formatted string representation of the extracted nested values
      Throws:
      IllegalArgumentException - if the token is null