Package org.apache.juneau.junit.bct
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 SummaryModifier and TypeMethodDescriptionbooleancanListify(Object o) Determines if an object can be converted to a list.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> TgetSetting(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- 
stringifyConverts an object to its string representation for testing purposes.- Parameters:
- o- The object to stringify
- Returns:
- The string representation of the object
 
- 
listifyConverts 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
 
- 
canListifyDetermines 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
 
- 
swapPre-processes objects before conversion operations.- Parameters:
- o- The object to swap
- Returns:
- The swapped object, or the original object if no swapping is needed
 
- 
getPropertyAccesses 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
 
- 
getSettingRetrieves 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
 
- 
getNestedExtracts 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
 
 
-